-
Notifications
You must be signed in to change notification settings - Fork 1
Architecture.md
Abhi edited this page Oct 20, 2025
·
1 revision
This page highlights the core components of the Banking System and how they collaborate. For detailed diagrams and design rationale, cross-reference the architecture documents in the docs/ directory.
The platform follows a layered architecture centered on the Bank aggregate:
-
Presentation Layer
-
ConsoleUIorchestrates teller interactions and maps console commands to domain actions. -
ApiApplicationadapts the domain model to HTTP, exposing health, metrics, and account operations endpoints.
-
-
Domain Layer
-
Bankcoordinates account lifecycle events, delegates transaction execution, and maintains invariants. - The
Accounthierarchy (Savings, Current, FixedDeposit) encapsulates product-specific rules and balances. -
AccountOperationimplementations represent transactional commands with validation and idempotency safeguards.
-
-
Infrastructure Layer
-
AccountRepositoryabstracts persistence, with JDBC and in-memory implementations selectable at runtime. -
MigrationRunnerexecutes SQL migrations before the application serves traffic. -
CacheProviderimplementations accelerate reads by caching account snapshots and derived balances.
-
A simplified component diagram is available in docs/architecture-system-design.md, while low-level class interactions are documented in docs/architecture-low-level.md.
-
Observability: The observer pattern wires
ConsoleNotifierandTransactionLoggerto account events for operator feedback and auditing. -
Configuration: Environment variables and JVM properties (e.g.,
CACHE_PROVIDER,BANKING_STORAGE_MODE) control repository selection, cache policies, and integration endpoints. - Concurrency: Transaction processing uses a queue-backed executor to serialize account mutations and guarantee consistency.
-
In-Memory Snapshot Repository: Default for local demos; stores serialized aggregates on the filesystem (
BANKING_DATA_PATH). -
JDBC Repository: Targets relational databases such as MySQL. Requires
BANKING_STORAGE_MODE=jdbc,BANKING_JDBC_URL, and credentials. Schema definitions live in docs/database-schema.md.
The CacheProviderFactory chooses between:
-
InMemoryCacheProvider(default): TTL-driven caching with configurable expiration. -
NoOpCacheProvider: Disabled caching for troubleshooting or cold-read environments.
Fine-grained TTLs can be set with CACHE_ACCOUNT_TTL_SECONDS and CACHE_BALANCE_TTL_SECONDS. See src/main/java/banking/cache for implementation details.
-
Repositories: Implement
AccountRepositoryto support new storage backends. -
Cache Providers: Add a new
CacheProviderimplementation and extend the factory for alternative caching layers (e.g., Redis). -
Interfaces: Additional presentation layers can wrap the
Bankaggregate without modifying domain logic.