135 lines
6 KiB
Markdown
135 lines
6 KiB
Markdown
# DIDI Backend Platform
|
||
|
||
Misinformation detection platform — 3-layer microservices architecture (TypeScript/Node.js).
|
||
|
||
> **⚠️ READ FIRST**: [`REFACTOR_CONTEXT.md`](./REFACTOR_CONTEXT.md) — convenții, helpers,
|
||
> structură nouă post-refactor (sesiune 2026-05-07). Conține pattern-urile
|
||
> obligatorii (`log`, `requireEnv`, `internalError`, `lazyRedis`, `acquireLock`,
|
||
> `LogicalInputError`, etc) + anti-pattern-uri de evitat + fișierele mari rămase.
|
||
|
||
## Active Services
|
||
|
||
| Service | Port | Container | Compose file |
|
||
|---------|------|-----------|--------------|
|
||
| Agent V3 | 24803 | didi-agent-v3 | `services/orchestration-layer/agent-v3/docker-compose.yml` |
|
||
| didiFramework | 3005 | didi-framework | `services/orchestration-layer/didiFramework/docker-compose.yml` |
|
||
| Admin Dashboard | 3000 (HTTPS) | didi-admin | `services/data-layer/docker-compose.yml` |
|
||
|
||
Workers (in agent-v3 compose): worker-techniques ×2, worker-ai-tampered ×2, worker-claims ×3, worker-domain ×2, worker-media-preprocess ×2, verdict-aggregator ×2.
|
||
|
||
## Quick Commands
|
||
|
||
```bash
|
||
# Rebuild agent-v3 (+ all workers)
|
||
cd services/orchestration-layer/agent-v3 && docker compose up -d --build agent-v3
|
||
|
||
# Rebuild framework
|
||
cd services/orchestration-layer/didiFramework && docker compose up -d --build didi-framework
|
||
|
||
# Rebuild admin dashboard
|
||
cd admin-dashboard && docker build -t didi-admin:latest .
|
||
cd ../services/data-layer && docker compose up -d --force-recreate didi-admin
|
||
|
||
# Sync parameters to Redis
|
||
docker exec didi-framework sh -c 'wget -qO- --post-data="" http://127.0.0.1:3005/api/sync-redis'
|
||
|
||
# View logs
|
||
docker logs -f didi-agent-v3
|
||
docker logs -f didi-framework
|
||
```
|
||
|
||
## Structure
|
||
|
||
```
|
||
backend/
|
||
├── admin-dashboard/ # React 19, MUI 7, TypeScript
|
||
│ ├── src/components/ # ServiceCard, AnalysisHistory, UserManagement, etc.
|
||
│ ├── src/services/api.ts # API client (health checks via Docker container state)
|
||
│ ├── nginx-ssl.conf # Nginx proxy (/framework/ → :3005, /agent-v3/ → :24803)
|
||
│ └── Dockerfile # Multi-stage: node:20 build → nginx:alpine serve
|
||
├── production/ # Production docker-compose + .env
|
||
└── services/
|
||
├── data-layer/
|
||
│ ├── didiCache/ # Redis 7 config
|
||
│ ├── didiDatabase/ # Local PG (waitlist only, main DB is external cluster)
|
||
│ ├── didiQueue/ # RabbitMQ init scripts
|
||
│ ├── didiStorage/ # MinIO init + lifecycle
|
||
│ ├── pgadmin/
|
||
│ └── docker-compose.yml # All data layer + admin dashboard containers
|
||
├── gateway-auth-layer/
|
||
│ ├── didiKeycloak/ # Realm import + 3 custom themes
|
||
│ └── didiKong/ # Declarative config + SSL certs
|
||
└── orchestration-layer/
|
||
├── agent-v3/ # Analysis engine (Express 5, TypeScript)
|
||
│ ├── src/api/ # routes.ts, ai-tampered-routes.ts, claims-routes.ts, pipeline-routes.ts
|
||
│ ├── src/components/ # techniques/, ai-tampered/, claims/, pipeline/ executors
|
||
│ ├── src/shared/ # media/, persistence/, redis/, types/
|
||
│ ├── src/queue/ # dispatcher.ts, connection.ts, aggregator.ts, workers/
|
||
│ └── docker-compose.yml # agent-v3 + 13 worker containers
|
||
└── didiFramework/ # Parameters CRUD API (Express 4, TypeScript)
|
||
├── src/routes/ # 20+ route files (CRUD for all parameters)
|
||
├── sql/migrations/ # PG migrations
|
||
└── docker-compose.yml
|
||
```
|
||
|
||
## Databases
|
||
|
||
| Database | Host | Schema | Used by |
|
||
|----------|------|--------|---------|
|
||
| DIDI (PG cluster) | 10.11.50.167:5000 | bos_parammgmt | didiFramework (parameters CRUD) |
|
||
| | | bos_analysis | agent-v3 (analysis results) |
|
||
| | | bos_sysadmin | didiFramework (users, subscriptions) |
|
||
| | | bos_subscriber | didiFramework (personal data) |
|
||
| Redis | didi-cache:6379 | — | Both (framework config cache, session state) |
|
||
| RabbitMQ | rabbitmq:5672 | — | agent-v3 (async analysis queues) |
|
||
| MinIO | minio:9000 | — | Both (media file storage) |
|
||
|
||
## API Routes (Agent V3, all async)
|
||
|
||
All `/analyze` and `/analyze-media` endpoints dispatch to RabbitMQ workers and return 202.
|
||
|
||
| Prefix | File | What |
|
||
|--------|------|------|
|
||
| `/api/v3/techniques/*` | routes.ts | Manipulation technique detection |
|
||
| `/api/v3/ai-tampered/*` | ai-tampered-routes.ts | AI content detection |
|
||
| `/api/v3/claims/*` | claims-routes.ts | Claim extraction + verification |
|
||
| `/api/v3/pipeline/*` | pipeline-routes.ts | Full pipeline, history, extension |
|
||
| `/api/v3/source-assessment/*` | source-assessment-routes.ts | Source credibility |
|
||
| `/api/v3/domain/*` | routes.ts | Domain analysis |
|
||
| `/api/v3/media/*` | routes.ts | File upload/download (MinIO) |
|
||
|
||
## LLM Models
|
||
|
||
| Role | Model | Location |
|
||
|------|-------|----------|
|
||
| Primary (all) | Qwen 3.5 397B | Local GPU 10.11.10.17:14011 |
|
||
| Fallback 1 | Claude Sonnet 4.6 (Opus 4.6 for ai-tampered) | OpenRouter |
|
||
| Fallback 2 | GPT-4o | OpenRouter |
|
||
| Vision | Qwen Vision → Gemini Flash → GPT-4o | 10.11.10.42:14001 + OpenRouter |
|
||
| Transcription | M17-Whisper → Groq → OpenAI | 10.11.10.17:54300 + Cloud |
|
||
|
||
Managed via `component_stage_assignment` PG table → sync to Redis.
|
||
|
||
## Tech Stack
|
||
|
||
| Component | Technology |
|
||
|-----------|------------|
|
||
| Agent V3 | Node.js, TypeScript, Express 5 |
|
||
| didiFramework | Node.js, TypeScript, Express 4 |
|
||
| Admin Dashboard | React 19, MUI 7, TypeScript |
|
||
| Database | PostgreSQL 14 (Patroni/HAProxy) |
|
||
| Cache | Redis 7 |
|
||
| Queue | RabbitMQ 3.12 |
|
||
| Storage | MinIO |
|
||
| Gateway | Kong 3.4 (SSL :443) |
|
||
| Auth | Keycloak 22 |
|
||
|
||
## Credentials (Staging)
|
||
|
||
| Service | User | Password |
|
||
|---------|------|----------|
|
||
| PostgreSQL (cluster) | bos_interface | interface |
|
||
| Redis | — | redis123 |
|
||
| RabbitMQ | admin | rabbitmq123 |
|
||
| MinIO | minioadmin | minio123 |
|
||
| Keycloak | admin@didi.local | admin123 |
|