microservices-fundamentals/SKILL.md
Core microservices concepts — monolith vs microservices trade-offs, decomposition patterns, the 12-Factor App adapted for microservices, bounded contexts, data isolation, and stateless design. Invoke before designing any microservices-based...
npx skillsauth add peterbamuhigire/skills-web-dev microservices-fundamentalsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
microservices-fundamentals or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.A microservices architecture structures an application as a collection of small, independently deployable services. Each service:
Do not recommend microservices by default. Make the call deliberately.
| Factor | Monolith | Microservices | |--------|----------|---------------| | Team size | < 10 developers | 10+ developers (or multiple teams) | | Deployment | One release for everything | Independent per service | | Scalability | Scale the whole app | Scale only bottleneck services | | Complexity | Low (one codebase) | High (network, distributed state) | | Technology | Single stack | Best tool per service | | Data | Shared DB (easy joins) | Separate DB per service (complex queries) | | Failure | One crash = total outage | Service isolation limits blast radius | | Testing | Straightforward integration tests | Requires contract + integration testing | | Startup speed | Fast to start | Slow — many services to orchestrate |
When to choose microservices:
When to stay monolithic:
Migration path: Start monolithic → extract services one at a time using the Strangler Fig pattern as boundaries become clear.
Align services with what the business does, not what the technology is.
School Management System
├── enrollment-service (admissions, registrations)
├── academic-service (grades, reports, transcripts)
├── finance-service (fees, payments, invoices)
├── communication-service (notifications, messages)
├── ai-service (analytics, predictions) ← separate, gated
└── identity-service (auth, roles, tenants)
Use Domain-Driven Design bounded contexts. Each subdomain becomes a service boundary. Cross-subdomain communication = API call, never a shared table.
Incrementally replace a monolith:
Key rule: Never split a service before you understand the boundary. A wrong split creates a distributed monolith — all the complexity of microservices, none of the benefits.
Source: Stetson, NGINX MRA Ch. 5
| Factor | Rule | Microservices-Specific Adaptation |
|--------|------|-----------------------------------|
| 1. Codebase | One codebase per service in revision control | One Git repo per service (not a monorepo unless using proper tooling) |
| 2. Dependencies | Explicitly declare and isolate dependencies | Use language dependency manager + Dockerfile for OS deps |
| 3. Config | Store config in environment variables | .env files locally (never committed); Vault or platform secrets in CI/CD |
| 4. Backing Services | Treat all external services as attached resources | Other microservices are backing services too — swap them by config |
| 5. Build/Release/Run | Strictly separate build and run stages | Docker image from every commit = deployment artifact; CI/CD mandatory |
| 6. Processes | Stateless processes | Services must be stateless — store shared state in Redis, not in-memory |
| 7. Data Isolation | Each service manages its own data | Access another service's data only via its API — never via direct DB query |
| 8. Concurrency | Scale via process model | Scale each service independently; horizontal scaling by adding instances |
| 9. Disposability | Fast startup, graceful shutdown | Containers start/stop instantly; queues absorb in-flight work on shutdown |
| 10. Dev/Prod Parity | Keep all environments identical | Docker containers enforce parity; diff in data can still cause surprises |
| 11. Logs | Treat logs as event streams | Stream to centralized log system (ELK, Loki) — services never write log files |
| 12. Admin Processes | Run admin tasks as one-off processes | Spin up a container for migrations/admin tasks, then destroy it |
The cardinal rule: Each service owns its data. No other service may read or write that data directly.
❌ WRONG — finance-service queries enrollment DB directly
SELECT balance FROM enrollment.student_accounts WHERE student_id = 42;
✅ CORRECT — finance-service calls enrollment-service API
GET /api/v1/students/42/enrollment-status
→ { "enrolled": true, "programme": "S.4" }
Why this matters:
Handling cross-service queries (reporting):
Services must not hold state in memory between requests.
Stateful (bad):
// ❌ — session stored in service memory; breaks horizontal scaling
$_SESSION['cart'] = $cartItems;
Stateless (good):
// ✅ — session stored in Redis backing service
$redis->set("cart:{$userId}", json_encode($cartItems), 3600);
What goes in backing services:
| Term | Definition | |------|-----------| | Bounded Context | The boundary within which a domain model is consistent and self-contained | | Service Mesh | Infrastructure layer managing service-to-service communication | | API Gateway | Single entry point that routes, authenticates, and transforms requests | | Service Registry | Database of live service instances (Consul, etcd, Kubernetes DNS, ZooKeeper) | | Circuit Breaker | Pattern that stops calling a failing service to allow recovery | | Strangler Fig | Migration pattern for incrementally replacing a monolith | | Sidecar | A helper container deployed alongside each service instance |
See also:
microservices-architecture-models — Proxy, Router Mesh, Fabric modelsmicroservices-communication — Service discovery, sync vs async, inter-service authmicroservices-resilience — Circuit breaker, health checks, load balancingmicroservices-ai-integration — AI as a microservice, AI gateway, async AI pipelinesdata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...