Decide whether and how to split a system into services: bounded contexts, data ownership, sync and async communication, sagas, observability, security and deployment.
Act as a software architect. Design the service architecture for the system below. Start by testing whether separate services are justified; a modular monolith is a valid recommendation. Base boundaries on business capabilities and data ownership, not on technical layers. ## Inputs Domain and core workflows: [DOMAIN] Load and growth evidence (current traffic, expected peaks, data volume): [SCALE] Consistency requirements (what must never be wrong, what can be eventually consistent): [CONSISTENCY] Team structure and size: [TEAMS] Existing system and constraints (monolith, databases, cloud, compliance): [CONSTRAINTS] Preferred communication styles, if any (REST, gRPC, message broker): [COMMUNICATION] ## Instructions 1. Recommend an overall style (modular monolith, a few services, or many services) and justify it with [SCALE], [TEAMS] and [CONSISTENCY]. 2. Identify bounded contexts and services with their responsibilities and the data each owns. A service's data is accessed only through its API or events. 3. For each interaction choose synchronous (REST/gRPC) or asynchronous (events, queues), with the reason. 4. Design cross-service workflows (for example order, payment, inventory) as sagas with compensating actions, idempotent consumers and an outbox or equivalent for reliable event publishing. 5. Specify storage per service (relational, document, cache) based on its access patterns. 6. Failure handling: timeouts, retries with backoff only for idempotent calls, circuit breakers, and what users see when a dependency is down. 7. Observability: distributed tracing with propagated context, structured logs with correlation IDs, metrics per service, and alerts tied to user-facing objectives. 8. Security: authentication at the edge, service-to-service identity, authorization per service, encryption in transit, secret management. 9. Deployment and CI/CD: containerization, orchestration, independent pipelines, contract tests between services, and a migration path from [CONSTRAINTS]. ## Return 1. Recommendation and rationale. 2. Text system diagram. 3. Service catalog: responsibility, owned data, APIs and events, storage, owning team. 4. Interaction table and saga designs. 5. Failure, observability and security plans. 6. CI/CD and migration plan. 7. Tradeoffs, risks and decisions to revisit. ## Acceptance checks - No two services write to the same tables or collections. - Every cross-service workflow that changes money or stock has a defined compensation. - The recommended number of services is consistent with the team size. - No scalability or availability figure is promised without [SCALE] evidence. ## Compact version Design microservices for: Domain: [DOMAIN] Scale requirements: [SCALE] Communication: [SYNC/ASYNC] Provide: 1. Service decomposition 2. API contracts 3. Data ownership 4. Communication patterns 5. Deployment strategy 6. Monitoring approach
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Domain: online store with user accounts, product catalog, cart, orders, payments (external provider) and inventory across two warehouses Scale: about 40 orders per minute at peak sales; catalog of 80,000 products Consistency: never charge without reserving stock; never oversell limited items; catalog updates can lag by a minute Teams: one team of 6 engineers Constraints: existing Rails monolith with one PostgreSQL database; AWS Communication: no preference
A recommendation to keep a modular monolith for most contexts and, at most, extract one or two services where there is a clear reason (for example search/catalog indexing), because one team of six would carry the operational cost of many services; module boundaries for accounts, catalog, cart, ordering, payments and inventory with owned tables; an order saga (reserve stock, authorize payment, confirm, release stock on failure) using an outbox; idempotency keys on payment calls; tracing with correlation IDs; and a migration plan that enforces module boundaries before any extraction. Illustrative expectation, not a recorded model run.
Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
Guides for adapting and checking prompts: