Kaium Al Limon
Available
About
Skills
Impact
Projects
GitHub
Activities
Achievements
Let's Talk
All Projects
Web Project

COSMOS ITS

COSMOS-ITS (Collaborative Orchestration System for Multi-Agent Optimization and Synthesis for Intelligent Tutoring Systems) is a personalized academic support for university students provided by an AI-powered intelligent tutoring System.

Live Demo Source Code
COSMOS ITS screenshot 1
Stars
0
Forks
0
Open Issues
0
Watchers
0

Repository

Kaium Al Limon

Full-Stack Mobile & Web Software Engineer building cross-platform Flutter applications, modern Next.js platforms, and scalable backends with clean architecture and production-ready code.

Available for workDhaka, Bangladesh
Flutter · Next.js · TypeScript · FastAPI · PostgreSQL

Navigation

AboutSkillsImpactProjectsGitHubActivitiesAchievementsContact

Tools Hub

GitHub UnwrappedUIU Exam RoutineUIU CGPA Calculator

Live Telemetry

@kaiumallimon

© 2026 Kaium Al Limon. All rights reserved.

kalimon291@gmail.com|
Default Branch
master
Primary Language
—
Created
Jul 15, 2026
License
—
Size
10 KB
View Repository

Contributors

kaiumallimon
kaiumallimon
3 commits
+440
-2

README

README.mdView on GitHub

⚠️ Production status: The current production URL is no longer functional. This project was built using free-tier resources across all integrated services — MongoDB (shared cluster), Pinecone (starter index), and OpenAI (API credits). Running this project locally or deploying it requires active/resumed MongoDB and Pinecone instances with valid API keys, as well as available OpenAI credits for LLM and embedding operations.

COSMOS Intelligent Tutoring System (ITS)

COSMOS-ITS (Collaborative Orchestration System for Multi-Agent Optimization and Synthesis for Intelligent Tutoring Systems) — A secure, multi-agent intelligent tutoring system that reduces hallucination rates and improves syllabus-aligned response accuracy from 65% (generic LLM baseline) to 92%, while delivering adaptive, always-available personalized tutoring at scale.

Traditional university education struggles to deliver scalable and personalized support. Existing intelligent tutoring platforms relying on generic large language models (LLMs) often suffer from hallucinations, lack curriculum alignment, and fail to adapt to individual learning trajectories. COSMOS-ITS addresses these limitations through a multi-agent architecture that integrates a LangGraph orchestration framework for coordinating specialized domain agents, a Pinecone-backed Retrieval-Augmented Generation (RAG) pipeline for syllabus-grounded responses, and a hybrid grade prediction model combining Gradient Boosting and Multi-Layer Perceptron (MLP) neural networks — trained on 1,000 synthetic student records with 20 engineered features, achieving 90.40% prediction accuracy.

The system is delivered as a monorepo combining a FastAPI microservice backend (cosmos-its-server) with a Next.js admin and student portal (cosmos-admin-panel). A comprehensive 20-feature security framework — including role-based access control (RBAC), context isolation, and prompt injection defense — ensures academic integrity and data privacy. Load testing confirmed system stability with zero failures under 50 concurrent users, and the modular architecture supports easy extensibility to new courses, making COSMOS-ITS a viable foundation for AI-powered personalized university education.


System Architecture

cosmos-its/
├── cosmos-its-server/          # FastAPI + LangChain + LangGraph backend (Python)
│   ├── api/                    # Vercel serverless entry point
│   ├── src/                    # Application source
│   │   ├── core/               # Infrastructure, security, agent framework
│   │   ├── features/           # Domain modules (auth, chat, prediction, roadmap, etc.)
│   │   ├── config/             # Settings & constants
│   │   └── main.py             # FastAPI app bootstrap
│   ├── models/                 # Trained ML model artifacts (.joblib)
│   ├── requirements.txt        # Python dependencies
│   └── vercel.json             # Serverless deployment config
│
├── cosmos-admin-panel/         # Next.js admin dashboard + student portal (TypeScript)
│   ├── app/                    # App Router pages & API routes
│   │   ├── admin/              # Admin dashboard, CRUD modules, logs, search
│   │   ├── user/               # Student portal (chat, performance, roadmap, CGPA)
│   │   ├── chat/               # AI-powered chat interface
│   │   ├── login/              # Authentication pages
│   │   └── api/                # Next.js API routes (auth, CRUD, search, embeddings)
│   ├── components/             # shadcn/ui + custom components
│   ├── lib/                    # Core services (auth, MongoDB, Pinecone, OpenAI)
│   ├── store/                  # Zustand state management
│   ├── hooks/                  # Custom React hooks
│   ├── middleware.ts           # Edge runtime JWT validation & RBAC
│   └── server.js               # cPanel Phusion Passenger deployment
│
└── README.md                   # This file

