EssayBot Backend
This documentation covers the EssayBot backend services running on the A6000 server.
GitHub Repository: https://github.com/dmsb-dash-labs/EssayBot-Server
Server Location
| Environment | Path | Branch |
|---|---|---|
| Production | /opt/Essaybot-server | main |
| UAT | /opt/Essaybot-server-UAT | uat |
Server: A6000
Tech Stack
Node.js Backend (Express)
| Component | Technology |
|---|---|
| Framework | Express.js |
| Database | MongoDB (Mongoose) |
| Auth | JWT + Cookies |
| Queue | RabbitMQ (amqplib) |
| Cache | Redis (ioredis) |
| Real-time | Socket.IO |
| Storage | MinIO/S3 (AWS SDK) |
Python Backend (Flask)
| Component | Technology |
|---|---|
| Framework | Flask |
| AI Agents | LangGraph + LangChain |
| RAG System | LlamaIndex |
| Vector Store | Qdrant |
| Embeddings | HuggingFace + Sentence Transformers |
| GPU | PyTorch (CUDA) |
Folder Structure
src/
├── index.ts # App entry point
├── config/
│ └── db.ts # MongoDB connection
│
├── controllers/ # Business logic (API handlers)
│ ├── assignments/ # Create/update assignments, generate rubrics
│ ├── attachments/ # File uploads, S3 operations
│ ├── auth/ # Login, session, cross-domain auth
│ ├── courses/ # CRUD for courses
│ ├── grading/ # Single + bulk grading, stats, history
│ ├── reports/ # Analytics
│ ├── tos/ # Terms of Service
│ └── users/ # User profile
│
├── middleware/ # Express middleware
│ ├── authenticateToken.ts # JWT validation
│ ├── errorHandler.ts # Global error handler
│ └── requireApiAuth.ts # API key auth
│
├── models/ # Mongoose schemas
│ ├── Assignment.ts
│ ├── Attachment.ts
│ ├── Course.ts
│ ├── GradingHistory.ts
│ ├── GradingStats.ts
│ └── Section.ts
│
├── routes/ # API route definitions
│ ├── routes.ts # Main router (mounts all sub-routes)
│ ├── authRoutes.ts
│ ├── courseRoutes.ts
│ ├── assignmentRoutes.ts
│ ├── gradingRoutes.ts
│ ├── gradingAsyncRoutes.ts
│ ├── bulkGradingAsyncRoutes.ts
│ └── devRoutes.ts # Dev-only routes (local auth bypass)
│
├── services/ # External service integrations
│ ├── queueService.ts # RabbitMQ producer
│ ├── redisService.ts # Redis cache/state
│ └── websocketService.ts # Real-time notifications
│
├── utils/ # Helpers
│ ├── awsS3.ts # S3/MinIO uploads
│ └── taskPoller.ts # Poll async task status
│
├── scripts/ # One-time migration scripts
│
└── python/ # Python AI Backend
├── app.py # Flask entry point (port 6001)
├── worker.py # RabbitMQ consumer (async jobs)
├── agents.py # LangGraph grading agents
│
├── routes/ # Flask API endpoints
│ ├── bulkGrading.py # Bulk essay grading
│ ├── gradingAgents.py # Single essay grading
│ ├── generateRubric.py
│ └── rag_pipeline.py # RAG queries
│
├── llamaindex_rag/ # RAG system
│ ├── llamaindex_core.py
│ ├── llamaindex_indexing.py
│ ├── llamaindex_retrieval.py
│ └── qdrant_store.py # Vector DB
│
└── utils/ # Python utilities
├── langgraph_grading_agents.py # Multi-agent orchestration
└── grading_guardrails.py # Output validation
Key Flows
1. Single Essay Grading (Sync)
UI → Express API → Flask /grade_single_essay → LangGraph Agents → Response
2. Bulk Grading (Async)
UI → Express API → RabbitMQ → Worker → Flask /grade_bulk_essays → S3 → WebSocket notification
3. RAG Indexing
Upload attachment → Express → Flask /index_content → LlamaIndex → Qdrant vectors
Ports
| Service | Port |
|---|---|
| Express (Node) | 3001 |
| Flask (Python) | 6001 |
| MongoDB | 27017 |
| Redis | 6379 |
| RabbitMQ | 5672 |
| Qdrant | 6333 |
Quick Commands
Start Node Server
npm run dev
Start Python Flask
cd src/python && python app.py
Start Python Worker
cd src/python && python worker.py
Environment Setup
Node.js Dependencies
cd /opt/Essaybot-server # or /opt/Essaybot-server-UAT
npm install
Python Dependencies
cd src/python
pip install -r requirements.txt
Related Documentation
- Frontend - EssayBot frontend application
- UI Deployment - Frontend deployment guide
- Server Deployment - Backend deployment guide