0
0
Microservicessystem_design~25 mins

Architecture decision records (ADR) in Microservices - System Design Exercise

Choose your learning style9 modes available
Design: Architecture Decision Records (ADR) System
In scope: ADR creation, storage, versioning, search, collaboration, and API access. Out of scope: Automated ADR generation or integration with CI/CD pipelines.
Functional Requirements
FR1: Allow teams to create, update, and view architecture decision records.
FR2: Support linking ADRs to specific microservices or projects.
FR3: Enable search and filtering of ADRs by date, status, or tags.
FR4: Provide version history for each ADR to track changes over time.
FR5: Allow collaboration with comments and approvals on ADRs.
FR6: Ensure ADRs are accessible via a web interface and API.
Non-Functional Requirements
NFR1: Handle up to 500 concurrent users editing or viewing ADRs.
NFR2: API response time p99 under 150ms.
NFR3: System availability of 99.9% uptime.
NFR4: Store up to 10,000 ADRs with version history.
NFR5: Secure access with authentication and role-based authorization.
Think Before You Design
Questions to Ask
❓ Question 1
❓ Question 2
❓ Question 3
❓ Question 4
❓ Question 5
Key Components
Web frontend for ADR management and collaboration
Backend API service for CRUD operations and business logic
Database for storing ADR content, metadata, and versions
Authentication and authorization service
Search engine or indexing service for fast filtering
Notification or collaboration service for comments and approvals
Design Patterns
Event sourcing or versioning pattern for ADR history
CQRS (Command Query Responsibility Segregation) for separating reads and writes
Microservice architecture for modular ADR management
Role-based access control (RBAC) for security
API gateway for routing and security
Reference Architecture
  +----------------+       +----------------+       +----------------+
  |  Web Frontend  | <---> |  API Gateway   | <---> | Auth Service   |
  +----------------+       +----------------+       +----------------+
          |                         |
          v                         v
  +----------------+       +----------------+       +----------------+
  | ADR Service    |       | Search Service |       | Notification   |
  | (CRUD + Logic) |       | (Elasticsearch)|       | Service       |
  +----------------+       +----------------+       +----------------+
          |
          v
  +----------------+
  | Database       |
  | (PostgreSQL)   |
  +----------------+
Components
Web Frontend
React or Angular
User interface for creating, viewing, editing, and collaborating on ADRs.
API Gateway
Kong or NGINX
Routes requests, handles authentication, and enforces security policies.
Auth Service
OAuth 2.0 / OpenID Connect
Manages user authentication and role-based authorization.
ADR Service
Node.js/Express or Spring Boot
Handles business logic, ADR CRUD operations, versioning, and linking to projects.
Search Service
Elasticsearch
Indexes ADR metadata and content for fast search and filtering.
Notification Service
RabbitMQ or Kafka
Manages comments, approvals, and collaboration notifications.
Database
PostgreSQL
Stores ADR content, metadata, version history, and user data.
Request Flow
1. User logs in via Web Frontend, which authenticates through Auth Service via API Gateway.
2. User requests to create or update an ADR; request goes through API Gateway to ADR Service.
3. ADR Service validates request, stores ADR and version info in Database.
4. ADR Service sends update events to Notification Service for collaboration updates.
5. Search Service indexes new or updated ADR metadata asynchronously.
6. User queries ADRs via Web Frontend; API Gateway routes search requests to Search Service.
7. Search Service returns filtered ADR list; Web Frontend displays results.
Database Schema
Entities: - ADR: id (PK), title, status, created_at, updated_at, project_id, current_version_id - ADRVersion: id (PK), adr_id (FK), content, version_number, created_at, author_id - Project: id (PK), name, description - User: id (PK), username, email, role - Comment: id (PK), adr_id (FK), user_id (FK), content, created_at Relationships: - One Project has many ADRs - One ADR has many ADRVersions - One ADR has many Comments - One User can author many ADRVersions and Comments
Scaling Discussion
Bottlenecks
Database write contention when many users update ADRs simultaneously.
Search Service latency with growing ADR volume and complex queries.
Notification Service overload with high collaboration activity.
API Gateway becoming a single point of failure or bottleneck.
Solutions
Use database sharding or partitioning by project to distribute load.
Implement caching for frequent ADR reads and optimize Elasticsearch indexing.
Scale Notification Service horizontally and use message queues for load leveling.
Deploy multiple API Gateway instances with load balancing and failover.
Interview Tips
Time: Spend 10 minutes understanding requirements and clarifying scope, 20 minutes designing components and data flow, 10 minutes discussing scaling and trade-offs, 5 minutes summarizing.
Explain importance of versioning ADRs for traceability.
Discuss role-based access control for security.
Highlight separation of concerns with microservices.
Describe how search indexing improves user experience.
Address scaling challenges and realistic solutions.