Documentation Index
Fetch the complete documentation index at: https://docs.spn.wtf/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js >= 18
- npm >= 9
- Docker + Docker Compose (for local MySQL & Redis)
- Git
Setup Steps
1. Clone the repo
git clone https://github.com/prativahq/sahyogi.git
cd sahyogi
2. Install dependencies
Copy or create a .env file in the project root. See Environment Variables for the full reference. At minimum you need the database, JWT secrets, and any integration keys you’re working with.
4. Start local services
docker-compose up mysql redis -d
This starts:
- MySQL 8 on port
3306 — db: sahyogi, user: dbuser, password: sin90is1
- Redis 7 on port
6380 — no auth (dev only)
5. Run migrations
To generate SQL migration files instead:
6. Seed the database (optional)
7. Start the dev server
The server runs on http://localhost:5001. The Vite frontend is served by Express (integrated, not a separate port).
Project Structure
sahyogi/
├── client/ # React frontend (Vite)
│ └── src/
│ ├── pages/ # Route-level page components
│ ├── components/ # Shared UI components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utilities, API clients
│ ├── App.tsx # Router + layout
│ └── main.tsx # Entry point
│
├── server/ # Express backend
│ ├── index.ts # Server entry point
│ ├── routes.ts # ALL API routes (~5300 lines)
│ ├── db.ts # Database connection (mysql2 pool)
│ ├── jwt-auth.ts # JWT middleware + helpers
│ ├── storage.ts # DB operations (queries/mutations)
│ ├── stripe.ts # Stripe client + webhook handler
│ ├── subscription.ts # Subscription & billing logic
│ ├── access-control.ts # RBAC implementation
│ ├── websocket.ts # WebSocket server
│ ├── cron.ts # Scheduled jobs (node-cron)
│ ├── controllers/wapp/ # WhatsApp-specific route handlers
│ ├── webhooks/ # Incoming webhook handlers
│ ├── middleware/ # RBAC middleware
│ └── utils/ # vectorSearch, encryption, event-emitter
│
├── shared/
│ ├── schema.ts # Drizzle schema + Zod types (source of truth)
│ ├── gupshup.ts # Gupshup API client
│ └── wasimple.ts # Wasimple API client
│
├── db/
│ ├── index.ts # DB pool initialization
│ ├── seed.ts # Seed data
│ └── migrations/ # SQL migration files
│
├── agent/ # Standalone AI agent process (port 5555)
├── uploads/ # Local file upload directory
├── drizzle.config.ts # ORM configuration
├── docker-compose.yml # Local dev services
├── Dockerfile # Production Docker image
└── package.json
Path aliases
| Alias | Resolves to |
|---|
@/ | client/src/ |
@shared/ | shared/ |
@db | db/index.ts |
Useful Commands
# Development
npm run dev # Start dev server (http://localhost:5001)
npm run check # TypeScript type check
# Database
npm run db:push # Push schema to DB (dev)
npm run db:migrate # Generate SQL migration files
npm run db:seed # Seed initial data
# Build & Production
npm run build # Build client + server
npm run start # Start production server
# Docker
docker-compose up mysql redis -d # Start local DB + Redis
docker-compose down # Stop services
docker-compose down -v # Stop + delete volumes (DELETES DATA)
docker-compose exec mysql mysql -u dbuser -psin90is1 sahyogi
docker-compose exec redis redis-cli
# One-off scripts
npx tsx server/scripts/processTrainingFiles.ts
npx tsx server/scripts/processTrainingUrls.ts
npx tsx server/scripts/createQdrantCollection.ts
npx tsx server/scripts/update-gupshup-subscription.ts