CourseApp — E-Learning Platform with RAG AI Chat
A full-stack e-learning platform where instructors manage courses and materials, students enroll and learn, and an AI assistant answers questions grounded in the actual course content (RAG).
Layer
Technology
Backend
.NET 9, ASP.NET Core, Entity Framework Core 8
Database
PostgreSQL 16 + pgvector extension
Messaging
RabbitMQ (async material processing)
LLM
Ollama (local) or Groq API (cloud, free)
Embeddings
Ollama nomic-embed-text or Jina AI (free)
Frontend
Angular 20, Bootstrap 5, Bootstrap Icons
┌─────────────────────────────────────────────────────────────┐
│ Angular 20 (Nginx) http://localhost │
│ Proxies /api/* → .NET API │
└─────────────────┬───────────────────────────────────────────┘
│
┌─────────────────▼───────────────────────────────────────────┐
│ CourseApp.Api (.NET 8) Clean Architecture │
│ ├─ Domain Entities, Enums, Domain Exceptions │
│ ├─ Application CQRS (MediatR), DTOs, AutoMapper │
│ ├─ Infrastructure EF Core, Repos, JWT, AI Services │
│ └─ Api Controllers, Swagger, Middleware │
└──────┬─────────────────────────────┬────────────────────────┘
│ │
┌──────▼──────┐ ┌──────────────────▼──────────────────────┐
│ PostgreSQL │ │ CourseApp.Worker (BackgroundService) │
│ + pgvector │ │ Consumes RabbitMQ MaterialUploaded │
└─────────────┘ │ → Extract text → Chunk → Embed → Store │
└──────────────────────────────────────────┘
Backend Clean Architecture
CourseApp.Domain ← Entities, Enums, Exceptions (no deps)
CourseApp.Application ← Use cases, Interfaces, DTOs, Validators
CourseApp.Infrastructure ← EF Core, Repos, JWT, Ollama/Groq
CourseApp.Api ← Controllers, Middleware, Program.cs
CourseApp.Worker ← RabbitMQ consumer (background process)
src/app/
│ ├── models/ TypeScript interfaces matching API DTOs
│ ├── services/ AuthService, CourseService, MaterialService, ChatService, ModelService
│ ├── guards/ authGuard, instructorGuard, guestGuard
│ └── interceptors/ jwtInterceptor (Bearer token), errorInterceptor (auto-refresh)
├── compontents/
│ ├── auth/ Login, Register, Unauthorized
│ ├── courses/ Dashboard, CourseList, CourseDetail, CourseForm, Models
│ ├── materials/ Upload, list with processing status
│ └── chat/ RAG chat sessions with message history
└── └── layout/ Navbar, sidebar, Alert, Loading
Pattern
Where
Clean Architecture
Domain → Application → Infrastructure → Api
CQRS
MediatR Commands / Queries per feature
Repository + UoW
IRepository<T>, IUnitOfWork → AppDbContext
Strategy
IContentExtractor — Pdf / Docx / Text extractors
Pipeline Decorator
LoggingBehavior, ValidationBehavior (MediatR pipeline)
RAG
Embed → pgvector search → prompt → LLM
Tool
Version
.NET SDK
9.0+
Node.js
22+
Angular CLI
20+
Method
Endpoint
Auth
Description
POST
/register
❌
Register — role: Student or Instructor
POST
/login
❌
Login → JWT access token + refresh token
POST
/refresh
❌
Exchange refresh token for new access token
POST
/revoke
✅
Revoke refresh token (logout)
GET
/me
✅
Get current user profile
Method
Endpoint
Role
Description
GET
/
Any
All published courses
GET
/{id}
Any
Course detail
GET
/my
Instructor
My courses
GET
/enrolled
Student
Enrolled courses
POST
/
Instructor
Create course
PUT
/{id}
Instructor
Update course
PATCH
/{id}/publish
Instructor
Publish / unpublish
DELETE
/{id}
Instructor
Delete course
POST
/{id}/enroll
Student
Enroll
Materials /api/courses/{courseId}/materials
Method
Endpoint
Role
Description
GET
/
Any
List materials
GET
/{id}
Any
Material metadata
GET
/{id}/download
Any
Download file
POST
/
Instructor
Upload file (multipart, max 100 MB)
DELETE
/{id}
Instructor
Delete material
Chat /api/courses/{courseId}/chat
Method
Endpoint
Role
Description
GET
/sessions
Student
My chat sessions
POST
/sessions
Student
Start new session
GET
/sessions/{id}
Student
Session with full message history
POST
/sessions/{id}/ask
Student
Ask AI — RAG pipeline
Method
Endpoint
Role
Description
GET
/
Instructor/Admin
List available models
GET
/current
Instructor/Admin
Active model name
POST
/switch
Instructor/Admin
Switch model at runtime
Student question
↓
1. Embed question (Ollama: nomic-embed-text)
↓
2. Vector similarity search (pgvector cosine distance, scoped to course)
↓
3. Retrieve top-K chunks (material_chunks table)
↓
4. Build system prompt ("Here is the course material: ...")
↓
5. Call LLM (Ollama: llama3.2 OR Groq: llama3-8b-8192)
↓
6. Save to chat history → return answer to student
Material Processing Pipeline
Instructor uploads file
↓
API saves to disk → writes DB record → publishes MaterialUploadedEvent to RabbitMQ
↓
Worker consumes event
↓
Load material via IMaterialRepository
↓
Get file stream via IFileStorage
↓
Extract text via IContentExtractorFactory (Strategy — PDF / DOCX / TXT)
↓
Chunk text (≈800 tokens, 100 token overlap)
↓
Embed each chunk (IEmbeddingService)
↓
Store vectors in material_chunks (pgvector)
↓
Mark material as Processed
"Ollama" : {
"BaseUrl" : " http://localhost:11434" ,
"LlmModel" : " llama3.2" ,
"EmbeddingModel" : " nomic-embed-text"
}
Pull models: ollama pull llama3.2 and ollama pull nomic-embed-text
Groq (cloud, free — chat only)
Get free API key at console.groq.com — no credit card needed.
"Groq" : {
"ApiKey" : " gsk_xxx" ,
"Model" : " llama3-8b-8192"
}
Available models: llama3-8b-8192, llama3-70b-8192, mixtral-8x7b-32768, gemma2-9b-it
Single AppDbContext — one Postgres database, no schemas.
Table
Description
users
All users — role column: Student / Instructor / Admin
refresh_tokens
JWT refresh tokens per user, with revocation
courses
Courses owned by instructors
enrollments
Student ↔ Course many-to-many
materials
Uploaded files with processing status
material_chunks
Text chunks with 768-dim vector embeddings
chat_sessions
Per-student, per-course conversation threads
chat_messages
Individual messages (role: user / assistant)
dotnet tool install --global dotnet-ef
dotnet ef migrations add InitialCreate \
--project src/CourseApp.Infrastructure \
--startup-project src/CourseApp.Api \
--context AppDbContext \
--output-dir Persistence/Migrations
# Migrations also run automatically on startup
Copy .env.example to .env and fill in:
POSTGRES_PASSWORD = StrongPassword123!
RABBITMQ_USER = guest
RABBITMQ_PASS = guest
JWT_KEY = your-very-long-random-secret-min-32-chars
LLM_MODEL = llama3.2
EMBEDDING_MODEL = nomic-embed-text
Never commit .env to Git. It is in .gitignore.
project-root/
├── backend/ .NET solution
│ ├── CourseApp.sln
│ ├── src/
│ │ ├── CourseApp.Domain/ Entities, Enums, Exceptions
│ │ ├── CourseApp.Application/
│ │ │ └── Features/
│ │ │ ├── Auth/ Commands, Queries, DTOs
│ │ │ ├── Courses/ Commands, Queries, DTOs
│ │ │ ├── Materials/ Commands, Queries, DTOs
│ │ │ ├── Indexing/ ProcessMaterialCommand
│ │ │ └── Chat/ Commands, Queries, DTOs
│ │ ├── CourseApp.Infrastructure/
│ │ │ ├── Persistence/ AppDbContext, Repositories, EF Configs
│ │ │ ├── Services/ JWT, FileStorage, Ollama, Groq
│ │ │ │
│ │ └── CourseApp.Api/ Controllers, Program.cs, Swagger
│ └── workers/
│ └── CourseApp.Worker/ RabbitMQ consumer
├── frontend/ Angular 20 app
│ ├── src/app/
│ │ ├── Models, Services, Guards, Interceptors
│ │ ├── Auth, Courses, Materials, Chat,Navbar, Alert, Loading
└── README.md