Bankflix
An application that simulates a digital bank, featuring customer and administrative areas, and allowing deposits and transfers between accounts within the same bank.
Install / Use
/learn @alexandrebeato/BankflixREADME
Architecture
Overview
Bankflix is a multi-client digital bank platform built as a Clean Architecture Modular Monolith with event-driven async processing. The system is organized into independent bounded contexts (Agencia, Clientes, Movimentacoes) that follow Domain-Driven Design principles, communicate via commands and events, and integrate through a centralized API gateway.
Key Architectural Characteristics:
- Style: Clean Architecture / Layered + Modular Monolith with DDD
- Communication: Synchronous (REST API), Asynchronous (RabbitMQ + Command Queue)
- Pattern: CQRS (Command Query Responsibility Segregation) via MediatR for Clientes & Movimentacoes; Traditional layered approach for Agencia
- Database: NoSQL (MongoDB) for all persistence
- Deployment: Containerized (Docker) with Docker Compose orchestration
Technology Stack
| Component | Technology | Purpose | Evidence |
|-----------|-----------|---------|----------|
| API Server | ASP.NET Core 3.1+ (.NET Framework) | REST API, core orchestration | server/src/Bankflix.API/ |
| Web Client | Angular 8.x, TypeScript, Bootstrap, Material Design | Front-end web application | clients/angular/package.json (Angular 8.1.2) |
| Mobile Client | Flutter (Dart) with MobX state management | Cross-platform mobile app (iOS/Android) | clients/flutter/pubspec.yaml (Flutter SDK >=2.1.0) |
| Database | MongoDB 5.x | Document store for all aggregates | docker-compose.yml (mongo:latest) |
| Message Queue | RabbitMQ 3.x | Async command processing & event sourcing | docker-compose.yml (rabbitmq:3-management) |
| Mediator | MediatR 7.0.0 | Command/Query routing & Event handling | Core.Domain/Core.Domain.csproj |
| ORM/Mapping | MongoDB.Driver 2.9.2, AutoMapper 6.0.0 | Data mapping & object-document mapping | *.csproj dependencies |
| Resilience | Polly 7.1.1 | Retry policies for RabbitMQ connection | Core.Domain/Services/QueueHostedService.cs |
| Validation | FluentValidation | Domain-level & command validation | Core.Domain patterns |
| Authentication | JWT (HS256) | Stateless API authentication | Bankflix.API/Configurations/ConfiguracoesSeguranca.cs |
Components & Responsibilities
| Component | Tech | Responsibility | Evidence |
|-----------|------|-----------------|----------|
| Bankflix.API | ASP.NET Core | HTTP endpoints, request routing, dependency injection bootstrap | server/src/Bankflix.API/Program.cs, Startup.cs |
| Core.Domain | C# | Base abstractions: Commands, Events, Entities, ValueObjects, Repositories, Validators, MediatorHandler, QueueHostedService | server/src/Core.Domain/ |
| Agencia Context | C# + MongoDB | Agency/Branch management (non-CQRS traditional layer approach). Entities: Agencia, Usuario (Admin). Single instance on startup. | server/src/Agencia.Domain/, Agencia.Infra.Data/ |
| Clientes Context | C# + MongoDB + CQRS | Client lifecycle: registration, approval, rejection. Commands: CadastrarCliente, AprovarCliente, RecusarCliente. Events trigger email notifications. | server/src/Clientes.Domain/, Clientes.CommandStack/, Clientes.Commands/ |
| Movimentacoes Context | C# + MongoDB + CQRS + RabbitMQ | Financial transactions: Depositos (Deposits) & Transferencias (Transfers). Async processing: SolicitarDeposito → queue → EfetuarDeposito (30s delay demo). | server/src/Movimentacoes.Domain/, Movimentacoes.CommandStack/, Movimentacoes.Commands/ |
| Angular Client | TypeScript, Angular 8.x | Web UI for client & admin portals. Communicates with API via HTTP/JWT. | clients/angular/src/ |
| Flutter Client | Dart, Flutter | Mobile app (iOS/Android). Uses MobX for state management, Dio for HTTP. | clients/flutter/lib/ |
| RabbitMQ Container | Docker image: rabbitmq:3-management | Message broker. Virtual host: rabbitmq-bankflix. Credentials: guest/guest. | docker-compose.yml |
| MongoDB Container | Docker image: mongo:latest | NoSQL database. All domain aggregates stored as documents. | docker-compose.yml |
Folder Structure & Responsibilities
bankflix/
├── server/
│ ├── src/
│ │ ├── Bankflix.API/
│ │ │ ├── Controllers/ # HTTP endpoints (Agencia, Clientes, Movimentacoes)
│ │ │ ├── Configurations/ # Security (JWT), Queue services, AutoMapper
│ │ │ ├── Models/ # DTOs for API responses
│ │ │ ├── Mapper/ # AutoMapper profiles
│ │ │ ├── Program.cs # Entry point; Agencia initialization
│ │ │ └── Startup.cs # Service registration & middleware config
│ │ │
│ │ ├── Core.Domain/
│ │ │ ├── Commands/ # Base Command abstract class (MediatR IRequest)
│ │ │ ├── Events/ # Base Event abstract class (MediatR INotification)
│ │ │ ├── CommandHandlers/ # MediatorHandler (routes to local or queue)
│ │ │ ├── Models/ # Entity<T> (aggregate root base); ValidationResult
│ │ │ ├── ValueObjects/ # ValueObject<T> base (immutable domain values)
│ │ │ ├── Repository/ # IRepository, IMongoSequenceRepository interfaces
│ │ │ ├── Services/ # QueueHostedService, IQueueableService
│ │ │ ├── Interfaces/ # IMediatorHandler, IUsuario, IEntity
│ │ │ ├── Validations/ # DomainValidator, DomainSpecification
│ │ │ ├── Notifications/ # DomainNotification (aggregates domain errors)
│ │ │ └── Extensions/ # Validation rules, entity extensions
│ │ │
│ │ ├── Agencia.Domain/
│ │ │ ├── Agencia/ # Agencia entity (aggregate root)
│ │ │ └── Repository/ # IAgenciaRepository interface
│ │ │
│ │ ├── Agencia.Infra.CrossCutting/
│ │ │ └── DependencyRegistration/ # BootstrapperAgencia (registers Agencia services)
│ │ │
│ │ ├── Agencia.Infra.Data.Mongo/
│ │ │ └── Repository/ # AgenciaRepository (MongoDB persistence)
│ │ │
│ │ ├── Clientes.Domain/
│ │ │ ├── Clientes/ # Cliente entity (aggregate root) + validations
│ │ │ ├── Contas/ # Conta (Account) entity + specifications
│ │ │ └── Repository/ # Interfaces: IClienteRepository, IContaRepository
│ │ │
│ │ ├── Clientes.Commands/
│ │ │ ├── Clientes/ # CadastrarClienteCommand, AprovarClienteCommand, RecusarClienteCommand
│ │ │ └── Contas/ # CriarContaCommand, AdicionarValorSaldoContaCommand, RemoverValorSaldoContaCommand
│ │ │
│ │ ├── Clientes.CommandStack/
│ │ │ ├── Clientes/
│ │ │ │ ├── Events/ # ClienteCadastradoEvent, ClienteAprovadoEvent, ClienteRecusadoEvent
│ │ │ │ └── Handlers/ # ClienteCommandHandler, ClienteEventHandler
│ │ │ └── Contas/
│ │ │ └── Handlers/ # ContaCommandHandler
│ │ │
│ │ ├── Clientes.Infra.CrossCutting/
│ │ │ └── DependencyRegistration/ # BootstrapperClientes (registers handlers, repositories)
│ │ │
│ │ ├── Clientes.Infra.Data.Mongo/
│ │ │ └── Repository/ # ClienteRepository, ContaRepository (MongoDB)
│ │ │
│ │ ├── Movimentacoes.Domain/
│ │ │ ├── Depositos/ # Deposito entity (aggregate root)
│ │ │ ├── Transferencias/ # Transferencia entity (aggregate root)
│ │ │ ├── Movimentacoes/ # Movimentacao (Transaction record) entity
│ │ │ ├── Clientes/ & Contas/ # Value Objects referencing other contexts
│ │ │ └── Repository/ # Interfaces: IDepositoRepository, ITransferenciaRepository, IMovimentacaoRepository
│ │ │
│ │ ├── Movimentacoes.Commands/
│ │ │ ├── Depositos/ # SolicitarDepositoCommand, EfetuarDepositoCommand
│ │ │ ├── Transferencias/ # SolicitarTransferenciaCommand, EfetuarTransferenciaCommand
│ │ │ └── Movimentacoes/ # RegistrarMovimentacaoCommand
│ │ │
│ │ ├── Movimentacoes.CommandStack/
│ │ │ ├── Depositos/
│ │ │ │ ├── Events/ # DepositoSolicitadoEvent
│ │ │ │ └── Handlers/ # DepositoCommandHandler, DepositoEventHandler
│ │ │ ├── Transferencias/
│ │ │ │ ├── Events/ # TransferenciaSolicitadaEvent
│ │ │ │ └── Handlers/ # TransferenciaCommandHandler, TransferenciaEventHandler
│ │ │ └── Movimentacoes/
│ │ │ └── Handlers/ # MovimentacaoCommandHandler
│ │ │
│ │ ├── Movimentacoes.Infra.CrossCutting/
│ │ │ └── DependencyRegistration/ # BootstrapperMovimentacoes (registers handlers, defines queueable commands)
│ │ │
│ │ └── Movimentacoes.Infra.Data.Mongo/
│ │ └── Repository/ # DepositoRepository, TransferenciaRepository, MovimentacaoRepository (MongoDB)
│ │
│ ├── Bankflix.Core.sln # Visual Studio solution file
│ ├── global.json # .NET SDK version specification
│ └── Dockerfile # ASP.NET Core runtime image
│
├── clients/
│ ├── angular/
│ │ ├── src/
│ │ │ ├── app/ # Angular components, services, guards, interceptors
│ │ │ ├── assets/ # Static images, styles
│ │ │ ├── environments/ # API endpoint configuration (dev/prod)
│ │ │ ├── index.html # Entry HTML
│ │ │ └── main.ts # Bootstrap Angular app
│ │ ├── angular.json # Angular CLI config
│ │ ├── Dockerfile # Node + Nginx reverse proxy for SPA
│ │ ├── nginx-custom.conf # Nginx routing (rewrites to index.html for SPA)
│ │ ├── p
