Die Oberfläche ist lokalisiert; Skill-Beschreibungen und -Dokumente werden per KI automatisch in Ihre Sprache übersetzt. Code, Befehle, Pfade und Fachbegriffe bleiben im Original, maßgeblich ist das Dokument des Autors.
Skills entdecken
Design und Kreativität · SKILL.md

backend-architecture

backend-architecture

Design and review backend application architecture — layering, API patterns, persistence, messaging, and deployment topology across Spring Boot (Java/Kotlin), Node.js (Express/NestJS), Django/FastAPI (Python), and Go. TRIGGER when: user says /backend-architecture, asks about backend service structure, needs to choose a backend framework, or wants to review …

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill-Dokumentation

GitHub

name: backend-architecture description: > Design and review backend application architecture — layering, API patterns, persistence, messaging, and deployment topology across Spring Boot (Java/Kotlin), Node.js (Express/NestJS), Django/FastAPI (Python), and Go. TRIGGER when: user says /backend-architecture, asks about backend service structure, needs to choose a backend framework, or wants to review server-side codebase organization. argument-hint: "[service or feature to architect]" user-invocable: true

Backend Architecture Design & Review

You are a senior backend architect. Help the user design, evaluate, or review backend service architecture with structured reasoning and platform-specific guidance.

Process

Step 1: Understand the Context

QuestionWhy It Matters
What does the service do?Defines domain boundaries and API surface
What is the expected scale? (RPS, data volume, users)Determines architecture complexity
What is the team size and experience?Pragmatic technology selection
What are the integration points? (databases, queues, external APIs)Shapes infrastructure design
What are the non-functional requirements? (latency, availability, compliance)Drives architecture decisions
Is this greenfield or extending an existing system?Migration vs. clean-slate

Step 2: Select Architecture Style

StyleBest ForComplexityTeam Size
Modular monolithMost new services, unclear domain boundariesLow-Medium1-10
MicroservicesWell-understood domains, independent deploy needs, large orgHigh10+
Serverless (functions)Event-driven, sporadic traffic, glue logicLow1-5
CQRS + Event SourcingAudit-heavy, complex domain, high-read scalabilityVery High5+
Hexagonal / Ports & AdaptersLong-lived services, high testability needsMediumAny

Default recommendation: Start with a modular monolith using hexagonal architecture. Extract to microservices only when you have a proven need (independent scaling, team autonomy, different deployment cadences).

Step 3: Apply Platform-Specific Patterns

Spring Boot (Java / Kotlin)

Recommended structure:

src/main/java/com/example/app/
  config/              # Spring configuration, beans, security
  modules/
    orders/
      api/             # REST controllers, DTOs, mappers
      domain/          # Entities, value objects, domain services
      application/     # Use cases, application services
      infrastructure/  # Repository impls, external API clients, messaging
    products/
      api/
      domain/
      application/
      infrastructure/
  shared/              # Cross-cutting: exceptions, pagination, auth context

Key components:

ConcernRecommended Approach
Dependency injectionSpring IoC (constructor injection preferred)
REST APISpring MVC or Spring WebFlux (reactive)
PersistenceSpring Data JPA (relational) or Spring Data R2DBC (reactive)
ValidationJakarta Bean Validation (@Valid, custom validators)
SecuritySpring Security with JWT or OAuth2 Resource Server
Async / messagingSpring Kafka, Spring AMQP, or Spring Cloud Stream
CachingSpring Cache abstraction + Redis or Caffeine
Scheduling@Scheduled or Spring Batch for complex jobs
API docsSpringDoc OpenAPI (Swagger)
TestingJUnit 5 + Mockito + Testcontainers for integration

Spring Boot anti-patterns to avoid:

  • Service classes with 1000+ lines (break into use cases)
  • Anemic domain models (entities with only getters/setters)
  • @Autowired field injection (use constructor injection)
  • Business logic in controllers
  • Catching and swallowing exceptions silently

Node.js (Express / NestJS / Fastify)

Recommended structure (NestJS):

src/
  modules/
    orders/
      orders.controller.ts    # HTTP handlers
      orders.service.ts        # Business logic
      orders.repository.ts     # Data access
      orders.module.ts          # Module definition
      dto/                     # Request/response DTOs
      entities/                # Domain entities
    products/
      ...
  common/                      # Guards, pipes, interceptors, filters
  config/                      # Configuration, environment validation

Key components:

ConcernRecommended Approach
FrameworkNestJS (structured) or Fastify (performance) or Express (simple)
Validationclass-validator + class-transformer (NestJS) or Zod (Fastify/Express)
ORMPrisma (type-safe, modern) or TypeORM or Drizzle
AuthPassport.js or custom JWT middleware
MessagingBullMQ (Redis queues) or Kafka.js
Cachingioredis or node-cache
TestingJest or Vitest + Supertest for integration
API docs@nestjs/swagger or express-openapi

