Skip to content

Extract Customer bounded context into the Customer service - #88

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789050524-customer-service
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789050524-customer-service

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Implements src/Services/Customer by porting the monolith's customer bounded context, keeping the wire shape identical to the monolith's CustomerVM so the Angular client can be repointed at the gateway without changes.

Domain owns customer fields only; the customer↔order link is an ID-only join row, so nothing in this service references an Order type:

class Customer { Id; Name; Email; PhoneNumber; Address; City; Gender; /* audit */ ICollection<CustomerOrderRef> OrderRefs }
class CustomerOrderRef { Id; CustomerId; int OrderId }   // no Order navigation

CustomerRepository.GetAllCustomersDataAsync reproduces the monolith's GetAllCustomersData (Include(OrderRefs).AsSingleQuery().OrderBy(Name)), minus the Order/OrderDetail/Product/Cashier graph that no longer lives here. GetTopActiveCustomersAsync(count)NotImplementedException in the monolith — ranks by OrderRefs.Count descending, then name. The controller fills in the verbs the monolith stubbed out (GET /{id}, POST, PUT, DELETE) with the monolith validator's rules (name required, gender required and parseable) and returns/accepts CustomerVM; OrderVM entries carry only Id (discount/comments stay at defaults since those fields are order-owned).

The controller is routed twice on purpose — the gateway strips /api/customers before forwarding, so it serves at both the service root and /api/customers for direct calls:

[Route("/")]
[Route("api/customers")]

Startup applies the EF migration and seeds the monolith's demo customers (idempotent), retrying while Postgres comes up, so GET /api/customers returns data on a fresh compose volume.

Repo fixes needed to make the stack build and boot: Identity/Notification/Order/Product .API projects referenced ..\..\Shared\... (one .. short, silently unresolved — Notification failed to compile); all now use ..\..\..\Shared\....

Tests: Customer.Tests (xUnit, added to the solution) runs characterization tests for the read path, CRUD, top-active, VM shape and the ID-only order representation against Postgres via Testcontainers, falling back to the EF in-memory provider when Docker is unavailable. Verified green on both paths (15/15).

Verified end-to-end with docker compose -f src/docker-compose.yml up --build: curl localhost:5000/api/customers returns the seeded customers through YARP, and GET /{id}, top-active/{count}, POST, PUT, DELETE all behave through the gateway.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/303c0deaab44431b977996c037eb49eb
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/303c0deaab44431b977996c037eb49eb?variant=devin
Requested by: @DhrovS

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant