From bff24f312466d8f11d5f408278916002a4ab6dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ren=C3=A9=20White=20Enciso?= Date: Mon, 9 Mar 2026 11:57:46 -0600 Subject: [PATCH] chore(furniture-service): checkpoint pending development updates --- .dockerignore | 9 +++++ Directory.Build.props | 4 +- Dockerfile | 23 +++++++++++ docs/application/use-case-boundaries.md | 1 + .../package-publication-baseline.md | 2 +- docs/roadmap/feature-epics.md | 18 +++++++++ docs/runbooks/containerization.md | 40 +++++++++++++++++++ .../GetFurnitureAvailabilityUseCase.cs | 38 +++++++++++++++++- src/Furniture.Service.Grpc/Program.cs | 10 +++++ .../RuntimeWiringTests.cs | 17 ++++++++ 10 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docs/roadmap/feature-epics.md create mode 100644 docs/runbooks/containerization.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..636f769 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +**/bin/ +**/obj/ +.vs/ +TestResults/ +.git/ +.repo-tasks/ +.repo-context/ +.tasks/ +.agile/ diff --git a/Directory.Build.props b/Directory.Build.props index 743f406..fb69ff9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,8 +3,8 @@ AgileWebs AgileWebs git - http://192.168.10.100:3000/AgileWebs/furniture-service - http://192.168.10.100:3000/AgileWebs/furniture-service + https://gitea.dream-views.com/AgileWebs/furniture-service + https://gitea.dream-views.com/AgileWebs/furniture-service false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4cc6a21 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.7 +ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0 +ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0 + +FROM ${SDK_IMAGE} AS build +ARG NUGET_FEED_URL=https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json +ARG NUGET_FEED_USERNAME= +ARG NUGET_FEED_TOKEN= +WORKDIR /src +COPY . . + +RUN if [ -n "$NUGET_FEED_USERNAME" ] && [ -n "$NUGET_FEED_TOKEN" ]; then dotnet nuget add source "$NUGET_FEED_URL" --name gitea-org --username "$NUGET_FEED_USERNAME" --password "$NUGET_FEED_TOKEN" --store-password-in-clear-text --allow-insecure-connections --configfile /root/.nuget/NuGet/NuGet.Config; fi + +RUN dotnet restore "src/Furniture.Service.Grpc/Furniture.Service.Grpc.csproj" --configfile /root/.nuget/NuGet/NuGet.Config +RUN dotnet publish "src/Furniture.Service.Grpc/Furniture.Service.Grpc.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore + +FROM ${RUNTIME_IMAGE} AS runtime +WORKDIR /app +ENV ASPNETCORE_ENVIRONMENT=Production +EXPOSE 8080 +EXPOSE 8081 +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Furniture.Service.Grpc.dll"] diff --git a/docs/application/use-case-boundaries.md b/docs/application/use-case-boundaries.md index 6f3d865..38dc1a4 100644 --- a/docs/application/use-case-boundaries.md +++ b/docs/application/use-case-boundaries.md @@ -6,6 +6,7 @@ - Use cases depend on DAL-facing ports, not persistence implementations. - Use cases consume BuildingBlock capability contracts through adapter and port boundaries. - Transport handlers map to use-case contracts and do not own orchestration logic. +- Demo/runtime aliases (`demo-context`, `FURN-*`, `PROD-FURN-*`) are normalized at use-case orchestration before port calls. ## Current Skeleton diff --git a/docs/architecture/package-publication-baseline.md b/docs/architecture/package-publication-baseline.md index 56853e1..62a0578 100644 --- a/docs/architecture/package-publication-baseline.md +++ b/docs/architecture/package-publication-baseline.md @@ -2,7 +2,7 @@ ## Feed -- Source: `http://192.168.10.100:3000/api/packages/AgileWebs/nuget/index.json` +- Source: `https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json` - Authentication: Gitea login + token - HTTP requirement: `allowInsecureConnections="true"` in `nuget.config` diff --git a/docs/roadmap/feature-epics.md b/docs/roadmap/feature-epics.md new file mode 100644 index 0000000..77e7ccf --- /dev/null +++ b/docs/roadmap/feature-epics.md @@ -0,0 +1,18 @@ +# Feature Epics + +## Repository +furniture-service + +## Core Epics +- Epic 1: Expand domain-aligned capabilities for restaurant operations. +- Epic 2: Stabilize service contracts for containerized runtime integration. +- Epic 3: Improve observability and operational readiness for demo compose environments. + +## Domain-Specific Candidate Features +- Order lifecycle consistency and state transitions. +- Kitchen queue and dispatch optimization hooks. +- Operations control-plane policies (flags, service windows, overrides). +- POS closeout and settlement summary alignment. + +## Documentation Contract +Any code change in this repository must include docs updates in the same branch. diff --git a/docs/runbooks/containerization.md b/docs/runbooks/containerization.md new file mode 100644 index 0000000..61ab5f8 --- /dev/null +++ b/docs/runbooks/containerization.md @@ -0,0 +1,40 @@ +# Containerization Runbook + +## Image Build + +If the repo consumes internal packages from Gitea, pass feed credentials as build args. + +```bash +docker build --build-arg NUGET_FEED_USERNAME= --build-arg NUGET_FEED_TOKEN= -t agilewebs/furniture-service:dev . +``` + +## Local Run + +```bash +docker run --rm -p 8080:8080 --name furniture-service agilewebs/furniture-service:dev +``` + +## Health Probe + +- Path: `/health` +- Fallback path: `/healthz` +- Port: `8080` + +## Runtime Notes + +- Exposes internal service endpoint set plus gRPC runtime surface. + +## Health Endpoint Consistency + +- Canonical probe: `/health` +- Compatibility probe: `/healthz` +- Container port: `8080` + +## Demo Integration + +- Participates in: **furniture** demo compose stack. +- Integration artifact path: `greenfield/demo/furniture/docker-compose.yml` +## Known Limitations + +- Current runtime adapters are still predominantly in-memory for deterministic local/demo behavior. +- Demo PostgreSQL seeds validate integration contracts and smoke determinism, but do not yet imply full persistence implementation parity. diff --git a/src/Furniture.Service.Application/UseCases/GetFurnitureAvailabilityUseCase.cs b/src/Furniture.Service.Application/UseCases/GetFurnitureAvailabilityUseCase.cs index a2e4dc2..8ee53cc 100644 --- a/src/Furniture.Service.Application/UseCases/GetFurnitureAvailabilityUseCase.cs +++ b/src/Furniture.Service.Application/UseCases/GetFurnitureAvailabilityUseCase.cs @@ -14,14 +14,38 @@ public sealed class GetFurnitureAvailabilityUseCase( IFurnitureAvailabilityReadPort inventoryReadPort) : IGetFurnitureAvailabilityUseCase { + private static readonly IReadOnlyDictionary LookupAliases = + new Dictionary(StringComparer.OrdinalIgnoreCase) + { + ["demo-context"] = ("FUR-001", "PRD-001"), + ["FURN-001"] = ("FUR-001", "PRD-001"), + ["FURN-002"] = ("FUR-002", "PRD-002"), + ["FURN-003"] = ("FUR-003", "PRD-003"), + ["PROD-FURN-001"] = ("FUR-001", "PRD-001"), + ["PROD-FURN-002"] = ("FUR-002", "PRD-002"), + ["PROD-FURN-003"] = ("FUR-003", "PRD-003"), + ["FUR-001"] = ("FUR-001", "PRD-001"), + ["FUR-002"] = ("FUR-002", "PRD-002"), + ["FUR-003"] = ("FUR-003", "PRD-003"), + ["PRD-001"] = ("FUR-001", "PRD-001"), + ["PRD-002"] = ("FUR-002", "PRD-002"), + ["PRD-003"] = ("FUR-003", "PRD-003") + }; + /// public async Task HandleAsync(GetFurnitureAvailabilityRequest request) { var domainRequest = new FurnitureAvailabilityDecisionRequest( request.FurnitureId, request.CorrelationId); - var catalogRequest = decisionService.BuildCatalogRequest(domainRequest); - var inventoryRequest = decisionService.BuildInventoryRequest(domainRequest); + var lookupKeys = ResolveLookupKeys(request.FurnitureId); + + var catalogRequest = decisionService + .BuildCatalogRequest(domainRequest) + with { ProductId = lookupKeys.CatalogProductId }; + var inventoryRequest = decisionService + .BuildInventoryRequest(domainRequest) + with { ItemCode = lookupKeys.InventoryItemCode }; var catalogTask = catalogReadPort.ReadProductAsync(catalogRequest); var inventoryTask = inventoryReadPort.ReadAvailabilityAsync(inventoryRequest); @@ -38,4 +62,14 @@ public sealed class GetFurnitureAvailabilityUseCase( domainResponse.DisplayName, domainResponse.QuantityAvailable); } + + private static (string InventoryItemCode, string CatalogProductId) ResolveLookupKeys(string furnitureId) + { + if (LookupAliases.TryGetValue(furnitureId, out var mappedKeys)) + { + return mappedKeys; + } + + return (furnitureId, furnitureId); + } } diff --git a/src/Furniture.Service.Grpc/Program.cs b/src/Furniture.Service.Grpc/Program.cs index 4f71e79..2351710 100644 --- a/src/Furniture.Service.Grpc/Program.cs +++ b/src/Furniture.Service.Grpc/Program.cs @@ -1,7 +1,16 @@ using Furniture.Service.Application.DependencyInjection; using Furniture.Service.Grpc.Services; +using Microsoft.AspNetCore.Server.Kestrel.Core; var builder = WebApplication.CreateBuilder(args); +var httpPort = builder.Configuration.GetValue("FurnitureService:HttpPort", 8080); +var grpcPort = builder.Configuration.GetValue("FurnitureService:GrpcPort", 8081); + +builder.WebHost.ConfigureKestrel(options => +{ + options.ListenAnyIP(httpPort, listenOptions => listenOptions.Protocols = HttpProtocols.Http1); + options.ListenAnyIP(grpcPort, listenOptions => listenOptions.Protocols = HttpProtocols.Http2); +}); builder.Services.AddGrpc(); builder.Services.AddHealthChecks(); @@ -11,5 +20,6 @@ var app = builder.Build(); app.MapGrpcService(); app.MapHealthChecks("/healthz"); +app.MapHealthChecks("/health"); app.Run(); diff --git a/tests/Furniture.Service.Application.UnitTests/RuntimeWiringTests.cs b/tests/Furniture.Service.Application.UnitTests/RuntimeWiringTests.cs index 18e861e..df85989 100644 --- a/tests/Furniture.Service.Application.UnitTests/RuntimeWiringTests.cs +++ b/tests/Furniture.Service.Application.UnitTests/RuntimeWiringTests.cs @@ -21,6 +21,23 @@ public class RuntimeWiringTests var response = await useCase.HandleAsync(new GetFurnitureAvailabilityRequest("FUR-001", "corr-123")); Assert.Equal("FUR-001", response.FurnitureId); + Assert.Equal("Contoso Lounge Chair", response.DisplayName); + Assert.Equal(8, response.QuantityAvailable); + } + + [Fact] + public async Task AddFurnitureServiceRuntime_WhenUsingDemoFurnitureAlias_ResolvesMappedAvailability() + { + var services = new ServiceCollection(); + services.AddFurnitureServiceRuntime(); + + using var provider = services.BuildServiceProvider(); + var useCase = provider.GetRequiredService(); + + var response = await useCase.HandleAsync(new GetFurnitureAvailabilityRequest("FURN-001", "corr-123")); + + Assert.Equal("FURN-001", response.FurnitureId); + Assert.Equal("Contoso Lounge Chair", response.DisplayName); Assert.Equal(8, response.QuantityAvailable); }