High-Level Data Flow

┌──────────────────────────────────────────────────────────────────────┐
│                        Admin Panel (Next.js)                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌────────────────────┐  │
│  │ Dashboard│  │ Users/   │  │ Course   │  │ AI Agent Config    │  │
│  │ Analytics│  │ Students │  │ Mgmt     │  │ & Tools            │  │
│  └──────────┘  └──────────┘  └──────────┘  └────────────────────┘  │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌────────────────────┐  │
│  │ Question │  │ Search   │  │ System   │  │ Embeddings /       │  │
│  │ Bank     │  │ (Global) │  │ Logs     │  │ Vector Management  │  │
│  └──────────┘  └──────────┘  └──────────┘  └────────────────────┘  │
└───────────────────────────┬──────────────────────────────────────────┘
                            │ HTTP / REST
                            ▼
┌──────────────────────────────────────────────────────────────────────┐
│                     ITS Server (FastAPI)                              │
│                                                                      │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │           LangGraph Orchestrator (Dynamic Agent Router)      │   │
│  │  ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌────────────────┐ │   │
│  │  │Supervisor│  │ Course  │  │ General │  │ Roadmap Agent  │ │   │
│  │  │  Agent   │  │  Agent  │  │  Agent  │  │                │ │   │
│  │  └─────────┘  └─────────┘  └─────────┘  └────────────────┘ │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                                                                      │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────────┐  │
│  │  Pinecone    │  │    OpenAI    │  │  ML Ensemble (RF+GB+MLP) │  │
│  │  Vector DB   │  │    LLM       │  │  Grade Prediction        │  │
│  └──────────────┘  └──────────────┘  └──────────────────────────┘  │
│                                                                      │
│  ┌──────────────────────────────────────────────────────────────┐   │
│  │              MongoDB (Beanie ODM / Motor)                     │   │
│  │  Accounts │ Threads │ Agents │ Courses │ Assessments │ ...   │   │
│  └──────────────────────────────────────────────────────────────┘   │
└──────────────────────────────────────────────────────────────────────┘

Features

Multi-Agent RAG Chatbot

The system employs a dynamic multi-agent architecture built on LangGraph. Rather than a single monolithic AI, the orchestrator routes queries to specialized agents based on context:

AgentRole
Supervisor AgentContext-aware router — assigns highest priority to pagination requests, routes to course-specific agents or the general fallback
Course AgentsSubject-matter experts for courses like DBMS, SPL, OOP, etc. Each agent performs intent detection (conceptual question vs. retrieval request), contextual query rewriting, and structured response generation
General AgentFallback for general education queries outside specific course scope

RAG Pipeline: User query → Supervisor routing → Course agent (intent detection) → Query rewriting with conversation context → LLM classification using few-shot learning from MongoDB → Pinecone vector search with metadata filters → Structured results with pagination state tracking.

Agents are auto-discovered — creating a new agent requires only a Python file extending BaseAgent under the features directory and a MongoDB record. No hardcoded imports needed.

ML-Based Grade Prediction

A production-grade ensemble prediction system that forecasts student grades:

  • Models: RandomForest, GradientBoosting, and MLP neural network trained on historical assessment data
  • Ensemble: Weighted voting across all three models for robust predictions
  • Meta-Learning: Adjusts predictions based on student experience level (fresh vs. experienced) and cross-course learning patterns
  • Feature Engineering: Course clusters, CT (class test) trends, trimester code resolution, marking scheme application (theory/lab distinction)
  • Storage: Pre-trained joblib artifacts for fast inference

Adaptive Learning Roadmaps

AI-generated personalized study roadmaps with multi-graph architecture:

  • Generation Graph: Structured roadmap creation (stages, items, descriptions) via LLM with JSON schema validation
  • Chat Graph: Context-aware follow-up Q&A about roadmap content with node-specific context injection
  • Explanation Graph: Deep-dive topic explanations anchored to specific roadmap nodes
  • Progress Tracking: Node-level completion tracking with toggle functionality
  • Checkpointing: LangGraph MongoDB checkpointer for conversation persistence

Academic Performance Tracker

Comprehensive student performance management:

  • Assessments: Full CRUD with grade calculation per the institution's marking scheme
  • Topics: Course topic tracking with per-student confidence levels
  • Quiz Sessions: Quiz generation, submission, and grading
  • Weakness Analysis: Track and analyze student weak areas
  • GPA Calculation: Full GPA computation with trimester-level records, grade scale enforcement (A=4.0 through F=0.0), and course-by-course breakdowns
  • Course Enrollment: Student-course mapping with marks and grades

Student Calendar & Events

  • CRUD operations for personal academic events with date-range filtering
  • Deduplication logic for event management
  • Integration with the academic calendar system

Admin Panel Features

The admin panel (cosmos-admin-panel) provides a complete management interface:

ModuleCapabilities
Dashboard AnalyticsReal-time stats (users, courses, questions, agents), system operations, success rates, bar/pie charts, activity feed
User ManagementCRUD with search/filter, role-based access (admin/student), auto-generated secure passwords, email notifications, profile editing, academic data management
Question BankFull CRUD with course/exam-type/semester filtering, rich text editing, image support, vector embedding generation, Pinecone sync
Course ManagementCourse, topic, and trimester CRUD with department tracking, exam type categorization
AI Agent ManagementCreate/edit/activate/deactivate agents, configure system prompts, tool bindings, few-shot examples, and extended configurations
Embedding ManagementUpdate/reprocess vector embeddings per course with shimmer-animated progress tracking and upsert statistics
Content DeliveryCDN file browser with upload, type filtering (pdf/image), paginated grid, download links
System LogsFull immutable audit trail with admin actions, request metadata (IP, user-agent, duration), searchable by method/resource/date range
Global SearchCross-collection command palette (cmd+k) searching users, questions, courses, agents, system logs, and navigation pages
Help CenterSearchable help articles with relevance scoring, accordion FAQs, command palette, support contact

Student Portal Features

ModuleCapabilities
Student DashboardEnrolled courses, performance summaries, CGPA display, GPA trend radar chart, notices, upcoming events
Performance ModuleCourse details with tabs (Assessments, Quizzes, Reports), quiz taking with history, weakness analysis, grade prediction
Learning RoadmapInteractive D3 force-directed graph visualization with zoom/pan and detailed panels
CGPA CalculatorInteractive GPA calculator with retake support
Class RoutinesClass schedule + exam timetable with UIU profile integration
Study PlannerCalendar-based event planner with CRUD dialogs
Notices & Academic CalendarPaginated notice list with detail view, calendar entries with revised indicators, PDF downloads
Profile SettingsProfile editor and password change
AI ChatFull-featured multi-agent chat with streaming responses, thread management, markdown rendering, code block highlighting

Technology Stack

Backend (cosmos-its-server)

CategoryTechnologies
FrameworkPython 3.11, FastAPI, Uvicorn, Pydantic
AI/LLMOpenAI GPT-4/GPT-3.5, LangChain, LangGraph, LangChain-Core, LangChain-Community
Vector DatabasePinecone (OpenAI text-embedding-3-small / ada-002)
DatabaseMongoDB via Motor + Beanie ODM + PyMongo
AuthPyJWT, bcrypt (12 rounds), Passlib
MLscikit-learn (RandomForest, GradientBoosting), NumPy, Pandas, Joblib
OrchestrationLangGraph StateGraph with MongoDB checkpointing
DeploymentVercel Serverless (Python 3.11, 250MB lambda)

