How abhiram3107/virtual-assistant works
Project Type and Purpose
• This is a full-stack, monolithic Django web application with a modular structure comprised of several Django “apps.” Its primary purpose is to provide a Role-Based Virtual Assistant within an LMS. Users interact via text or (optional) voice; the assistant performs intent recognition, routes the request to the correct handler, fetches/aggregates data (performance, attendance, etc.) from the database, and returns a customized response.
High-Level File‐Structure Analysis
• Top-Level Components:
• VA/ – Django project settings (ASGI/WSGI, URLs, env)
• Assistant/ – Core virtual assistant logic: NLP, intent router, handlers, static dataset
• assessments/, attendence/, program/, users/ – Domain apps containing models, views, migrations
• manage.py, requirements.txt, README.md
• Architectural Pattern:
• Monolithic Django MVC (Models in each app → Views → HTTP interface)
• “Handler” sub-pattern in Assistant/: IntentRouter → Router → Role‐specific handlers
• ORM models spanning multiple apps for user profiles, academic structure, tests, attendance
Insights from README
• Workflow:
1. User Input (text or voice)
2. Role Identification (via users.models.*Profile)
3. Intent Detection (Sentence-BERT + cosine similarity)
4. Routing to Handlers (Assistant/handlers/)
5. Data Fetch (ORM queries across assessments, attendence, program, users)
6. Response Generation (text or text+speech)
• Key Technologies:
• Django, Python, ORM
• sentence-transformers (paraphrase-MiniLM-L6-v2)
• speech_recognition, pyttsx3 (optional voice)
• Static JSON dataset for FAQs/navigation
Main Components
a. User Layer
• Web Client (Browser/mobile)
• Optional Voice Input/Output module
b. API Layer
• Django ASGI/WSGI Server (VA/asgi.py, VA/wsgi.py)
• URL Routing (VA/urls.py → app urls)
c. Virtual Assistant Service (Assistant/)
• Core Engine (Assistant/core.py)
• Intent Detection (Assistant/handlers/intent_router.py)
• Router (Assistant/handlers/router.py)
• Role-specific Handlers (student_analysis.py, teacher_analysis.py, hod_analysis.py)
• Static Dataset Loader (Assistant/data/dataset.json)
d. Domain Applications
• users/ (User, StudentProfile, TeacherProfile, HodProfile)
• program/ (Program, Subject, Chapter, Topic)
• assessments/ (Test, TestResult)
• attendence/ (Attendance)
e. Database
• Relational DB (PostgreSQL/MySQL/SQLite)
• Contains all model tables across the apps
f. External Libraries & Services
• Sentence-BERT model
• speech_recognition & pyttsx3
Relationships and Data Flow
1. User → HTTP/Voice request → Django Server
2. Django URL Dispatcher → Assistant.core entry point
3. Assistant.core → IntentRouter → Router → appropriate handler
4. Handler → ORM Queries (users, program, assessments, attendence)
5. Handler → Business logic & analytics → Response object
6. Core → Return JSON or rendered template (plus optional TTS)
7. Django → HTTP/Voice response → User
Architectural Patterns & Principles
• MVC (Models in each app → Controllers in views/handlers → Views/Responses)
• Modular apps for separation of concerns
• Handler/Router pattern for virtual assistant request processing
• Single source of truth: dataset.json for static Q&A
• Pluggable voice I/O layers (commented out for flexibility)
Elements
• Clear labels (e.g., “IntentRouter,” “StudentAnalysisHandler,” “TestResult ORM Query”)