Sistema completo de gerenciamento de pedidos construído com .NET 8
Arquitetura de microsserviços escalável capaz de processar milhares de pedidos por minuto
# Clone o repositório
git clone <repository-url>
cd OrderManagement
# Sobe tudo de uma vez - bancos, Redis, RabbitMQ e os serviços
docker-compose up -d
# Ou use o script PowerShell (Windows)
.\scripts\run-local.ps1
# Pra parar tudo
docker-compose down
# ou
.\scripts\stop-local.ps1# 1. Suba a infraestrutura primeiro
docker-compose up -d postgres redis rabbitmq
# 2. Rode cada serviço em terminais separados
dotnet run --project src/ApiGateway
dotnet run --project src/OrderService
dotnet run --project src/PaymentService
dotnet run --project src/InventoryService
dotnet run --project src/NotificationService# Build e testes
.\scripts\build.ps1
# Testa se a API tá funcionando
.\scripts\test-api.ps1| Serviço | Endpoint | Descrição |
|---|---|---|
| 🚪 Gateway | http://localhost:5000 |
Ponto de entrada único |
| 📦 Orders | http://localhost:5001 |
Gerenciamento de pedidos |
| 💳 Payments | http://localhost:5002 |
Processamento de pagamentos |
| 📋 Inventory | http://localhost:5003 |
Controle de estoque |
| 📬 Notifications | http://localhost:5004 |
Envio de notificações |
Cada serviço tem sua documentação interativa:
- Gateway: http://localhost:5000/swagger
- Orders: http://localhost:5001/swagger
- Payments: http://localhost:5002/swagger
- Inventory: http://localhost:5003/swagger
- Notifications: http://localhost:5004/swagger
- RabbitMQ Management: http://localhost:15672 (dev/dev123)
- Health Checks: Disponível em
/healthem cada serviço
graph TB
subgraph "Frontend"
WEB[🌐 Web App]
MOBILE[📱 Mobile App]
end
subgraph "API Gateway"
GATEWAY[🚪 YARP Gateway<br/>Rate Limiting<br/>Load Balancing]
end
subgraph "Microsserviços"
ORDER[📦 Order Service<br/>CRUD Pedidos<br/>Workflow Status]
PAYMENT[💳 Payment Service<br/>Processamento<br/>Stripe Mock]
INVENTORY[📋 Inventory Service<br/>Controle Estoque<br/>Reservas]
NOTIFICATION[📬 Notification Service<br/>Email & SMS<br/>SendGrid Mock]
end
subgraph "Infraestrutura"
POSTGRES[(🐘 PostgreSQL<br/>Database per Service)]
REDIS[(⚡ Redis<br/>Cache Distribuído)]
RABBIT[🐰 RabbitMQ<br/>Message Broker]
end
WEB --> GATEWAY
MOBILE --> GATEWAY
GATEWAY --> ORDER
GATEWAY --> PAYMENT
GATEWAY --> INVENTORY
GATEWAY --> NOTIFICATION
ORDER --> POSTGRES
PAYMENT --> POSTGRES
INVENTORY --> POSTGRES
ORDER --> REDIS
PAYMENT --> REDIS
INVENTORY --> REDIS
ORDER --> RABBIT
PAYMENT --> RABBIT
INVENTORY --> RABBIT
NOTIFICATION --> RABBIT
style GATEWAY fill:#00D4FF,stroke:#0099CC,color:#fff
style ORDER fill:#4CAF50,stroke:#45a049,color:#fff
style PAYMENT fill:#FF9800,stroke:#F57C00,color:#fff
style INVENTORY fill:#9C27B0,stroke:#7B1FA2,color:#fff
style NOTIFICATION fill:#F44336,stroke:#D32F2F,color:#fff
sequenceDiagram
participant C as 👤 Cliente
participant G as 🚪 Gateway
participant O as 📦 Order Service
participant I as 📋 Inventory
participant P as 💳 Payment
participant N as 📬 Notification
C->>G: 1. Criar Pedido
G->>O: Validar & Criar
O->>I: Reservar Estoque
I-->>O: ✅ Estoque OK
O->>N: Pedido Criado
N->>C: 📧 Email Confirmação
O->>P: Processar Pagamento
P-->>O: ✅ Pagamento OK
O->>O: Status → Pago
O->>N: Pagamento Confirmado
N->>C: 📧 Pagamento Aprovado
O->>O: Status → Enviado
O->>N: Pedido Enviado
N->>C: 📱 SMS Rastreamento
O->>O: Status → Entregue
O->>N: Pedido Entregue
N->>C: 📧 Avaliação
# Roda todos os testes
dotnet test
# Com coverage
dotnet test --collect:"XPlat Code Coverage"
# Só os testes de unidade
dotnet test --filter Category=Unit
# Testa a API funcionando
.\scripts\test-api.ps1- 📖 Exemplos de API - Como usar todos os endpoints
- 🔧 Swagger UI - Documentação interativa em cada serviço
- 📊 Postman Collection - Coleção completa para testes
| Categoria | Tecnologias |
|---|---|
| Backend | |
| Database | |
| Messaging | |
| Container | |
| Testing | |
| Patterns | CQRS, DDD, Repository, Event Sourcing |
| Feature | Descrição | Status |
|---|---|---|
| 📦 CRUD Pedidos | Criação, leitura, atualização e exclusão de pedidos | ✅ |
| 🔄 Workflow Status | Transições automáticas de status (Pendente → Pago → Enviado → Entregue) | ✅ |
| ⚡ Cache Distribuído | Redis para consultas rápidas e invalidação inteligente | ✅ |
| 🛡️ Rate Limiting | Proteção contra spam (100 req/min por IP) | ✅ |
| 📊 Logs Estruturados | Serilog com formato JSON para análise | ✅ |
| 🔍 Health Checks | Monitoramento de saúde de todos os serviços | ✅ |
| 📧 Notificações | Email e SMS automáticos para eventos do pedido | ✅ |
| 💳 Pagamentos | Integração mock com gateways (Stripe ready) | ✅ |
| 📋 Controle Estoque | Reserva e liberação automática de produtos | ✅ |
| 🧪 Testes | Cobertura de testes unitários e integração | ✅ |
graph LR
subgraph "Clean Architecture"
DOMAIN[🎯 Domain<br/>Entities<br/>Value Objects<br/>Events]
APP[⚙️ Application<br/>Commands<br/>Queries<br/>Handlers]
INFRA[🔧 Infrastructure<br/>Repositories<br/>EF Core<br/>External APIs]
PRES[🌐 Presentation<br/>Controllers<br/>DTOs<br/>Validators]
end
PRES --> APP
APP --> DOMAIN
INFRA --> DOMAIN
style DOMAIN fill:#4CAF50,stroke:#45a049,color:#fff
style APP fill:#2196F3,stroke:#1976D2,color:#fff
style INFRA fill:#FF9800,stroke:#F57C00,color:#fff
style PRES fill:#9C27B0,stroke:#7B1FA2,color:#fff
- 🎯 CQRS - Separação de comandos e consultas com MediatR
- 📦 Repository - Abstração da camada de dados
- 🏭 Factory - Criação controlada de entidades
- 📢 Domain Events - Comunicação entre agregados
- 🔄 Event Sourcing - Histórico imutável de mudanças
- 🛡️ Result Pattern - Tratamento de erros sem exceptions
| Fase | Feature | Prioridade |
|---|---|---|
| 🎯 Fase 1 | Autenticação JWT & Autorização | 🔴 Alta |
| 🎯 Fase 2 | Tracing Distribuído (Jaeger) | 🟡 Média |
| 🎯 Fase 3 | GraphQL Gateway (HotChocolate) | 🟡 Média |
| 🎯 Fase 4 | Kubernetes Deployment | 🟢 Baixa |
| 🎯 Fase 5 | Métricas Prometheus/Grafana | 🟢 Baixa |
- Fork o projeto
- Clone seu fork:
git clone <your-fork-url> - Crie uma branch:
git checkout -b feature/nova-feature - Commit suas mudanças:
git commit -m 'Add: nova feature' - Push para a branch:
git push origin feature/nova-feature - Abra um Pull Request
- Código segue os padrões do projeto
- Testes unitários adicionados/atualizados
- Documentação atualizada
- Build passa sem erros
- Cobertura de testes mantida
Este projeto está sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.