# hoanglhse173120/prn222 architecture

> Architecture diagram of the GitHub repository hoanglhse173120/prn222, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hoanglhse173120/prn222
- Repository: https://github.com/hoanglhse173120/prn222

## Overview

This is an ASP.NET Core RAG learning chatbot with a Python embedding service. Its main workflow is document upload and indexing, followed by real-time chat: questions are embedded, compared with indexed document chunks, and sent with relevant context to an LLM; responses can include document sources. The repository also exposes authentication, subject/document administration, subscriptions and payments, and benchmark/statistics capabilities. The graph reflects documented capabilities where relevant, but several page and service implementations were not sampled, so uncertain internal calls are omitted.

Main entry points: [`ServiceLayer/Services/DocumentService.cs`](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/DocumentService.cs) (Document service), [`ServiceLayer/Services/RagService.cs`](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/RagService.cs) (RAG retrieval), [`ServiceLayer/Services/ChatService.cs`](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/ChatService.cs) (Chat service), [`DataAccessLayer/Repositories/DocumentRepository.cs`](https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Repositories/DocumentRepository.cs) (Document repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interaction"]
  node_chat_ui["Chat pages<br/>[Index.cshtml.cs]"]
  node_chat_hub["ChatHub<br/>[ChatHub.cs]"]
  node_chat_service["Chat service<br/>[ChatService.cs]"]
  node_identity["Identity login<br/>[Login.cshtml.cs]"]
end

subgraph group_content["Content ingestion"]
  node_document_pages["Document pages<br/>[Upload.cshtml.cs]"]
  node_document_service["Document service<br/>[DocumentService.cs]"]
  node_text_extractor["Text extraction"]
  node_chunking["Chunking<br/>[ChunkingService.cs]"]
  node_embedding["Embedding API<br/>[main.py]"]
end

subgraph group_rag["RAG answering"]
  node_rag_service["RAG retrieval<br/>[RagService.cs]"]
  node_llm["Groq LLM"]
end

subgraph group_data["Persistence"]
  node_doc_repo["Document repository"]
  node_session_repo["Chat session repository"]
  node_db[("SQL Server")]
end

subgraph group_operations["Administration"]
  node_subjects["Subject management<br/>[Index.cshtml.cs]"]
  node_pricing["Packages and pricing<br/>[Index.cshtml.cs]"]
  node_payments["Payment service<br/>[PaymentService.cs]"]
  node_benchmark["Benchmark service"]
  node_statistics["Admin statistics"]
end

node_learner(("Learner"))
node_teacher(("Teacher"))
node_admin(("Admin"))
node_vnpay["VNPAY"]

node_learner -->|"asks questions"| node_chat_ui
node_chat_ui -->|"starts chat"| node_chat_hub
node_chat_hub -->|"dispatches chat"| node_chat_service
node_chat_service -->|"requests answer"| node_rag_service
node_rag_service -->|"embeds query"| node_embedding
node_rag_service -->|"loads chunks"| node_doc_repo
node_rag_service -->|"sends context"| node_llm
node_chat_service -->|"persists sessions"| node_session_repo
node_teacher -->|"uploads documents"| node_document_pages
node_document_pages -->|"submits file"| node_document_service
node_document_service -->|"extracts text"| node_text_extractor
node_document_service -->|"chunks text"| node_chunking
node_document_service -->|"embeds chunks"| node_embedding
node_document_service -->|"stores document"| node_doc_repo
node_doc_repo -->|"reads and writes"| node_db
node_session_repo -->|"reads and writes"| node_db
node_learner -->|"signs in"| node_identity
node_teacher -->|"manages subjects"| node_subjects
node_admin -->|"views statistics"| node_statistics
node_admin -->|"runs benchmarks"| node_benchmark
node_learner -->|"chooses package"| node_pricing
node_pricing -->|"starts payment"| node_payments
node_payments -.->|"initiates payment"| node_vnpay
node_admin -->|"manages packages"| node_pricing

click node_chat_ui "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Chat/Index.cshtml.cs"
click node_chat_hub "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Hubs/ChatHub.cs"
click node_chat_service "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/ChatService.cs"
click node_identity "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Areas/Identity/Pages/Account/Login.cshtml.cs"
click node_document_pages "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Document/Upload.cshtml.cs"
click node_document_service "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/DocumentService.cs"
click node_text_extractor "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/TextExtractorService.cs"
click node_chunking "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/ChunkingService.cs"
click node_embedding "https://github.com/hoanglhse173120/prn222/blob/main/PythonAIService/main.py"
click node_rag_service "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/RagService.cs"
click node_subjects "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Subject/Index.cshtml.cs"
click node_pricing "https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Pricing/Index.cshtml.cs"
click node_payments "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/PaymentService.cs"
click node_benchmark "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/BenchmarkService.cs"
click node_statistics "https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/StatisticService.cs"
click node_doc_repo "https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Repositories/DocumentRepository.cs"
click node_session_repo "https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Repositories/ChatSessionRepository.cs"
click node_db "https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Context/ChatbotDbContext.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat_ui,node_chat_hub,node_chat_service,node_identity toneBlue
class node_document_pages,node_document_service,node_text_extractor,node_chunking,node_embedding toneAmber
class node_rag_service,node_llm toneMint
class node_doc_repo,node_session_repo,node_db toneRose
class node_subjects,node_pricing,node_payments,node_benchmark,node_statistics,node_learner,node_teacher,node_admin,node_vnpay toneIndigo
```

## Components

### Web interaction

- [Chat pages](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Chat/Index.cshtml.cs): `PresentationLayer/Pages/Chat/Index.cshtml.cs`
- [ChatHub](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Hubs/ChatHub.cs): `PresentationLayer/Hubs/ChatHub.cs`
- [Chat service](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/ChatService.cs): `ServiceLayer/Services/ChatService.cs`
- [Identity login](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Areas/Identity/Pages/Account/Login.cshtml.cs): `PresentationLayer/Areas/Identity/Pages/Account/Login.cshtml.cs`

### Content ingestion

- [Document pages](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Document/Upload.cshtml.cs): `PresentationLayer/Pages/Document/Upload.cshtml.cs`
- [Document service](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/DocumentService.cs): `ServiceLayer/Services/DocumentService.cs`
- [Text extraction](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/TextExtractorService.cs): `ServiceLayer/Services/TextExtractorService.cs`
- [Chunking](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/ChunkingService.cs): `ServiceLayer/Services/ChunkingService.cs`
- [Embedding API](https://github.com/hoanglhse173120/prn222/blob/main/PythonAIService/main.py): `PythonAIService/main.py`

### RAG answering

- [RAG retrieval](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/RagService.cs): `ServiceLayer/Services/RagService.cs`
- **Groq LLM**

### Persistence

- [Document repository](https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Repositories/DocumentRepository.cs): `DataAccessLayer/Repositories/DocumentRepository.cs`
- [Chat session repository](https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Repositories/ChatSessionRepository.cs): `DataAccessLayer/Repositories/ChatSessionRepository.cs`
- [SQL Server](https://github.com/hoanglhse173120/prn222/blob/main/DataAccessLayer/Context/ChatbotDbContext.cs): `DataAccessLayer/Context/ChatbotDbContext.cs`

### Administration

- [Subject management](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Subject/Index.cshtml.cs): `PresentationLayer/Pages/Subject/Index.cshtml.cs`
- [Packages and pricing](https://github.com/hoanglhse173120/prn222/blob/main/PresentationLayer/Pages/Pricing/Index.cshtml.cs): `PresentationLayer/Pages/Pricing/Index.cshtml.cs`
- [Payment service](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/PaymentService.cs): `ServiceLayer/Services/PaymentService.cs`
- [Benchmark service](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/BenchmarkService.cs): `ServiceLayer/Services/BenchmarkService.cs`
- [Admin statistics](https://github.com/hoanglhse173120/prn222/blob/main/ServiceLayer/Services/StatisticService.cs): `ServiceLayer/Services/StatisticService.cs`

### Other components

- **Learner**
- **Teacher**
- **Admin**
- **VNPAY**

## Connections

- Learner → Chat pages: asks questions
- Chat pages → ChatHub: starts chat
- ChatHub → Chat service: dispatches chat
- Chat service → RAG retrieval: requests answer
- RAG retrieval → Embedding API: embeds query
- RAG retrieval → Document repository: loads chunks
- RAG retrieval → Groq LLM: sends context
- Chat service → Chat session repository: persists sessions
- Teacher → Document pages: uploads documents
- Document pages → Document service: submits file
- Document service → Text extraction: extracts text
- Document service → Chunking: chunks text
- Document service → Embedding API: embeds chunks
- Document service → Document repository: stores document
- Document repository → SQL Server: reads and writes
- Chat session repository → SQL Server: reads and writes
- Learner → Identity login: signs in
- Teacher → Subject management: manages subjects
- Admin → Admin statistics: views statistics
- Admin → Benchmark service: runs benchmarks
- Learner → Packages and pricing: chooses package
- Packages and pricing → Payment service: starts payment
- Payment service → VNPAY: initiates payment
- Admin → Packages and pricing: manages packages
