Appearance
Warrior AI — Platform Architecture
A Firebase-authenticated gateway routes Warrior coaching sessions through 7 specialist Dify agents, backed by a Redis-cached Firebase Bridge and Qdrant vector store. Built for 50 users today, engineered for 10,000 at $3,444/mo.
One coaching session, end to end. Total request lifetime: 3–17 seconds.

Client layer. Warrior-facing interface. Firebase Auth SDK handles token lifecycle. Sends authenticated HTTP requests with Bearer token. Receives SSE stream.
Authentication and routing layer. Validates Firebase JWT, enforces CORS (WARAI-71), applies per-user rate limiting (WARAI-72), and forwards to Dify. Bun runtime handles 10,000+ concurrent HTTP connections natively — not a bottleneck.
Core AI layer. 11 containers: API server, Celery workers, nginx, PostgreSQL, Redis, Qdrant. Routes messages through Coordinator → 7 Specialist Agents. Celery workers are the primary scaling bottleneck — each LLM call occupies one worker for 2–15 seconds.
Firestore access layer. Exposes REST endpoints for reading/writing Warrior data. Redis-cached context snapshots (6 parallel reads, 80%+ hit rate, 5ms cache / 200ms cold). Zod schema validation on all writes. Not a bottleneck.
Persistent data layer. Stores Power Stacks, Door Cards, Bible Stacks, Core4 scores, and Warrior context. Google-managed infrastructure, auto-scales. At 10,000 users: ~$220/mo read cost. Not a bottleneck.
The Coordinator routes each Warrior message to the right specialist. 80% routing accuracy target (≥8/10 messages). LLM providers distributed across OpenRouter to manage rate limits.

Routes messages to specialist agents. Orchestrator — not user-facing.
Gemini 2.0 FlashBody domain. Core4 performance, physical training, energy management.
DeepSeek ChatBeing domain. Mental models, clarity, identity mapping.
Claude 3.5 SonnetBeing domain. Faith integration, spiritual clarity, scriptural application.
Claude 3.5 SonnetBalance domain. Relationship frameworks, partnership, family leadership.
DeepSeek ChatBusiness domain. Decision-making, business vision, production breakthroughs.
Gemini 2.0 FlashRecognizes drift patterns. Redirects Warriors back to core commitments.
DeepSeek ChatFallback for unclassified messages. Maintains conversation continuity.
Claude 3.5 Sonnet| Item | Status | Notes |
|---|---|---|
| Firebase JWT validation | ✓ Live | firebase-auth.ts — token verified, uid extracted, token discarded |
| CORS origin restriction | ✓ Fixed (WARAI-71) | ALLOWED_ORIGIN env var — must be set in staging/production |
| Per-user rate limiting (Gateway) | ✓ Fixed (WARAI-72) | 20 req/min, configurable, Retry-After header on 429 |
| Bridge localhost-only binding | ✓ By design | Port 4000 bound to 127.0.0.1 — unreachable from internet |
| Zod validation on Bridge writes | ✓ Live | Field types, 5,000 char max, allowed enums |
| AI audit trail | ✓ Live | digital_trainer_stack: true on every AI write |
| nginx reverse proxy (WARAI-69) | 📋 Pending | Gateway must bind 127.0.0.1 + nginx in front |
| Bridge write rate limit (ADR-W021) | 📋 Pending | Redis INCR pattern, to implement before beta |
| HMAC-signed user_id (ADR-W026) | 📋 Proposed | Restores cryptographic trust through Gateway→Dify→Bridge chain |
| Docker network segmentation (ADR-W027) | 📋 Proposed | 5 named trust tiers — replaces flat network |
The primary bottleneck is Dify's Celery worker pool — each LLM call occupies a worker for 2–15 seconds. Every scaling stage targets this bottleneck.
| Component | Monthly Cost |
|---|---|
| Dify cluster (5 × $180) | $900 |
| Gateway / Bridge servers (2 × $72) | $144 |
| Redis cluster | $150 |
| PostgreSQL (managed) | $200 |
| LLM providers (OpenRouter) | ~$1,380 |
| Firebase Firestore reads | ~$220 |
| Deepgram STT | ~$400 |
| Load balancer / CDN | $50 |
| Total | ~$3,444/mo |