Awesome-claude-code microservices-knowledge

Microservices Architecture knowledge base. Provides service decomposition, communication patterns, API gateway, service discovery, and data management guidelines for architecture audits and generation.

install
source · Clone the upstream repo
git clone https://github.com/dykyi-roman/awesome-claude-code
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/dykyi-roman/awesome-claude-code "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/microservices-knowledge" ~/.claude/skills/dykyi-roman-awesome-claude-code-microservices-knowledge && rm -rf "$T"
manifest: skills/microservices-knowledge/SKILL.md
source content

Microservices Architecture Knowledge Base

Quick reference for microservices architecture patterns and PHP implementation guidelines.

Core Principles

Architecture Overview

┌──────────────────────────────────────────────────────────────────────────┐
│                     MICROSERVICES ARCHITECTURE                           │
├──────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   ┌──────────┐     ┌──────────────────┐     ┌──────────────────┐        │
│   │  Client   │────▶│   API Gateway    │────▶│   Service A      │        │
│   │          │     │  (Routing/Auth)   │     │  (Own Database)  │        │
│   └──────────┘     └──────────────────┘     └──────────────────┘        │
│                           │                       │                      │
│                           │                       │ async                │
│                    ┌──────▼──────┐          ┌─────▼──────────┐          │
│                    │  Service B  │          │  Message Broker │          │
│                    │ (Own DB)    │◀─────────│  (Events/Cmds)  │          │
│                    └─────────────┘          └────────────────┘          │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│   Decomposition Strategies:                                              │
│   • By Business Capability    - Align with bounded contexts             │
│   • By Subdomain (DDD)        - Core, Supporting, Generic               │
│   • Strangler Fig              - Incremental migration from monolith    │
│                                                                          │
│   Communication:                                                         │
│   • Synchronous  - REST, gRPC, GraphQL (request-response)              │
│   • Asynchronous - Message queues, event streaming                      │
│                                                                          │
└──────────────────────────────────────────────────────────────────────────┘

Service Communication Patterns

PatternTypeUse WhenTrade-off
RESTSyncCRUD, simple queriesEasy but coupling
gRPCSyncInternal service-to-service, performance-criticalFast but schema coupling
GraphQLSyncClient-driven queries, BFFFlexible but complex
Message QueueAsyncReliable delivery, work distributionDecoupled but eventual consistency
Event StreamingAsyncReal-time, event sourcing, audit trailsScalable but complex ordering
Request-ReplyAsyncAsync request needing responseDecoupled but higher latency

API Gateway Patterns

PatternDescriptionWhen to Use
Simple ProxyRoutes requests to servicesSmall number of services
Gateway AggregationCombines multiple service callsReduce client round-trips
BFF (Backend for Frontend)Gateway per client typeMobile vs Web vs API clients
Gateway OffloadingAuth, rate limiting, TLSCross-cutting concerns

Service Discovery

ApproachHow It WorksExample
Client-sideClient queries registry, selects instanceNetflix Eureka
Server-sideLoad balancer queries registryAWS ALB, Kubernetes
DNS-basedDNS SRV records resolve to instancesConsul DNS, CoreDNS
Platform-nativeContainer orchestrator handles routingKubernetes Services

Data Management

PatternDescriptionConsistency
Database per ServiceEach service owns its dataStrong (within service)
Shared DatabaseServices share one databaseStrong (anti-pattern!)
SagaDistributed transaction via eventsEventual
CQRSSeparate read/write modelsEventual
Event SourcingEvents as source of truthEventual
API CompositionQuery multiple services, merge resultsEventual

When to Use Microservices vs Monolith

FactorMonolithMicroservices
Team size< 10 developers> 10, multiple teams
Domain complexitySimple/moderateComplex, many bounded contexts
Scalability needsUniform scalingIndependent scaling per component
Deployment frequencyInfrequent, coordinatedFrequent, independent
Technology diversitySingle stackPolyglot needed
Organizational maturityStarting outDevOps culture, CI/CD mature

Detection Patterns

# Service boundary indicators
Grep: "HttpClient|GuzzleHttp|curl_init" --glob "**/Infrastructure/**/*.php"
Grep: "grpc|protobuf" --glob "**/*.php"

# API Gateway patterns
Grep: "X-Forwarded|X-Request-ID|X-Correlation" --glob "**/*.php"
Glob: **/Gateway/**/*.php

# Service discovery
Grep: "ServiceDiscovery|ServiceRegistry|consul|etcd" --glob "**/*.php"
Grep: "KUBERNETES_SERVICE|SERVICE_HOST" --glob "**/*.env*"

# Database per service
Grep: "DATABASE_URL|DB_CONNECTION" --glob "**/*.env*"
Grep: "DATABASE_HOST|DB_HOST" --glob "**/docker-compose*.yml"

# Inter-service communication
Grep: "AMQPChannel|RabbitMQ|Kafka|SQS" --glob "**/Infrastructure/**/*.php"
Grep: "EventPublisher|MessageBus" --glob "**/*.php"

Advanced Patterns

Strangler Fig Pattern

Incrementally migrate from monolith to microservices:

Phase 1: Proxy all traffic through gateway
Phase 2: Extract one feature to service, route via gateway
Phase 3: Repeat until monolith is empty shell
Phase 4: Decommission monolith

┌─────────┐     ┌──────────┐     ┌──────────────┐
│  Client  │────▶│ Gateway  │────▶│  New Service  │  (extracted)
│          │     │ (Router) │     └──────────────┘
│          │     │          │────▶┌──────────────┐
│          │     │          │     │  Monolith     │  (shrinking)
└─────────┘     └──────────┘     └──────────────┘

Migration Decision:

FactorExtract FirstKeep in Monolith
Change frequencyHighLow
Team ownershipDedicated teamShared
Scaling needsIndependent scalingUniform
Technology fitDifferent stack neededSame stack fine

API Gateway Aggregation Patterns

PatternWhenExample
Simple proxy1:1 route mapping
/users
→ User Service
AggregationClient needs data from N servicesOrder + Customer + Payment
BFFDifferent clients need different dataMobile vs Web vs API
OffloadingCross-cutting concernsAuth, rate limiting, TLS

Database-Per-Service Trade-offs

AspectShared DBDB per Service
ConsistencyACID transactionsSaga/eventual
QueryingJOIN across domainsAPI composition
IndependenceCoupled deploymentsIndependent
ComplexityLowHigh
Schema changesCoordinatedIndependent

References

For detailed information, load these reference files:

  • references/patterns.md
    — Service mesh, API gateway implementations, service discovery details, data consistency, Strangler Fig, database-per-service
  • references/antipatterns.md
    — Distributed monolith, shared database, missing boundaries, chatty communication