Setup do Ambiente¶
Pré-requisitos¶
- .NET 8 SDK
- Docker Desktop
- Node.js (opcional, para ferramentas de dev)
Setup Rápido¶
1. Subir infraestrutura¶
Isso inicia: - PostgreSQL 17 + pgvector na porta 5432 (com extensão vector para busca semântica) - Redis 7 na porta 6379 - Evolution API v2.3.7 na porta 8081
2. Aplicar migrations¶
3. Executar seed (opcional)¶
4. Rodar a aplicação¶
Em terminais separados:
# Backend (porta 5000)
dotnet run --project src/Ciba.Api
# Frontend (porta 5001)
dotnet run --project src/Ciba.Web
Ou use dotnet watch para hot reload:
Configuração¶
appsettings.Development.json (Api)¶
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=ciba;Username=ciba;Password=ciba123",
"Redis": "localhost:6379"
},
"Jwt": {
"SecretKey": "sua-chave-secreta-com-pelo-menos-32-caracteres",
"Issuer": "ciba-api",
"Audience": "ciba-web",
"ExpirationMinutes": 60
},
"Llm": {
"AnthropicApiKey": "sk-ant-...",
"OpenAiApiKey": "sk-..."
},
"Evolution": {
"BaseUrl": "http://localhost:8081",
"ApiKey": "evolution-api-key-dev",
"TimeoutSeconds": 10
},
"R2": {
"AccessKey": "...",
"SecretKey": "...",
"BucketName": "ciba-dev",
"Endpoint": "https://....r2.cloudflarestorage.com",
"PublicUrl": "https://cdn.exemplo.com"
}
}
wwwroot/appsettings.json (Web)¶
Credenciais de Desenvolvimento¶
| Serviço | Usuário | Senha |
|---|---|---|
| PostgreSQL | ciba | ciba123 |
| Evolution API | - | evolution-api-key-dev |
Comandos Úteis¶
Migrations¶
# Criar nova migration
dotnet ef migrations add NomeDaMigration --project src/Ciba.Infrastructure --startup-project src/Ciba.Api
# Aplicar migrations
dotnet ef database update --project src/Ciba.Infrastructure --startup-project src/Ciba.Api
# Reverter última migration
dotnet ef database update PreviousMigrationName --project src/Ciba.Infrastructure --startup-project src/Ciba.Api
# Gerar script SQL
dotnet ef migrations script --project src/Ciba.Infrastructure --startup-project src/Ciba.Api
Docker¶
# Ver logs
docker logs ciba-postgres
docker logs ciba-redis
docker logs ciba-evolution
# Acessar PostgreSQL
docker exec -it ciba-postgres psql -U ciba -d ciba
# Acessar Redis
docker exec -it ciba-redis redis-cli
# Parar tudo
docker-compose -f docker-compose.dev.yaml down
# Parar e remover volumes
docker-compose -f docker-compose.dev.yaml down -v
Build¶
Estrutura de Portas¶
| Serviço | Porta |
|---|---|
| CIBA API | 5000 |
| CIBA Web | 5001 |
| PostgreSQL | 5432 |
| Redis | 6379 |
| Evolution API | 8081 |
Troubleshooting¶
Evolution API não recebe webhooks¶
- Verifique se a API está rodando na porta 5000
- Confirme que
host.docker.internalresolve para o host: - Verifique os logs do Evolution:
Erro de conexão com PostgreSQL¶
- Verifique se o container está rodando:
- Teste a conexão:
Erro de conexão com Redis¶
- Verifique se o container está rodando:
- Teste a conexão:
Hot reload não funciona¶
Use dotnet watch com a flag de rebuild:
Blazor WASM lento no debug¶
Isso é normal em debug. Para performance real, use Release: