Skip to main content

Tech Stack

LayerTechnology
FrontendReact 18, TypeScript, Vite, Tailwind CSS, Radix UI
BackendNode.js, Express.js, TypeScript
DatabaseMySQL 8 (Drizzle ORM)
CachingRedis (Upstash in production)
AuthJWT access + refresh tokens, OAuth2 (Google, Twitter, Facebook)
AI / LLMGoogle Gemini, LangChain, OpenAI (embeddings)
Vector DBQdrant (RAG / semantic search)
Cloud StorageAWS S3
PaymentsStripe, Cashfree
WhatsAppGupshup (primary), Wasimple, Facebook Meta
Real-timeWebSockets
Job Schedulingnode-cron

High-Level Architecture

Browser / WhatsApp / Telegram / Gmail / Twitter


  Express.js Server (port 5001)
  ├── REST API (~160+ endpoints)  ←── JWT Auth middleware
  ├── WebSocket Server            ←── Real-time inbox updates
  ├── Webhook handlers            ←── Gupshup / Wasimple / Meta / Stripe
  └── Static file server          ←── Vite-built React app

        ├── MySQL 8 (Drizzle ORM)
        ├── Redis (session cache, job queue)
        ├── AWS S3 (media + training files)
        ├── Qdrant (vector store for RAG)
        └── AI Agent Process (port 5555)
              └── LangChain + Gemini / OpenAI

Project Structure

sahyogi/
├── client/src/           # React frontend
│   ├── pages/            # Route-level components
│   ├── components/       # Shared UI components
│   ├── hooks/            # Custom React hooks
│   └── lib/              # API clients, utilities

├── server/               # Express backend
│   ├── routes.ts         # All API routes (160+ endpoints)
│   ├── db.ts             # MySQL connection pool
│   ├── jwt-auth.ts       # JWT middleware
│   ├── storage.ts        # DB query/mutation layer
│   ├── stripe.ts         # Stripe client + webhooks
│   ├── websocket.ts      # WebSocket server
│   ├── cron.ts           # Scheduled jobs
│   └── utils/            # vectorSearch, encryption, events

├── shared/
│   ├── schema.ts         # Drizzle schema + Zod types (source of truth)
│   ├── gupshup.ts        # Gupshup API client
│   └── wasimple.ts       # Wasimple API client

├── agent/                # Standalone AI agent (port 5555)
└── db/                   # Migrations + seed

Key Flows

Message Flow (WhatsApp → Bot → User)

WhatsApp user sends message


Gupshup/Wasimple/Meta webhook → POST /api/webhooks/...


Bot lookup (channel → bot mapping)


AI Agent (LangChain + Gemini)
  ├── Tool calls (Airtable, webhooks, API tools)
  └── RAG: Qdrant vector search → context injection


Response sent back via WhatsApp provider API


Message stored in MySQL → WebSocket push to inbox

RAG (Knowledge Base) Flow

User uploads PDF / URL


File stored in AWS S3 / URL scraped


processTrainingFiles.ts / processTrainingUrls.ts
  → Text chunked → Embeddings via Gemini/OpenAI
  → Stored in Qdrant vector collection


On bot message → vectorSearch.ts queries Qdrant
  → Top-k chunks injected into LLM prompt

Channels

ChannelProviderAuth method
WhatsAppGupshup (primary)API Key
WhatsAppWasimpleAPI Key
WhatsAppFacebook/MetaOAuth2
GmailGoogleOAuth2
TwitterTwitterOAuth2
WebBuilt-inBot ID
Telegram, Slack, DiscordOn request

AI & Integrations

ServiceRole
Google GeminiLLM for bot responses + embeddings
OpenAIEmbedding fallback
QdrantVector search for knowledge-base RAG
LangChainAgent orchestration, tool use, RAG pipeline
AirtableBot tool — read/write CRM data
AWS S3Media and training file storage
StripeSubscription billing
CashfreeAlternative billing (India)
RedisSession caching, queue