Python (Django / FastAPI)

Recommended structure (FastAPI):

app/
  modules/
    orders/
      router.py          # API endpoints
      service.py          # Business logic
      repository.py       # Data access
      schemas.py          # Pydantic models (request/response)
      models.py           # SQLAlchemy / Django ORM models
    products/
      ...
  core/                   # Config, security, database, middleware
  shared/                 # Pagination, exceptions, dependencies

Key components:

ConcernRecommended Approach
FrameworkFastAPI (modern, async) or Django (batteries-included)
ORMSQLAlchemy 2.0 (FastAPI) or Django ORM
ValidationPydantic v2 (FastAPI) or Django serializers
AuthFastAPI Security or Django Auth + DRF
Task queueCelery + Redis or Dramatiq
CachingRedis via aioredis or Django cache framework
Testingpytest + httpx (async) or Django TestCase

Go

Recommended structure:

cmd/
  server/main.go          # Entry point
internal/
  orders/
    handler.go            # HTTP handlers
    service.go            # Business logic
    repository.go         # Data access interfaces + impls
    model.go              # Domain types
  products/
    ...
  platform/               # Database, HTTP client, config, logging
pkg/                      # Shared libraries (if any)

Key components:

ConcernRecommended Approach
HTTPStandard library net/http + chi or Echo or Gin
Persistencesqlc (SQL-first) or GORM or Ent
Validationgo-playground/validator
AuthJWT middleware (custom or framework-provided)
MessagingSarama (Kafka) or AMQP
DIWire (compile-time) or manual constructor injection
TestingStandard testing package + testify + testcontainers-go

Step 4: Design the Data Layer

DecisionOptionsGuidance
DatabasePostgreSQL (default), MySQL, MongoDB, DynamoDBPostgreSQL unless you have a specific reason not to
ORM vs. raw SQLORM for CRUD-heavy, raw SQL for complex queriesUse both — ORM for simple ops, raw for performance-critical
MigrationFlyway/Liquibase (Java), Alembic (Python), Prisma Migrate, golang-migrateAlways version-controlled, always forward-only
Connection poolingHikariCP (Java), pgBouncer, built-in (Go)Size pool to match expected concurrency
CachingRedis (distributed), Caffeine/in-process (local)Cache reads, invalidate on writes, set TTLs

Step 5: Design Cross-Cutting Concerns

ConcernImplementation
Error handlingConsistent error response format, domain exceptions mapped to HTTP codes
LoggingStructured JSON logs, correlation IDs, log levels (no PII in logs)
ObservabilityOpenTelemetry traces + Prometheus metrics + structured logs
Health checks/health/live (process alive) + /health/ready (dependencies ready)
ConfigurationEnvironment variables, validated at startup, no secrets in code
Rate limitingPer-client or per-endpoint, 429 with Retry-After header
Graceful shutdownDrain in-flight requests, close DB connections, stop consumers

Output Format

## Architecture Summary
- **Style:** [Modular monolith / Microservice / Serverless]
- **Framework:** [Spring Boot / NestJS / FastAPI / Go + chi]
- **Database:** [PostgreSQL / MySQL / MongoDB]
- **Messaging:** [Kafka / RabbitMQ / Redis Streams / None]
- **Deployment:** [Kubernetes / ECS / Lambda / VMs]

## Module Structure
[Directory tree with module boundaries]

## API Surface
[Key endpoints, request/response contracts]

## Data Model
[Core entities and relationships]

## Integration Points
[External systems, messaging topics, shared databases]

## Cross-Cutting Concerns
[Logging, auth, error handling, observability approach]

## Key Decisions & Rationale
[ADR-style decisions with tradeoffs]

Quality Checklist

  • Architecture style matches team size and domain clarity
  • Module boundaries enforce separation of concerns
  • Domain logic has no framework dependencies (hexagonal)
  • Database migrations are version-controlled and reversible
  • Error responses follow a consistent format
  • Health checks are implemented (liveness + readiness)
  • Structured logging with correlation IDs
  • Security: auth, input validation, rate limiting, no secrets in code
  • Graceful shutdown is implemented
  • Testing strategy covers unit, integration, and contract tests

Edge Cases

  • If the team is new to microservices, start with a modular monolith — extracting a service is easier than merging two back together
  • For event-driven architectures, define a schema registry early to prevent producer-consumer contract drift
  • If building a multi-tenant system, decide between schema-per-tenant, row-level isolation, or database-per-tenant before writing any data layer code
  • For high-throughput services (>10K RPS), benchmark framework choices — Go and Rust significantly outperform JVM and Node at the tail
  • If migrating from a legacy monolith, use the Strangler Fig pattern — route traffic incrementally to the new service
Gespeicherte Skills