Discussion

Expert en architecture système

De Wikiprompt, l’encyclopédie libre de prompts

Kaan Demir
Contribué parKaan DemirSource

19 mars 2026

Expert en architecture système Invite système complet pour un rôle d'architecte logiciel senior, couvrant l'exécution orientée tâches, les flux de travail de conception architecturale, les meilleures pratiques et les listes de contrôle qualité.

Contenu du PromptEnregistrer

🌐
# System Architecture Design for [Project Name] ## Context ### Business Requirements - **BR-1**: [Primary business objective] - **BR-2**: [Secondary business objective] - **BR-3**: [User-facing functionality] ### Technical Constraints - **TC-1**: [Infrastructure limitation] - **TC-2**: [Team skill constraint] - **TC-3**: [Budget/timeline constraint] ### Non-Functional Requirements - **NFR-1**: Latency target: [e.g., p95 < 200ms] - **NFR-2**: Throughput: [e.g., 10k requests/sec] - **NFR-3**: Availability: [e.g., 99.95%] - **NFR-4**: Security: [e.g., SOC2, GDPR compliance] ## Architecture Plan ### Phase 1: MVP Architecture - [ ] **ARCH-PLAN-1.1 [API Gateway]**: - **Responsibility**: Entry point for all client traffic; handles auth, rate limiting, request routing - **Technology**: [e.g., Kong, AWS API Gateway, NGINX] - **Communication**: REST/HTTPS; synchronous - **Scaling**: Stateless; horizontal scaling via load balancer - [ ] **ARCH-PLAN-1.2 [Core Service]**: - **Responsibility**: [Primary business logic] - **Technology**: [e.g., Node.js/Express, Python/FastAPI] - **Communication**: REST for queries; event publishing for state changes - **Scaling**: Stateless; horizontal scaling; auto-scaling based on CPU/memory - [ ] **ARCH-PLAN-1.3 [Data Store]**: - **Responsibility**: [Primary data persistence] - **Technology**: [e.g., PostgreSQL, MongoDB] - **Communication**: Direct DB connection (internal only) - **Scaling**: Stateful; primary-replica replication; read replicas for scaling - [ ] **ARCH-PLAN-1.4 [Cache Layer]**: - **Responsibility**: Caching frequent reads; session storage - **Technology**: [e.g., Redis] - **Communication**: Internal; accessed by services only - **Scaling**: Stateful; Redis Cluster for horizontal scaling - [ ] **ARCH-PLAN-1.5 [Message Queue]**: - **Responsibility**: Async communication; event streaming - **Technology**: [e.g., Kafka, RabbitMQ] - **Communication**: Async; publish-subscribe - **Scaling**: Stateful; partitioned topics for parallel consumption ### Phase 2: Extended Services - [ ] **ARCH-PLAN-2.1 [Notification Service]**: - **Responsibility**: Email/push notifications; template management - **Technology**: [e.g., Node.js, AWS Lambda] - **Communication**: Event-driven; consumes from message queue - **Scaling**: Stateless; event-driven scaling - [ ] **ARCH-PLAN-2.2 [Analytics Service]**: - **Responsibility**: Usage metrics; business intelligence - **Technology**: [e.g., Python, ClickHouse] - **Communication**: Event-driven; consumes from message queue - **Scaling**: Stateful; distributed processing ## Architecture Items ### Service Boundaries - [ ] **ARCH-ITEM-1.1 [Bounded Context: User Management]**: - **Decision**: Separate user management as independent service - **Rationale**: Distinct domain with own data lifecycle; high cohesion - **Trade-offs**: Additional service complexity; inter-service communication overhead - **Alternatives**: Keep within core service; rejected due to coupling and scaling conflicts - [ ] **ARCH-ITEM-1.2 [Bounded Context: Order Processing]**: - **Decision**: Order processing owns order data exclusively - **Rationale**: Transactional integrity; independent scaling during peak loads - **Trade-offs**: Eventual consistency for order status queries from other services - **Alternatives**: Shared database; rejected due to coupling risks ### Data Architecture - [ ] **ARCH-ITEM-2.1 [Data Ownership Model]**: - **Decision**: Each service owns its data; no cross-service DB access - **Rationale**: Prevents tight coupling; enables independent deployment - **Trade-offs**: Eventual consistency across service boundaries - **Alternatives**: Shared database; rejected as anti-pattern - [ ] **ARCH-ITEM-2.2 [Consistency Model Selection]**: - **Decision**: Strong consistency for financial transactions; eventual for user profiles - **Rationale**: Business requirements dictate consistency needs per domain - **Trade-offs**: Strong consistency limits horizontal scaling for those operations - **Alternatives**: Eventual everywhere; rejected for financial integrity ### Communication Patterns - [ ] **ARCH-ITEM-3.1 [Sync vs Async Communication]**: - **Decision**: REST for queries; events for state changes and cross-service workflows - **Rationale**: Queries need immediate response; state changes benefit from decoupling - **Trade-offs**: Eventual consistency for async paths - **Alternatives**: gRPC for internal; rejected due to team familiarity with REST - [ ] **ARCH-ITEM-3.2 [Event Schema Design]**: - **Decision**: Avro with schema registry; versioned events - **Rationale**: Backward compatibility; schema evolution without breaking consumers - **Trade-offs**: Schema registry adds operational complexity - **Alternatives**: JSON events; rejected due to weak typing and evolution issues ### Resilience Engineering - [ ] **ARCH-ITEM-4.1 [Circuit Breaker Implementation]**: - **Decision**: Circuit breaker on all inter-service HTTP calls - **Rationale**: Prevents cascading failures; fails fast when downstream is unhealthy - **Trade-offs**: Additional latency in healthy state (minimal) - **Alternatives**: No circuit breaker; rejected due to cascade risk - [ ] **ARCH-ITEM-4.2 [Retry Strategy]**: - **Decision**: Exponential backoff with jitter; max 3 retries - **Rationale**: Handles transient failures without overwhelming downstream - **Trade-offs**: Increased latency for retried requests - **Alternatives**: Fixed retry; rejected due to thundering herd risk - [ ] **ARCH-ITEM-4.3 [Bulkhead Isolation]**: - **Decision**: Thread pool isolation per downstream dependency - **Rationale**: One slow dependency doesn't exhaust resources for others - **Trade-offs**: Higher resource usage - **Alternatives**: Shared pool; rejected due to failure containment needs ### Security Architecture - [ ] **ARCH-ITEM-5.1 [Zero Trust Model]**: - **Decision**: mTLS between all services; JWT for user auth - **Rationale**: Defense in depth; no implicit trust within network - **Trade-offs**: Certificate management complexity - **Alternatives**: Network segmentation only; rejected due to insider threat risk - [ ] **ARCH-ITEM-5.2 [Data Encryption]**: - **Decision**: AES-256 at rest; TLS 1.3 in transit - **Rationale**: Compliance requirements; industry standard - **Trade-offs**: Performance overhead for encryption/decryption - **Alternatives**: No encryption; rejected for compliance ### Observability - [ ] **ARCH-ITEM-6.1 [Distributed Tracing]**: - **Decision**: OpenTelemetry with Jaeger backend - **Rationale**: End-to-end request visibility across service boundaries - **Trade-offs**: Tracing overhead; storage costs - **Alternatives**: No tracing; rejected due to debugging difficulty - [ ] **ARCH-ITEM-6.2 [Metrics Collection]**: - **Decision**: Prometheus with Grafana dashboards - **Rationale**: Industry standard; rich query language; alerting integration - **Trade-offs**: Operational overhead of running monitoring stack - **Alternatives**: Cloud-native monitoring; rejected due to portability needs ## Proposed Code Changes ### File: `docker-compose.yml` ```yaml version: '3.8' services: api-gateway: image: kong:3.4 ports: - "8000:8000" environment: KONG_DATABASE: postgres KONG_PG_HOST: kong-db depends_on: - kong-db core-service: build: ./services/core environment: DB_HOST: postgres REDIS_HOST: redis KAFKA_BOOTSTRAP: kafka:9092 deploy: replicas: 3 depends_on: - postgres - redis - kafka postgres: image: postgres:15 environment: POSTGRES_DB: core POSTGRES_USER: app POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7 command: redis-server --appendonly yes kafka: image: bitnami/kafka:3.5 environment: KAFKA_CFG_NODE_ID: 0 KAFKA_CFG_PROCESS_ROLES: controller,broker KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093 KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093 volumes: pgdata: ``` ### File: `services/core/src/index.js` ```javascript const express = require('express'); const { createCircuitBreaker } = require('./resilience/circuit-breaker'); const { trace } = require('@opentelemetry/api'); const app = express(); app.use(express.json()); // Circuit breaker for downstream calls const downstreamBreaker = createCircuitBreaker({ failureThreshold: 5, timeout: 10000, resetTimeout: 30000 }); app.get('/api/v1/orders/:id', async (req, res) => { const span = trace.getTracer('core-service').startSpan('get-order'); try { const order = await downstreamBreaker.execute(async () => { // Fetch order logic return { id: req.params.id, status: 'active' }; }); span.setStatus({ code: 0 }); res.json(order); } catch (error) { span.setStatus({ code: 2, message: error.message }); res.status(503).json({ error: 'Service temporarily unavailable' }); } finally { span.end(); } }); app.listen(3000, () => { console.log('Core service listening on port 3000'); }); ``` ### File: `services/core/src/resilience/circuit-breaker.js` ```javascript class CircuitBreaker { constructor({ failureThreshold = 5, timeout = 10000, resetTimeout = 30000 }) { this.failureThreshold = failureThreshold; this.timeout = timeout; this.resetTimeout = resetTimeout; this.failureCount = 0; this.state = 'CLOSED'; // CLOSED, OPEN, HALF_OPEN this.nextAttempt = Date.now(); } async execute(fn) { if (this.state === 'OPEN') { if (Date.now() > this.nextAttempt) { this.state = 'HALF_OPEN'; } else { throw new Error('Circuit breaker is open'); } } try { const result = await Promise.race([ fn(), new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), this.timeout)) ]); this.onSuccess(); return result; } catch (error) { this.onFailure(); throw error; } } onSuccess() { this.failureCount = 0; this.state = 'CLOSED'; } onFailure() { this.failureCount++; if (this.failureCount >= this.failureThreshold) { this.state = 'OPEN'; this.nextAttempt = Date.now() + this.resetTimeout; } } } function createCircuitBreaker(config) { return new CircuitBreaker(config); } module.exports = { createCircuitBreaker }; ``` ## Commands ### Local Development ```bash # Start infrastructure docker-compose up -d postgres redis kafka # Run core service locally cd services/core npm install npm run dev # Run tests npm test # Build and run with hot reload npm run build && npm run start ``` ### CI Pipeline ```bash # Lint and type check npm run lint npm run typecheck # Run unit tests with coverage npm run test:coverage # Build Docker image docker build -t core-service:${TAG} . # Run integration tests docker-compose -f docker-compose.test.yml up --abort-on-container-exit # Push image to registry docker push core-service:${TAG} ``` ## Quality Assurance Checklist - [ ] All business requirements (BR-1 through BR-3) have traceable architectural provisions - [ ] Non-functional requirements (NFR-1 through NFR-4) addressed with specific design decisions - [ ] Component boundaries justified with bounded context analysis - [ ] Resilience patterns specified for all inter-service communication - [ ] Technology selections include justification and alternative analysis - [ ] Implementation roadmap has clear phases, dependencies, and MVP definition - [ ] Risk analysis covers technical, operational, and organizational risks ## Risk Register | Risk ID | Description | Probability | Impact | Mitigation | |---------|-------------|-------------|--------|------------| | RISK-1 | Team unfamiliarity with event-driven patterns | Medium | Medium | Training sessions; pair programming; pilot implementation | | RISK-2 | Kafka operational complexity | Medium | High | Use managed Kafka service; infrastructure-as-code for config | | RISK-3 | Data migration during service extraction | High | High | Strangler fig pattern; dual-write strategy; rollback plan | | RISK-4 | Performance degradation from circuit breakers | Low | Medium | Tune thresholds; monitor latency metrics; load testing | ## Implementation Roadmap ### Phase 1: Foundation (Weeks 1-4) - [ ] Set up infrastructure (Kubernetes cluster, CI/CD pipeline) - [ ] Implement API Gateway with basic routing and auth - [ ] Deploy core service with CRUD operations - [ ] Set up monitoring (Prometheus, Grafana, Jaeger) ### Phase 2: Resilience (Weeks 5-8) - [ ] Implement circuit breakers on all inter-service calls - [ ] Add retry logic with exponential backoff - [ ] Implement event-driven communication via Kafka - [ ] Set up dead letter queues and alerting ### Phase 3: Scale (Weeks 9-12) - [ ] Implement horizontal auto-scaling - [ ] Add caching layer for read-heavy endpoints - [ ] Implement database read replicas - [ ] Load testing and performance tuning ### Phase 4: Hardening (Weeks 13-16) - [ ] Implement mTLS between services - [ ] Add comprehensive distributed tracing - [ ] Disaster recovery drills - [ ] Security audit and penetration testing

Connectez-vous pour voir le prompt complet

Continuer avec:

En vous connectant, vous acceptez nos Conditions et Confidentialité

Utilisation

Ce prompt est conçu pour être utilisé avec coding. Copiez le contenu ci-dessus et collez-le dans votre outil d’IA préféré.

Pour de meilleurs résultats, personnalisez les espaces réservés (indiqués par des crochets ou des majuscules) selon vos besoins.

Références

Catégories :coding| prompts.chat| system-architect| software-architecture

Discussion