C#
0
70 commits
updated Jun 27, 2026
Nền tảng học tập thông minh hỗ trợ upload tài liệu, chunking tự động và embedding vector thời gian thực.
wwwroot/uploads và quản lý metadata (tiêu đề, kích thước, trạng thái).chunkSize=800, overlap=10%).?handler=Documents, ?handler=Chunks, ?handler=TriggerEmbedding, ?handler=Delete, ?handler=Download.| Thành phần | Mô tả |
|---|---|
| ASP.NET Core Razor Pages (.NET 8) | UI chính (SmartEdu.RazorWeb) |
| SmartEdu.Business | Business layer — DocumentService xử lý chunking, embedding, notifications |
| SmartEdu.DataAccess | EF Core — các entity Document, DocumentChunk, v.v. |
| SignalR | SubjectHub / DocumentHub — push tiến trình và log realtime |
| PdfPig | Trích xuất văn bản từ PDF |
| OpenXML SDK | Xử lý file DOCX |
| HttpClient | Gọi Hugging Face Inference API |
| Database | SQL Server / SQLite (tuỳ ConnectionString) |
| DI | IServiceCollection + scoped background tasks qua IServiceScopeFactory |
SmartEdu.RazorWeb/
├── Pages/Documents/
│ └── UploadDocument.cshtml(.cs) # UI upload & list, modal chunk review, client JS
├── wwwroot/uploads/ # Nơi lưu file upload
SmartEdu.Business/
└── Services/
└── DocumentService.cs # Chunking, embedding loop, notifications
SmartEdu.DataAccess/ # EF entities, migrations, repositories
1. Cấu hình connection string (xem phần User Secrets / appsettings).
2. Tạo migration (nếu cần):
dotnet ef migrations add InitialCreate \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
3. Áp dụng migration:
dotnet ef database update \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
Lưu ý: Khi chạy trong Visual Studio, chọn
SmartEdu.RazorWeblà Startup Project và dùng Package Manager Console hoặc CLI tương ứng.
Sử dụng Secret Manager (khuyến nghị cho môi trường dev):
# Di chuyển vào thư mục RazorWeb
cd SmartEdu.RazorWeb
# Khởi tạo secret manager
dotnet user-secrets init
# Thiết lập secrets
dotnet user-secrets set "HuggingFace:Token" "<YOUR_HUGGINGFACE_TOKEN>"
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "<your-connection-string>"
Tham chiếu trong app:
IConfiguration["HuggingFace:Token"]
⚠️ Không commit secrets lên repo. Trên production, dùng environment variables hoặc Secret Store của hosting.
git clone <repo-url>
cd SmartEdu.RazorWeb
# Thiết lập user-secrets như hướng dẫn trên
Đảm bảo DB có thể truy cập theo ConnectionStrings:DefaultConnection.
dotnet ef database update \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
dotnet run --project SmartEdu.RazorWeb
Hoặc mở solution trong Visual Studio, đặt SmartEdu.RazorWeb là Startup Project rồi nhấn F5.
Dùng account có quyền leader hoặc giảng viên (nếu đã seed dữ liệu).
Truy cập /Documents/UploadDocument, sau đó:
ℹ️ Nếu embed server (Hugging Face model) đang khởi động, server có thể trả
ServiceUnavailable— thông báo sẽ hiển thị; chờ vài giây rồi bấm lại.
Chỉnh sửa trong SmartEdu.Business/Services/DocumentService.cs:
ChunkText(text, chunkSize: 800, overlapFraction: 0.1)
chunkSize hoặc overlapFraction để điều chỉnh kích thước / độ chồng lấp.ChunkText bằng tokenizer / sentence splitter phù hợp trước khi gọi embedding.Task.Run với scope) — theo dõi log/exception để đảm bảo không crash.EmbeddingJson được lưu trong bảng DocumentChunks. Nếu vectors lớn, cân nhắc chuyển sang vector database chuyên dụng thay vì lưu trực tiếp trong SQL.C#
0
70 commits
updated Jun 27, 2026
Nền tảng học tập thông minh hỗ trợ upload tài liệu, chunking tự động và embedding vector thời gian thực.
wwwroot/uploads và quản lý metadata (tiêu đề, kích thước, trạng thái).chunkSize=800, overlap=10%).?handler=Documents, ?handler=Chunks, ?handler=TriggerEmbedding, ?handler=Delete, ?handler=Download.| Thành phần | Mô tả |
|---|---|
| ASP.NET Core Razor Pages (.NET 8) | UI chính (SmartEdu.RazorWeb) |
| SmartEdu.Business | Business layer — DocumentService xử lý chunking, embedding, notifications |
| SmartEdu.DataAccess | EF Core — các entity Document, DocumentChunk, v.v. |
| SignalR | SubjectHub / DocumentHub — push tiến trình và log realtime |
| PdfPig | Trích xuất văn bản từ PDF |
| OpenXML SDK | Xử lý file DOCX |
| HttpClient | Gọi Hugging Face Inference API |
| Database | SQL Server / SQLite (tuỳ ConnectionString) |
| DI | IServiceCollection + scoped background tasks qua IServiceScopeFactory |
SmartEdu.RazorWeb/
├── Pages/Documents/
│ └── UploadDocument.cshtml(.cs) # UI upload & list, modal chunk review, client JS
├── wwwroot/uploads/ # Nơi lưu file upload
SmartEdu.Business/
└── Services/
└── DocumentService.cs # Chunking, embedding loop, notifications
SmartEdu.DataAccess/ # EF entities, migrations, repositories
1. Cấu hình connection string (xem phần User Secrets / appsettings).
2. Tạo migration (nếu cần):
dotnet ef migrations add InitialCreate \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
3. Áp dụng migration:
dotnet ef database update \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
Lưu ý: Khi chạy trong Visual Studio, chọn
SmartEdu.RazorWeblà Startup Project và dùng Package Manager Console hoặc CLI tương ứng.
Sử dụng Secret Manager (khuyến nghị cho môi trường dev):
# Di chuyển vào thư mục RazorWeb
cd SmartEdu.RazorWeb
# Khởi tạo secret manager
dotnet user-secrets init
# Thiết lập secrets
dotnet user-secrets set "HuggingFace:Token" "<YOUR_HUGGINGFACE_TOKEN>"
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "<your-connection-string>"
Tham chiếu trong app:
IConfiguration["HuggingFace:Token"]
⚠️ Không commit secrets lên repo. Trên production, dùng environment variables hoặc Secret Store của hosting.
git clone <repo-url>
cd SmartEdu.RazorWeb
# Thiết lập user-secrets như hướng dẫn trên
Đảm bảo DB có thể truy cập theo ConnectionStrings:DefaultConnection.
dotnet ef database update \
--project SmartEdu.DataAccess \
--startup-project SmartEdu.RazorWeb
dotnet run --project SmartEdu.RazorWeb
Hoặc mở solution trong Visual Studio, đặt SmartEdu.RazorWeb là Startup Project rồi nhấn F5.
Dùng account có quyền leader hoặc giảng viên (nếu đã seed dữ liệu).
Truy cập /Documents/UploadDocument, sau đó:
ℹ️ Nếu embed server (Hugging Face model) đang khởi động, server có thể trả
ServiceUnavailable— thông báo sẽ hiển thị; chờ vài giây rồi bấm lại.
Chỉnh sửa trong SmartEdu.Business/Services/DocumentService.cs:
ChunkText(text, chunkSize: 800, overlapFraction: 0.1)
chunkSize hoặc overlapFraction để điều chỉnh kích thước / độ chồng lấp.ChunkText bằng tokenizer / sentence splitter phù hợp trước khi gọi embedding.Task.Run với scope) — theo dõi log/exception để đảm bảo không crash.EmbeddingJson được lưu trong bảng DocumentChunks. Nếu vectors lớn, cân nhắc chuyển sang vector database chuyên dụng thay vì lưu trực tiếp trong SQL.