Skip to content

Add Order Service — Place Order, CI/CD#81

Open
npcjake wants to merge 23 commits into
mainfrom
order-service
Open

Add Order Service — Place Order, CI/CD#81
npcjake wants to merge 23 commits into
mainfrom
order-service

Conversation

@npcjake
Copy link
Copy Markdown

@npcjake npcjake commented May 26, 2026

Closes #40, #43
Partial #41, #42

What's included

API endpoints (OrderService/)

  • POST /api/orders — Place an order. Geocodes the delivery address via Nominatim, selects an available bot from BotNetApi, saves to Azure SQL, publishes a RobotOrderAssignment event to the robot-input Event Hub.
  • GET /api/orders/{id} — Get order status by order ID.
  • GET /api/orders?customerId={id} — Order history. customerId is formatted as "CustomerName:Phone" — whoever wires up the frontend history page will need to know this.

Infrastructure

  • EF Core + Azure SQL (jacob-orderservice-sql2.database.windows.net / OrderServiceDb). Managed Identity auth — deliverybot-order-service is already granted db_owner. Schema is created automatically on first startup via Database.Migrate().
  • Dockerfile (multi-stage, same pattern as BotNetApi)

CI/CD (.github/workflows/orderservice-deploy.yml)

  • Triggers on push to main with changes under OrderService/**
  • Runs unit tests → builds Docker image → pushes to deliverybotcr.azurecr.io → deploys to deliverybot-order-service Container App
  • Event Hub connection string injected via GitHub secret at deploy time

Tests (OrderService.Tests/)

  • Unit tests covering Place Order, Get Order, and Order History logic

Known gaps

#41 and #42 are partially complete. The endpoints exist, are fully wired up, and return real data — the skeleton is done. However, order status will always reflect what it was at placement (Pending or Assigned) because updating status requires consuming bot telemetry events from the Event Hub, which depends on the read model work (#64#70). Once those events are being published, the Order Service will need a consumer to update order status to InTransit or Delivered.

npcjake and others added 12 commits May 25, 2026 13:38
10 xUnit tests covering MapOrderTypeToItems (food/beverage/package/unknown),
PlaceOrderAsync status logic (Assigned/Pending), and GeocodeAddressAsync
fallback to downtown Spokane when Nominatim is unavailable or returns no results.
Uses EF Core InMemory and fake HTTP handler — no external dependencies needed.
Replaced shared deliverybotsystem-sql (William-admin) with jacob-orderservice-sql2
where jtonani1 is AAD admin. deliverybot-order-service managed identity is already
granted db_owner on OrderServiceDb. Also fixed BotNetApi URL placeholder in workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Issue #43 requires tests run before pushing image. Fails fast if any test fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@npcjake npcjake marked this pull request as draft May 26, 2026 22:06
@npcjake npcjake marked this pull request as ready for review May 26, 2026 22:07
@npcjake npcjake linked an issue May 26, 2026 that may be closed by this pull request
@philspokas philspokas self-requested a review May 26, 2026 22:31
@npcjake npcjake changed the title Add Order Service — Place Order, Get Status, Order History, CI/CD Add Order Service — Place Order, CI/CD May 26, 2026
@philspokas philspokas requested review from a team and removed request for philspokas May 27, 2026 18:26
Copy link
Copy Markdown
Collaborator

@jenny-curry jenny-curry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a new OrderService folder and put your two existing OrderService folders into it in order to keep the file structure clean when other PRs are merged

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a gitignore at this level

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .gitignore should be at the root level of the repository

npcjake and others added 6 commits May 28, 2026 14:03
Move OrderService and OrderService.Tests into a new OrderService/
parent dir to keep the file structure clean as other PRs merge, per
review feedback. Update workflow test path and docker build context
accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codify the deliverybot-order-service Container App as IaC under
Iac/order-service/, using a reusable container-app module. Reuses the
shared RG, Container App Environment, and ACR via data sources; the
module owns the app's identity, ACR-pull auth, ingress, and env/secret
configuration. Image tag stays owned by the CD pipeline (ignore_changes).

Validated with terraform validate + fmt and proven against the live app
via import (plan: 0 to destroy).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Provision the Container App via `terraform apply` before building and
rolling out the image, matching the team's admin-webapp pipeline pattern.
Terraform now owns the app's env vars/secrets, so the image-update step
only bumps the image tag (dropped --set-env-vars to avoid drift).

Add an import block so CI adopts the pre-existing app into remote state
on the first apply (removable afterward). Workflow also triggers on
Iac/order-service changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Iterate the non-sensitive secret names and look up values, instead of
passing the sensitive secrets map directly to for_each — which TF 1.9.x
rejects (the CI runner's version).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The CI service principal is RG-scoped and lacks subscription-level
provider registration rights (403). Providers are already registered,
so set resource_provider_registrations = "none".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Separate concerns: orderservice-iac.yml runs Terraform (plan on PR,
apply on merge to main), triggered by Iac/order-service changes.
orderservice-deploy.yml now only builds/pushes the image and rolls it
out, triggered by OrderService code changes. Terraform owns env/secrets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move UseSwagger/UseSwaggerUI out of the Development-only block so the
deployed API can be explored and tested from the browser at /swagger.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order Service CI/CD Pipeline Place an Order

2 participants