Skip to main content

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

EnvironmentPathBranch
Production/opt/Essaybot-servermain
UAT/opt/Essaybot-server-UATuat

Server: A6000


Tech Stack

Node.js Backend (Express)

ComponentTechnology
FrameworkExpress.js
DatabaseMongoDB (Mongoose)
AuthJWT + Cookies
QueueRabbitMQ (amqplib)
CacheRedis (ioredis)
Real-timeSocket.IO
StorageMinIO/S3 (AWS SDK)

Python Backend (Flask)

ComponentTechnology
FrameworkFlask
AI AgentsLangGraph + LangChain
RAG SystemLlamaIndex
Vector StoreQdrant
EmbeddingsHuggingFace + Sentence Transformers
GPUPyTorch (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

ServicePort
Express (Node)3001
Flask (Python)6001
MongoDB27017
Redis6379
RabbitMQ5672
Qdrant6333

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