How vicenzomartinelli/act-caixa-desafio works
Project type and purpose
• This is a microservices-based financial application (“Act.Caixa”) that handles “Lançamentos” (transactions) and “Consolidações” (daily consolidations).
• It uses an API Gateway to expose endpoints, two independent services for write/read operations, asynchronous event‐driven flows, and a shared domain/library layer.
File structure
• Top-level projects:
• Act.Caixa.BuildingBlocks: reusable infra (EF Core DbContext, migrations, message-bus config, HTTP filters)
• Act.Caixa.Domain: core entities, enums, domain events
• Act.Caixa.Services.Lancamento: transaction microservice
• Act.Caixa.Services.Consolidacao: consolidation microservice
• Act.Caixa.Gateway: Ocelot API Gateway
• Act.Caixa.Tests: integration tests with Testcontainers
• compose.yaml/dockerfiles: Docker-based infra (PostgreSQL, RabbitMQ)
• Patterns & infra:
• EF Core + PostgreSQL
• MassTransit + RabbitMQ for event bus
• MediatR (Mediator) for in-process command/query dispatch
• Ocelot for API routing
Extract README insights
• CQRS: Services separate commands (writes) and queries (reads) within each service.
• Event-driven: services publish/consume domain events via RabbitMQ.
• API Gateway Pattern: single ingress point.
• Feature-focused structure per service (Commands, Queries, Consumers, ViewModels).
• Docker-compose spins up infra; each service publishes its own Dockerfile.
a. Main components:
• Clients (e.g., browser, mobile, other services)
• API Gateway (Act.Caixa.Gateway)
• Service: Lancamento
• Service: Consolidacao
• Shared Library (BuildingBlocks + Domain) – code dependency, not a runtime component
• PostgreSQL database
• RabbitMQ message broker
• (Optional) In-memory cache inside services
b. Relationships / interactions:
1. Client → HTTP calls → API Gateway
2. Gateway → routes → Lancamento or Consolidacao HTTP endpoints
3. Service receives HTTP → dispatches via MediatR → EF Core writes to PostgreSQL
4. On write commands, service publishes an event to RabbitMQ (e.g., “LancamentoAdded”)
5. Consolidacao service has a MassTransit consumer listening to corresponding queue
6. Consolidacao consumer handles event → updates daily consolidations in its own database schema/table
c. Architectural patterns/design principles:
• API Gateway sits at the front (Ocelot)
• Microservices each own their data (Database per service)
• CQRS inside each service
• Event-driven communication via RabbitMQ + MassTransit
• Mediator (MediatR) for in-proc decoupling
• Shared Building Blocks library for common infra (DbContextFactory, message-bus setup, validation filters)
d. Technologies/frameworks:
• .NET 9.0, C#
• Ocelot (API Gateway)
• MassTransit + RabbitMQ
• Entity Framework Core + PostgreSQL
• MediatR
• Docker / Docker-Compose
Elements
• Another for “Messaging infrastructure”
• Another for “Persistence”
• Ports, queue names, topic/exchange names.