How crystal-bank/crystalbank works
Main Components Identification
a. Core Domains:
• Accounts Domain
• Customers Domain
• Users Domain
• API Keys Domain
• Transactions Domain (with sub-domains)
b. Infrastructure Components:
• PostgreSQL EventStore
• API Server
• Authentication Layer
• Event Bus
• Projections System
Architectural Patterns to Highlight
The system implements several important patterns that should be represented:
a. CQRS (Command Query Responsibility Segregation):
• Commands (write operations)
• Queries (read operations)
• Event Sourcing
• Projections
b. REST API Architecture:
• OpenAPI/Swagger Integration
• JWT Authentication
• API Key Management
┌─ Client Layer ─────────────────────────────┐
• REST API Clients │
• ┘
• ↕ HTTP/REST
┌─ API Layer ──────────────────────────────────┐
• Authentication | Authorization | API Gateway │
• ┘
• ↕
┌─ Domain Layer ────────────────────────────────────────────────┐
• ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌────────────────────┐ │
• Accounts │ │Customers │ │Users │ │Transactions │ │
• Commands │ │Commands │ │Commands │ │┌─────────────────┐ │ │
• Events │ │Events │ │Events │ ││Internal Transfer│ │ │
• Queries │ │Queries │ │Queries │ ││Postings │ │ │
• ┘ └──────────┘ └─────────┘ └─────────────────┘ │ │
• ┘ │
• ┘
• ↕
┌─ Infrastructure Layer ──────────────────────────────────────┐
• EventStore (PostgreSQL) | Event Bus | Projections Store │
• ┘
Important Relationships
• Event flow between domains
• Command/Query separation
• API authentication flow
• Projection updates
• Domain interaction patterns
Additional Details
Annotations for:
• API endpoints (/accounts, /customers, etc.)
• Event types (AccountOpened, TransferInitiated, etc.)
• Authentication flow
• Currency support
• Customer types (business, individual)
Implementation Notes
• Event-driven architecture
• Domain isolation
• Clear boundaries between write and read operations
• Security layers
• Data flow directions
This system design should reflect the event-sourced, domain-driven nature of the application while clearly showing how the different components interact to provide banking functionality.