Frontend (cosmos-admin-panel)

CategoryTechnologies
FrameworkNext.js 16 (App Router), React 19, TypeScript
StylingTailwind CSS v4, tw-animate-css, shadcn/ui (New York style)
UI LibrariesRadix UI primitives, Lucide & Tabler icons, motion (Framer Motion), GSAP, Lottie, Cobe
Data VisualizationD3.js, Recharts, react-syntax-highlighter, react-markdown
State ManagementZustand with persist middleware
API & IntegrationMongoDB native driver, Pinecone SDK, OpenAI SDK, Nodemailer
SearchCustom cross-collection command palette (cmdk)
AuthJWT (access + refresh tokens), bcryptjs, 3-layer auth (Edge, API, Client)
DeploymentStandalone Next.js output, cPanel Phusion Passenger, Vercel, Namecheap CI/CD

Database Schema

The system uses MongoDB as its primary database, shared between both packages. The server uses Beanie ODM for document modeling, while the admin panel uses the native MongoDB driver.

20+ Collections Overview

CollectionModulePurpose
accountsAuthUser accounts with email, bcrypt-hashed password, role (admin/user)
profilesAuthExtended user profiles (name, student ID, department, batch, program, CGPA, credits)
refresh_tokensAuthJWT refresh token storage with revocation tracking
agentsCore Data / Agent MgmtAI agent configurations (name, prompt, active status)
agent_toolsCore DataPer-agent tool bindings
agent_configurationsCore DataExtended agent configuration JSON
few_shot_examplesCore DataLLM query classification examples for RAG pipeline
question_partsCore Data / QuestionsExam question metadata, text, image URLs, vector IDs for Pinecone
user_threadsAgentic ChatChat conversation threads with metadata
chat_messagesAgentic ChatIndividual chat messages within threads
assessmentsPerformance TrackerAcademic assessment records with marks and grades
topicsPerformance TrackerCourse topic definitions with student confidence tracking
student_coursesPerformance TrackerEnrollment mappings with marks and computed grades
coursesPerformance TrackerCourse catalog (code, title, credits, department)
weaknessesPerformance TrackerStudent weakness analysis records
quiz_sessionsPerformance TrackerQuiz attempts, submissions, and results
performance_recordsPerformance TrackerOverall performance snapshots per student
trimestersPerformance TrackerTrimester GPA records
gpa_recordsPerformance TrackerFull GPA breakdowns with per-course grades
student_eventsStudent EventsCalendar events with date ranges
roadmapsRoadmap GeneratorGenerated AI learning roadmaps with stages and items
roadmap_node_progressRoadmap GeneratorPer-node completion tracking
roadmap_chat_messagesRoadmap GeneratorRoadmap-specific chat history
system_logsAdmin PanelImmutable admin action audit trail
noticesAdmin/User PortalPublished notices and announcements

API Endpoints

Server API (FastAPI — 50+ endpoints)

Auth (/auth): Register, login, refresh tokens, logout, profile (GET/PATCH), forgot/reset password

Agentic Chat (/chat): Create/list/get/delete threads, send messages, simple chat, list available agents

Grade Prediction (/api/v1/prediction): Predict student grades via ensemble ML, health check

Performance Tracker (/api/v1/performance): Full CRUD for assessments, topics, courses, enrollments, weaknesses, quizzes, GPA calculation, CT count management

Student Events (/api/v1/events): Create, list (by student + date range), update, delete events

Learning Roadmap (/roadmap): Generate roadmaps, list/get/delete, chat with context, progress toggling

Agent Management (/agents): Admin CRUD for AI agent configurations

Admin Panel API (Next.js — 30+ endpoints)

Auth (/api/auth): Login, register, logout, refresh, password reset with email

Users (/api/users): Paginated list with search/filter, create with auto-generated passwords, get/update/delete by ID, stats

Courses (/api/courses): CRUD with department tracking

Course Management (/api/course-management): Topics and trimesters CRUD

Questions (/api/questions): Paginated list with course/exam-type/semester filters, CRUD by ID, upload with Pinecone embedding generation

Agents (/api/agents, /api/agent-tools, /api/agent-configurations, /api/few-shot-examples): Full CRUD for agents and their configurations

Search (/api/search): Cross-collection search (users, questions, courses, agents, system-logs, navigation)

Dashboard (/api/dashboard): Analytics overview, question stats by course

System Logs (/api/system-logs): Filterable, paginated audit trail with admin/date/resource filters

Embeddings (/api/update-embeddings): Regenerate Pinecone embeddings for all questions or by course

CDN (/api/cdn): File upload and management for content delivery

Notices & Academic Calendar (/api/notices, /api/academic-calendar): CRUD for published content


Security Architecture

The system implements a multi-layered security model:

LayerMechanism
Edge MiddlewareNext.js Edge Runtime validates JWT format, checks expiry, enforces role-based route access; redirects unauthenticated users to /login
API MiddlewareServer-side JWT signature verification with jsonwebtoken, admin role enforcement, user object injection into request context
Client ProtectionProtectedRoute component with Zustand auth state check; redirects on authentication failure
Token StrategyShort-lived access tokens (15 min) + long-lived refresh tokens (7 days) with rotation and revocation
Password Securitybcrypt hashing (12 rounds, 4096 iterations), secure auto-generated passwords (12 chars, 74-bit entropy), RFC email validation + disposable domain blocking
Password Reset3-minute time-limited reset tokens, separate signing secret, issuer/audience validation, single-use enforcement
Cookie SecurityHttpOnly, Secure (production), SameSite=Lax configuration
Audit TrailImmutable system_logs collection capturing before/after state, admin identity, IP, user-agent, and response timing for all POST/PUT/DELETE operations
Error HandlingDetailed server-side error logging with sanitized client responses — stack traces, file paths, and DB errors never exposed to users

AI & Machine Learning Highlights

Language Model Integration

  • Primary Model: GPT-4-turbo-preview (default) / GPT-3.5-turbo (fast fallback)
  • Embeddings: OpenAI text-embedding-3-small / text-embedding-ada-002
  • Framework: LangChain with LangGraph for stateful multi-agent orchestration
  • Tracking: LangChain callback handler for LLM token usage monitoring

RAG Pipeline Features

  • Few-Shot Learning: Query classification examples stored in MongoDB, dynamically loaded per agent
  • Contextual Query Rewriting: Conversation history injected into search queries for improved retrieval
  • Metadata Filtering: Pinecone queries filtered by course code, exam type, and semester
  • Paginated Retrieval: Stateful pagination with 50-question cap, dynamic quantity extraction from user queries
  • Graceful Degradation: Falls back to conversation-only mode when LLM is unavailable

ML Prediction Pipeline

Student Marks → Trimester Code Resolution → Enrollment History Fetch →
Feature Engineering (Course Clusters, CT Trends) →
Ensemble Prediction (RF + GB + MLP) →
Meta-Learning Adjustment (Fresh vs Experienced) →
Marking Scheme Application (Theory/Lab) → Grade Output

Auto-Discovery Architecture

The server agent system uses dynamic filesystem scanning. Adding a new AI capability requires:

  1. Create a Python file in src/features/*/agent/ with a class extending BaseAgent
  2. Insert a record in the MongoDB agents collection
  3. The AgentRegistry discovers it automatically — no code changes in main.py

UI & Experience Highlights

  • Animated Marketing Landing: 3D globe (Cobe), GSAP scroll animations, Lottie illustrations, particle effects
  • Command Palette: Cross-collection cmd+k search bar available throughout the admin panel
  • Dark Mode: Full theme support via next-themes with system preference detection
  • Responsive Design: Adaptive layouts for desktop and tablet, mobile chat sidebar with sheet drawer
  • Interactive Visualizations: D3 force-directed roadmap graphs, Recharts analytics, radar charts for student performance
  • Streaming Chat: Real-time AI response streaming with markdown rendering, syntax-highlighted code blocks, and copy functionality
  • Shimmer Animations: Embedding processing progress with per-question shimmer effects
  • Toast Notifications: Sonner-based toast system for action feedback
  • Frosted Glass UI: Custom frosted header components with backdrop blur

Deployment

The system is designed for modern cloud deployment:

ComponentPlatformConfiguration
FastAPI ServerVercel ServerlessPython 3.11, 250MB lambda, vercel.json routing
Next.js Admin PanelVercel / cPanel (Phusion Passenger)output: 'standalone', Node 20
DatabaseMongoDB AtlasShared across both packages
Vector StorePineconeServerless index with metadata filtering
CI/CDGitHub ActionsNamecheap deployment via rsync + PM2

The .github/workflows/deploy.yml pipeline automates build and deployment with environment-specific secrets for database URIs, JWT secrets, API keys, and email credentials.


Project Structure (Detailed)

cosmos-its/
│
├── cosmos-its-server/
│   ├── api/
│   │   └── index.py                  # Vercel serverless entry
│   ├── src/
│   │   ├── main.py                   # FastAPI bootstrap, CORS, lifespan
│   │   ├── config/
│   │   │   ├── settings.py           # pydantic-settings (env vars)
│   │   │   └── constants.py          # LLM, retrieval, agent config
│   │   ├── core/
│   │   │   ├── infra/
│   │   │   │   ├── database.py       # Motor + Beanie ODM
│   │   │   │   ├── llm_client.py     # OpenAI/LangChain integration
│   │   │   │   ├── pinecone_client.py# Vector DB service
│   │   │   │   └── services.py       # DI container
│   │   │   ├── agent/
│   │   │   │   ├── registry.py       # Dynamic agent discovery
│   │   │   │   ├── factory.py        # Agent instantiation from DB
│   │   │   │   ├── base_agent.py     # Abstract agent class
│   │   │   │   ├── orchestrator.py   # LangGraph StateGraph
│   │   │   │   └── agent_state.py    # TypedDict state defs
│   │   │   ├── security/
│   │   │   │   └── jwt_utils.py      # JWT + bcrypt utilities
│   │   │   ├── data/
│   │   │   │   └── models.py         # Core MongoDB models
│   │   │   └── utils/
│   │   │       ├── logger.py         # Colored console logging
│   │   │       ├── exceptions.py     # Custom exception hierarchy
│   │   │       ├── title_generator.py
│   │   │       ├── llm_tracker.py    # Token usage tracking
│   │   │       ├── message_formatter.py
│   │   │       └── performance_context.py
│   │   └── features/
│   │       ├── auth/                 # Registration, login, profile
│   │       ├── agentic_chat/         # Supervisor, course, general agents
│   │       ├── prediction_model/     # Ensemble ML grade prediction
│   │       ├── performance_tracker/  # Assessments, quizzes, GPA
│   │       ├── student_events/       # Calendar management
│   │       ├── roadmap_generator/    # AI learning roadmaps
│   │       └── agent_management/     # Admin agent CRUD
│   ├── models/                       # Joblib ML artifacts
│   └── docs/                         # Run scripts, issue tracking
│
├── cosmos-admin-panel/
│   ├── app/
│   │   ├── (landing)/                # Marketing page
│   │   ├── login/                    # Auth pages
│   │   ├── register/
│   │   ├── reset-password/
│   │   ├── admin/                    # Admin dashboard & CRUD modules
│   │   ├── user/                     # Student portal (13+ pages)
│   │   ├── chat/                     # AI chat interface
│   │   └── api/                      # All server API routes
│   ├── components/
│   │   ├── ui/                       # shadcn primitives (button, card, etc.)
│   │   ├── dashboard/                # Stats cards, charts
│   │   ├── landing/                  # Marketing header/footer
│   │   ├── roadmap/                  # D3 graph components
│   │   ├── agents/                   # Agent form components
│   │   ├── kokonutui/               # External registry components
│   │   └── *.tsx                    # ProtectedRoute, ThemeProvider, GlobalSearch, etc.
│   ├── lib/                          # 28 service modules (auth, DB, AI, email, etc.)
│   ├── store/auth.ts                 # Zustand persistence store
│   ├── hooks/                        # use-mobile, use-auto-resize-textarea
│   └── middleware.ts                 # Edge auth + RBAC
│
└── README.md