This guide covers our full-stack system design across backend, frontend, infrastructure, and AI integration layers.

Python Backend Architecture

Core Application Stack

ComponentTool / Technology
Backend FrameworkFastAPI
Task QueueCelery
BrokerRedis
DBMongoDB
AuthJWT + Middleware
Task MonitorFlower
Streaming ResponseFastAPI StreamingResponse

AI & Vector Layer

ComponentStack
LLMsOpenAI, Gemini, Anthropic, HuggingFace
EmbeddingsLangChain, Gemini, OpenAI
Vector DBQdrant (Primary), Pinecone (Optional)
Scraping / ParsingPlaywright, BeautifulSoup, Crawler4AI
Currently, we have integrated OpenAI, Anthropic, Gemini, and Hugging Face directly through their APIs. For models like LLaMA, DeepSeek, Grok, and Qwen, we use OpenRouter.
To see how LangChain streaming chat integration is implemented in our system, refer to this link.

Security Config

  • API Key encryption using internal crypto module
  • JWT tokens for access + refresh
  • .env based configuration separation for local/dev/prod

Testing & Debugging

ToolPurpose
PytestUnit Testing
LocustLoad Testing
WDBVisual Debugger (Web-based)
Docker Overridedocker-compose-test.yml setup

Infrastructure

Tool / LayerDescription
DockerContainerization of all services
Docker ComposeMulti-env support for dev/test/local
GitHub ActionsCI/CD pipeline (Optional: AWS CodePipeline)
PrometheusMetrics & Monitoring
Async LoggerCustom logging library

Node.js API System Design

Core Backend

ComponentTool / Library
Web ServerExpress.js
Task QueueBull (via Redis)
Job SchedulerAgenda
AuthJWT Middleware
ORMMongoose (MongoDB)
StreamingSocket.IO

Security & Middleware

  • Role-based Access Control via JWT
  • Rate-limiting using express-rate-limit
  • Encrypted API Keys + Custom middleware
  • .env config via dotenv

Dev Tools

  • Winston + Morgan loggers (logger.js, morgan.js)
  • Debugging via Chrome DevTools or VSCode debugger
  • Live reload via nodemon

Real-time & Storage

  • Socket.IO for live chat + updates
  • Redis Pub/Sub for socket scaling
  • Email via SMTP
  • MinIO / AWS S3 compatible file storage
To learn how socket scaling is handled across multiple servers and load balancers using Redis Pub/Sub, read this guide.

Next.js Frontend System

Framework & UI Layer

ComponentTool Used
Frontend FrameworkNext.js (App Router)
Type SystemTypeScript
StylingTailwind CSS
State ManagementRedux Toolkit
FormsFormik + Custom Inputs
RoutingNext.js File System Routing
AuthFirebase + IronSession + Custom

Feature Modular Structure

ModulePath / Directory
Authsrc/app/(auth) + src/actions/auth.ts
Chat + Threadssrc/components/Chat + src/hooks/chat
Custom GPTsrc/components/CustomGpt
Workspace / Teamssrc/components/Workspace, src/hooks/workspace
File Uploadssrc/components/FileUpload* + src/hooks/storage
Reportssrc/app/(page)/settings/reports

AI & Integration

  • Modular API Clients (/src/actions/)
  • Integrated LLM providers (OpenAI, Gemini, Anthropic)
  • Vector search via Qdrant or Pinecone
  • Asset serving via S3 or MinIO
All services are containerized and orchestrated via Docker Compose. Auth secrets, keys, and access configs are managed securely using .env and optional secret managers.

API Request Lifecycle (Python)

Client Request

[gateway/] → Main entrypoint (FastAPI/Nginx)

[middleware/] → Auth, Logging, Rate Limits

[schema/] → Input/Output validation (Pydantic)

[router/] → Endpoint routing (`/api/user` etc.)

[controller/] → Request logic & response shaping

[service/] → Business logic, API calls

[models/] → DB interaction (MongoDB)

[exceptions/] → Graceful error handling

[utils/] → Shared helper methods

Response → JSON or Streaming back to client