How shubhamdalvi1999/gen_ai_assignment_evaluator works
Project Type and Purpose
• Type: Full-stack web application with a monolithic backend (FastAPI) and a static frontend (HTML/CSS/JS).
• Purpose: Automatically evaluate student code and text assignments via a Retrieval-Augmented-Generation (RAG) pipeline, returning similarity scores and AI-generated feedback.
File Structure
• Top Level:
• app.py – main FastAPI application entrypoint
• config/setting.py – environment and service configuration
• static/ & templates/ – frontend assets and HTML
• utils/ – modular services (code_analyzer, docx_processor, embedding_service, rag_processor, db_service, feedback_service, logger, tokenizer_utils, prompts)
• docs/ – architecture and flow documentation
• Patterns:
• MVC-style separation: templates + static for “view,” FastAPI for “controller,” utils for “model/business logic.”
• RAG pipeline layers implemented as distinct utility modules.
Extract Additional Insights from README
• Backend: FastAPI providing API endpoints for code and text evaluation.
• Frontend: Single-page interface using JavaScript to call backend endpoints.
• Database: MongoDB for embedding storage and retrieval.
• AI Models: Ollama (local) and OpenAI (cloud) for embeddings and generation.
• RAG Stages: Document processing, embedding gen/storage, retrieval, augmentation, evaluation, scoring, generation, summary.
Main Components & Interactions
a. User Interface (Browser)
• Static files served by FastAPI: HTML (templates/index.html), CSS, JS.
• JS calls backend endpoints (/evaluate_code, /evaluate_text).
b. API Layer (FastAPI app.py)
• Receives HTTP requests from UI.
• Routes to appropriate controller functions.
c. Configuration Module (config/setting.py)
• Loads environment variables (API keys, DB URI, thresholds).
d. RAG Pipeline & Business Logic (utils/…)
• docx_processor.py / code_analyzer.py: parse submissions.
• tokenizer_utils.py: estimate tokens.
• embedding_service.py: call Ollama/OpenAI for embeddings.
• db_service.py: store/retrieve embeddings from MongoDB.
• rag_processor.py / text_rag_processor.py: orchestrate retrieval + augmentation.
• feedback_service.py: generate final feedback via AI.
• prompts.py: store prompt templates.
• logger.py: log each stage to logs/*.log.
e. External Services
• MongoDB: stores embeddings & QA docs.
• Ollama API (optional local)
• OpenAI API (optional cloud)
f. Logging Subsystem
• File-based logs for each util: app.log, embedding.log, feedback.log, etc.
Architectural Patterns & Principles
• Layered Architecture: Presentation (frontend), API (FastAPI), Service/Business Logic (utils), Data Access (db_service), External integrations (AI models, MongoDB).
• Separation of Concerns: Each util module handles a distinct RAG stage.
• Modularity & Extensibility: New evaluation types can be added by creating new util modules.
Step-by-Step Diagramming Workflow
• Config Loader
• Endpoint Controllers
• RAG Pipeline (group the utils modules)
• Logger
4. Inside RAG Pipeline, order modules top-down:
• Document/Code Processor → Token Estimator → Embedding Service ↔ MongoDB
• Retrieval → Augmentation → Evaluation → Feedback Generator