Architecture Evolution
Weam AI uses a streamlined architecture with Node.js handling all backend operations through LangGraph for intelligent AI orchestration.Node.js Backend Architecture
Core Application Stack
AI & Vector Layer
Direct API integration for OpenAI, Anthropic, Gemini, and HuggingFace. OpenRouter used for LLaMA, DeepSeek, Grok, and Qwen models.
Security & Configuration
- API key encryption with internal crypto module
- JWT tokens for access and refresh authentication
- Environment-based configuration (
.envfiles) - Role-based access control
Real-time & Storage
- Socket.IO for live updates and streaming responses
- Redis Pub/Sub for socket scaling
- SMTP email integration
- MinIO / AWS S3 file storage with parallel processing
- Event streaming for optimized file uploads
Socket scaling across multiple servers uses Redis Pub/Sub. See socket scaling guide for implementation details.
Next.js Frontend Architecture
Framework & UI
Module Structure
AI Integration
- Socket.IO client for real-time AI responses
- Single event emission for all AI operations
- Backend-driven operation routing
- Asset serving through S3/MinIO
Request Processing Architecture
LangGraph Flow Management
Intelligent Backend Routing
LangGraph handles all decision-making for operation types: Single Call Operations:- Normal chat queries
- Document-based questions
- Agent conversations
- Combined agent + document queries
- Web search integration
- Image generation requests
- Vision model processing
Operation Detection
Backend automatically identifies:- Tool requirements (web search, image generation)
- Document context needs
- Agent selection
- Model capabilities and limitations
Service Communication
- Frontend ↔ Node.js: Single Socket.IO event for all operations
- Node.js ↔ LLMs: Direct API calls through LangGraph
- Backend ↔ Database: MongoDB connections
- Task Processing: Bull + Redis queues
- Real-time Updates: Socket.IO + Redis Pub/Sub
- File Processing: Parallel S3 upload and vector embedding
File Upload Optimization
Parallel Processing Architecture
Web Search Architecture
SearxNG Integration
- Independence: No dependency on OpenAI’s search features
- Self-hosted: Complete control over search infrastructure
- Universal: Works with all models except GPT-4o latest, DeepSeek, and Qwen
- Privacy: No external search API dependencies
Deployment Architecture
All services are containerized using Docker and orchestrated with Docker Compose:- Development: Local Docker containers
- Production: Multi-container deployment
- Secrets: Environment variables and secret managers
- Monitoring: Socket.IO event tracking and logging

