backend-architect

$npx mdskill add tranhieutt/software_development_department/backend-architect

Designs scalable backend architectures covering microservices, event-driven systems, and data stores.

  • Captures requirements including domain context, use cases, and non-functional requirements.
  • Uses DDD bounded contexts and service decomposition to define service boundaries.
  • Decides on protocols and communication patterns based on use case and scale needs.
  • Produces service diagrams, ADRs, and API contracts for implementation.

SKILL.md

.github/skills/backend-architectView on GitHub ↗
---
name: backend-architect
type: workflow
description: "Designs scalable backend architectures covering microservices, event-driven systems, API gateways, and data stores. Use when designing a backend system or when the user mentions backend architecture, scalability, or distributed systems."
paths: ["**/src/**/*.ts", "**/src/**/*.js", "**/package.json"]
effort: 5
allowed-tools: Read, Glob, Grep, Write, Edit, Bash
argument-hint: "[project description or requirements]"
user-invocable: true
when_to_use: "When designing new backend services, defining service boundaries, or planning scalable API architecture"
---

# Backend Architect

## Workflow

1. **Capture requirements**: Domain context, use cases, NFRs (scale, latency, consistency)
2. **Define service boundaries**: DDD bounded contexts, service decomposition
3. **Design API contracts**: REST/GraphQL/gRPC with versioning strategy
4. **Plan communication**: Sync (REST, gRPC) vs async (queues, events)
5. **Build in resilience**: Circuit breakers, retries, timeouts, graceful degradation
6. **Design observability**: structured logging, RED metrics, distributed tracing
7. **Security**: Auth/Z strategy, rate limiting, secrets management
8. **Caching**: Layer strategy (app → API → CDN) with invalidation plan
9. **Document**: Service diagram (Mermaid), ADRs, trade-offs

## API design decision matrix

| Use case | Protocol | Reason |
|---|---|---|
| Standard CRUD API | REST | Widest tooling support |
| Client queries complex data | GraphQL | Reduces over-fetching |
| Internal service-to-service | gRPC | Typed contracts, low latency |
| Real-time bidirectional | WebSocket | Full duplex |
| Server push (one-way) | SSE | Simpler than WS for unidirectional |
| High-volume async work | SQS/Kafka | Decoupling, retry, backpressure |

## Service boundary rules (non-obvious)

- **Bounded context = 1 database** — shared DB across services creates hidden coupling; eventual consistency is the price of independence
- **Sync calls create latency chains** — A → B → C means P99(A) = P99(A) + P99(B) + P99(C); use async for non-blocking flows
- **Saga over 2PC** — distributed transactions via saga (choreography or orchestration); 2PC blocks and creates distributed deadlocks
- **Stateless for horizontal scale** — session state in Redis/DynamoDB, not in memory
- **Database per service, not schema per service** — separate schemas in shared DB = shared schema migrations = coupling still exists

## Resilience patterns (always include these)

```
Circuit Breaker: CLOSED → [failures > threshold] → OPEN → [timeout] → HALF-OPEN → [success] → CLOSED
Retry: exponential backoff with jitter — base_delay * 2^attempt + random(0, base_delay)
Timeout: always set; propagate deadline via context/headers
Bulkhead: separate thread pools per dependency; one slow dep shouldn't starve others
Idempotency: every mutating operation needs idempotency key; store result, return on duplicate
```

## Observability essentials

```
Logs:  structured JSON, always include: traceId, userId, duration, status
Metrics (RED): Rate (req/s), Errors (%), Duration (p50/p95/p99)
Traces: OpenTelemetry → Jaeger/Tempo; trace every cross-service call
Alerts: error rate > 1%, p99 latency > SLO, queue depth > threshold
```

## Caching strategy

| Layer | Tool | Pattern | Invalidation |
|---|---|---|---|
| App | Redis | Cache-aside | TTL + event-driven |
| API | CDN (CloudFront) | Read-through | Cache-Control headers |
| DB reads | Read replica | Direct query | N/A (replica lag) |

Cache-aside rule: **read → cache miss → DB → cache set → return**. Never write to cache directly on writes — let TTL or event invalidate.

## Auth patterns

- **User auth**: OAuth2 + OIDC, JWT access token (15 min TTL) + refresh token (7 days, rotated)  
- **Service-to-service**: mTLS or signed JWT with short expiry; never share user tokens between services
- **API keys**: Hash on storage (SHA-256), include key prefix in metadata for lookup

## Deliver

- Service diagram (Mermaid) showing communication patterns + boundaries
- API contract excerpt (OpenAPI or Protobuf)
- Auth/Z strategy
- Resilience patterns per dependency
- Caching plan with invalidation strategy
- Tech recommendations with explicit rationale
- ADR for each major decision

## Scope boundaries

- Database schema design → `database-architect`
- Infrastructure + cloud services → `cloud-architect`
- Comprehensive security audit → `security-auditor`
- System-wide performance optimization → `performance-engineer`

More from tranhieutt/software_development_department

SkillDescription
agent-healthReads production/traces/agent-metrics.jsonl and displays a per-agent performance summary table for the current or a specified session. Highlights agents with high error rates or OPEN circuit breaker state.
agent-styleProvides the vendored agent-style v0.3.5 prose rule pack as a portable Claude skill. Use when installing, syncing, applying, or auditing SDD Agent-Style support in another project, or when a style-review workflow needs the bundled rules.
angular-best-practicesProvides Angular best practices for components, modules, services, and reactive patterns. Use when working with Angular TypeScript files, component templates, NgModules, RxJS observables, or when the user mentions Angular, ng, or Angular CLI.
annotateRecords unexpected API behaviors, undocumented caveats, version bugs, or non-obvious workarounds into .claude/memory/annotations.md. Use immediately when an undocumented behavior or surprising caveat is discovered during development.
aws-serverlessProvides AWS serverless architecture patterns for Lambda, API Gateway, DynamoDB, SQS, and SAM/CDK. Use when working with AWS serverless files (serverless.yml, CDK stacks) or when the user mentions Lambda, API Gateway, serverless, or AWS SAM.
cloud-run-puppeteerDeploys Puppeteer browser automation on Google Cloud Run with Docker. Use when running headless browser tasks on Cloud Run, or when the user mentions Cloud Run, Puppeteer, headless Chrome, or serverless browser automation.
codex-sddAdapts SDD for Codex while preserving Claude Code behavior. Use when working in Codex, setting up Codex compatibility, mapping Claude tools to Codex tools, or explaining how SDD should run outside Claude Code.
database-architectDesigns relational and NoSQL database schemas, indexing strategies, migration plans, and data modeling patterns. Use when designing a database or when the user mentions database architecture, schema design, or data modeling.
db-reviewReviews database schemas, queries, and migrations for correctness, performance, security, and best practices. Use when reviewing SQL migration files or when the user mentions database review, schema review, or query audit.
deep-interviewConducts a structured technical deep-dive to gather detailed requirements, constraints, and decisions from the user. Use when starting a complex feature or when the user wants to be asked structured clarifying questions before implementation.