feat: bootstrap b2bcall saas architecture
- monorepo skeleton (apps/, packages/, infrastructure/, scripts/, docs/) - docker-compose with PostgreSQL 18 and Redis 7 (localhost-only) - .gitignore and .env.example - initial TODO.md and docs/ARCHITECTURE.md
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
FREESWITCH_PAT=
|
||||||
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Secrets — never commit
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
FIRST_LOGIN.txt
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
|
# Build output
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
.next/
|
||||||
|
.turbo/
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Docker volumes / data
|
||||||
|
infrastructure/**/data/
|
||||||
37
TODO.md
Normal file
37
TODO.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# TODO — B2BCall
|
||||||
|
|
||||||
|
## PHASE 01 — Infrastructure
|
||||||
|
- [x] Diagnóstico do servidor (Debian 13, 2 vCPU, ~1.9GB RAM, 26GB disco livre)
|
||||||
|
- [x] Docker + Docker Compose instalados
|
||||||
|
- [x] Estrutura de monorepo criada (apps/, packages/, infrastructure/, scripts/, docs/)
|
||||||
|
- [x] PostgreSQL 18 (docker-compose, porta 127.0.0.1:5432)
|
||||||
|
- [x] Redis 7 (docker-compose, porta 127.0.0.1:6379)
|
||||||
|
- [x] Secrets gerados em `.env` (POSTGRES_PASSWORD, REDIS_PASSWORD, JWT_SECRET, JWT_REFRESH_SECRET, ENCRYPTION_KEY, ESL_PASSWORD)
|
||||||
|
- [x] `FREESWITCH_PAT` configurado em `.env` (não commitado)
|
||||||
|
- [ ] FreeSWITCH (build/imagem própria, ver risco de RAM abaixo)
|
||||||
|
- [ ] nginx (reverse proxy)
|
||||||
|
|
||||||
|
## PHASE 02 — SaaS Core
|
||||||
|
- [ ] Monorepo Node.js/TypeScript (workspaces, tsconfig base)
|
||||||
|
- [ ] `packages/database` (schema, migrations)
|
||||||
|
- [ ] `packages/types`, `packages/shared`
|
||||||
|
|
||||||
|
## PHASE 03 — Tenant Isolation
|
||||||
|
- [ ] Tabela `tenants` + RLS
|
||||||
|
- [ ] Tenant context em transação PostgreSQL
|
||||||
|
|
||||||
|
## PHASE 04 — Authentication / RBAC
|
||||||
|
- [ ] Login (Argon2id), access/refresh tokens
|
||||||
|
- [ ] roles/permissions/user_roles/role_permissions
|
||||||
|
|
||||||
|
## PHASE 05+ — ver `agente.md` seções 15 em diante (FreeSWITCH, Telefonia, Call Center,
|
||||||
|
Predictive Dialer, Recordings, AI, Billing, Frontend, Reports, Security, Tests)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Riscos conhecidos
|
||||||
|
- **RAM da VM (1.9GB total)**: insuficiente para rodar toda a stack (Postgres + Redis +
|
||||||
|
FreeSWITCH + múltiplos workers Node + Next.js) simultaneamente sem swap/OOM. Avaliar
|
||||||
|
upgrade de RAM antes de subir FreeSWITCH + frontend + workers juntos.
|
||||||
|
- **Disco (26GB livre)**: build do FreeSWITCH + imagens Docker + gravações vão consumir
|
||||||
|
espaço rápido. Monitorar com `df -h`.
|
||||||
BIN
apps/frontend/public/branding/b2blogo.png
Normal file
BIN
apps/frontend/public/branding/b2blogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 KiB |
BIN
b2bcall.png
Normal file
BIN
b2bcall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 KiB |
37
docker-compose.yml
Normal file
37
docker-compose.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:18-alpine
|
||||||
|
container_name: b2bcall-postgres
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:5432:5432"
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
container_name: b2bcall-redis
|
||||||
|
restart: unless-stopped
|
||||||
|
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:6379:6379"
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "redis-cli -a ${REDIS_PASSWORD} ping | grep -q PONG"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
redis_data:
|
||||||
51
docs/ARCHITECTURE.md
Normal file
51
docs/ARCHITECTURE.md
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Arquitetura — B2BCall
|
||||||
|
|
||||||
|
SaaS multi-tenant de call center, discagem preditiva, telefonia, IA e billing.
|
||||||
|
Ver `agente.md` na raiz do projeto para a especificação completa.
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
- **Backend**: Node.js, TypeScript, NestJS, Fastify
|
||||||
|
- **Frontend**: Next.js, React, TypeScript, Tailwind CSS, shadcn/ui
|
||||||
|
- **Banco**: PostgreSQL (18)
|
||||||
|
- **Cache/Jobs**: Redis + BullMQ
|
||||||
|
- **Telefonia**: FreeSWITCH
|
||||||
|
- **Reverse Proxy**: nginx
|
||||||
|
|
||||||
|
## Monorepo
|
||||||
|
|
||||||
|
```
|
||||||
|
apps/
|
||||||
|
frontend/ Next.js
|
||||||
|
api/ API principal (NestJS)
|
||||||
|
dialer-worker/ Predictive Dialer Engine
|
||||||
|
freeswitch-events/ Consumidor ESL (mod_event_socket)
|
||||||
|
freeswitch-config/ Provedor XML Curl (Directory/Dialplan)
|
||||||
|
scheduler/ Jobs agendados (callbacks, retenção, fechamento)
|
||||||
|
ai-worker/ Pipeline de transcrição/análise IA
|
||||||
|
billing-worker/ Rating Engine / fechamento mensal
|
||||||
|
|
||||||
|
packages/
|
||||||
|
database/ auth/ billing/ ai/ telephony/ shared/ types/ ui/
|
||||||
|
|
||||||
|
infrastructure/
|
||||||
|
docker/ freeswitch/ postgres/ redis/ nginx/
|
||||||
|
|
||||||
|
scripts/
|
||||||
|
docs/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Servidor atual (ambiente de desenvolvimento)
|
||||||
|
|
||||||
|
- Debian 13 (trixie), kernel 6.12
|
||||||
|
- 2 vCPU, ~1.9GB RAM, ~26GB disco livre
|
||||||
|
- Hostname: `Lab-FSCore-RTPEngine` — sugere ambiente de laboratório, não produção
|
||||||
|
|
||||||
|
**Atenção**: a RAM disponível é baixa para rodar a stack completa (Postgres + Redis +
|
||||||
|
FreeSWITCH + workers Node + Next.js) ao mesmo tempo. Ver `TODO.md` para riscos e
|
||||||
|
recomendações antes de escalar para todos os serviços simultaneamente.
|
||||||
|
|
||||||
|
## Rede
|
||||||
|
|
||||||
|
Serviços de infraestrutura (Postgres, Redis) expostos apenas em `127.0.0.1`, nunca
|
||||||
|
publicamente, conforme seção 184 de `agente.md`.
|
||||||
Reference in New Issue
Block a user