Một hệ thống tìm kiếm tài liệu . Dự án này showcase thực hành DevOps, kiến trúc microservices, và tích hợp AI/ML
- 🏗️ Microservices: Mẫu provider modular với dependency injection
- ☁️ Cloud-Native: Tích hợp AWS S3 + SQS với LocalStack (Giả lập AWS) cho phát triển local
- 🤖 AI/ML: Tìm kiếm ngữ nghĩa sử dụng BGE-M3 embeddings và vector databases Qdrant
- � RAG System: Chat với tài liệu sử dụng Ollama models và retrieval augmented generation
- �🔧 DevOps: Multi-stage Docker builds, quản lý cấu hình, giám sát Healths
- 📊 Production: Xử lý async, xử lý lỗi, logging, và mẫu khả năng mở rộng
Dự án này mô phỏng hệ thống quản lý tài liệu doanh nghiệp thực tế:
- Backend services gửi yêu cầu xử lý tài liệu qua AWS SQS
- Tài liệu được truy xuất từ AWS S3 sử dụng secure file keys
- Tìm kiếm ngữ nghĩa được hỗ trợ AI cho phép khám phá tài liệu thông minh
- Kiến trúc có thể mở rộng
Dự án này tái tạo pipeline xử lý tài liệu doanh nghiệp thực tế:
graph LR
A[Backend Services] --> B[LocalStack S3]
B --> C[AWS SQS Queue]
C --> D[Document Processor]
D --> E[AI Processing]
E --> F[Vector Database]
F --> G[Search API]
G --> H[End Users]
Luồng Kỹ Thuật:
- 🔄 Message Queue: Backend services gửi metadata tài liệu qua SQS
- 📄 Truy Xuất Tài Liệu: Hệ thống lấy tài liệu từ S3 sử dụng secure file keys
- 🤖 Xử Lý AI: Embeddings đa ngôn ngữ được tạo bằng BGE-M3 model
- 🗄️ Lưu Trữ Vector: Tài liệu được đánh index trong Qdrant cho similarity search
- 🔍 Search Engine: RESTful API cung cấp khả năng tìm kiếm ngữ nghĩa
- 💬 RAG Chat: Chat với tài liệu sử dụng Ollama models (qwen2.5:1.5b)
- Docker & Docker Compose đã cài đặt
- Tối thiểu 4GB RAM có sẵn (khuyến nghị 8GB)
- Port 8001 có sẵn
- Kết nối Internet (để tải Qdrant Cloud & models)
- Tùy chọn: LocalStack cho mô phỏng S3/SQS
# Clone repository
git clone https://github.com/Bui-Tung-Hung/The-Documents-Manager.git
cd The-Documents-Manager/docker
# Thiết lập environment variables
cp .env.example .env
# Chỉnh sửa .env với cấu hình của bạn
# Chạy với Docker Compose
docker-compose up -d
# Kiểm tra health
curl http://localhost:8001/healthMô phỏng workflow doanh nghiệp đầy đủ với AWS services:
# 1. Khởi động LocalStack cho mô phỏng AWS
docker run --rm -d \
-p 4566:4566 \
-e SERVICES=s3,sqs \
localstack/localstack
# 2. Thiết lập môi trường local
export QDRANT_URL=http://localhost:6333
export AWS_ENDPOINT_URL=http://localhost:4566
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
# 3. Chạy với local Qdrant
docker-compose --profile local up -d
# 4. Test enterprise workflow
python scripts/upload_to_s3.py # Upload documents
python scripts/send.py # Send SQS messages
python scripts/receive.py # Process documents# Clone và setup
git clone https://github.com/Bui-Tung-Hung/The-Documents-Manager.git
cd The-Documents-Manager/The-Document-Manager-v2
# Tạo virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# Cài đặt dependencies
pip install -r requirements.txt
# Cấu hình environment
cp .env.example .env
# Chỉnh sửa .env với settings của bạn
# Kiểm tra cấu hình
python tools/check_config.py
# Chạy API
python -m app.main# Health check
curl http://localhost:8001/health
# Tìm kiếm tài liệu (mô phỏng end-user query)
curl -X POST "http://localhost:8001/search-files" \
-H "Content-Type: application/json" \
-d '{"query": "machine learning"}'
# Chat với tài liệu (RAG - Retrieval Augmented Generation)
curl -X POST "http://localhost:8001/chat-with-files" \
-H "Content-Type: application/json" \
-d '{
"file_ids": ["doc_123", "doc_456"],
"message": "Tóm tắt nội dung chính",
"max_chunks": 5
}'
# Tài liệu API (Swagger UI cấp doanh nghiệp)
open http://localhost:8001/docsHệ thống yêu cầu lựa chọn cấu hình thủ công. Nó KHÔNG tự động chuyển đổi giữa các môi trường.
Use Case: Testing, development, công việc offline, học kiến trúc microservices
Cấu hình: config/config.dev.yaml
# Khởi động local Qdrant với full stack
docker-compose --profile local up -d
# Chạy với development config
CONFIG_PATH=config/config.dev.yaml python -m app.mainUse Case: Triển khai production, cộng tác team, kiến trúc có thể mở rộng
Cấu hình: config/config.prod.yaml + environment variables
# Thiết lập production credentials
export QDRANT_URL=https://your-cluster.qdrant.tech
export QDRANT_API_KEY=your_secure_api_key
# Cấu hình Chat Models (Ollama)
export CHAT_PROVIDER=ollama
export CHAT_MODEL=qwen2.5:1.5b
export CHAT_BASE_URL=http://localhost:11434
export CHAT_MAX_CHUNKS=5
# Chạy với production config
CONFIG_PATH=config/config.prod.yaml python -m app.mainLuôn xác minh cấu hình của bạn trước khi triển khai:
# Kiểm tra cấu hình hiện tại
python tools/check_config.py
# Test cấu hình cụ thể
python tools/check_config.py --config config/config.prod.yamlhttp://localhost:8001
GET /healthPOST /search-files
Content-Type: application/json
{
"query": "machine learning algorithms"
}POST /chat-with-files
Content-Type: application/json
{
"file_ids": ["doc_123", "doc_456"],
"message": "Tóm tắt nội dung chính của các tài liệu này",
"max_chunks": 5
}Response:
{
"response": "Dựa trên các tài liệu được cung cấp...",
"source_chunks": [
{
"file_id": "doc_123",
"content": "Nội dung chunk liên quan...",
"score": 0.85
}
],
"total_chunks": 3
}POST /index-documents
Content-Type: application/json
{
"documents": [
{
"content": "Document content here...",
"file_id": "doc_456",
"metadata": {"title": "My Document"}
}
]
}GET /docsDự án này thể hiện các mẫu doanh nghiệp thực tế với RAG (Retrieval Augmented Generation):
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Backend │ │ Message │ │ Document │
│ Services │───►│ Queue │───►│ Processor │
│ │ │ (SQS) │ │ │
└─────────────────┘ └──────────────┘ └─────────────────┘
│
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Search API │◄───│ Vector DB │◄───│ File Storage │
│ (FastAPI) │ │ (Qdrant) │ │ (S3) │
│ │ │ │ │ │
│ Chat API │◄───│ Chat Model │ │ │
│ (RAG) │ │ (Ollama) │ │ │
└─────────────────┘ └──────────────┘ └─────────────────┘
Kiến trúc linh hoạt cho phép dễ dàng thay đổi công nghệ:
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ FastAPI │ │ Embedding │ │ Vector DB │
│ Application │◄──►│ Provider │◄──►│ Provider │
│ │ │ │ │ │
│ │ ┌──────────────┐ │ │
│ │◄──►│ Chat │ │ │
│ │ │ Provider │ │ │
└─────────────────┘ └──────────────┘ └─────────────────┘
Vector Databases:
- ✅ Qdrant (Cloud & Self-hosted)
- 🔄 Chroma (Sắp có)
- 🔄 Pinecone (Sắp có)
- 🔄 Weaviate (Sắp có)
- 🔄 Milvus (Sắp có)
Embedding Models:
- ✅ Ollama (BGE-M3, khác)
- 🔄 OpenAI (Sắp có)
- 🔄 Hugging Face (Sắp có)
- 🔄 Azure OpenAI (Sắp có)
Chat Models (RAG):
- ✅ Ollama (qwen2.5:1.5b, llama3, khác)
- 🔄 OpenAI GPT (Sắp có)
- 🔄 Azure OpenAI (Sắp có)
- 🔄 Anthropic Claude (Sắp có)
# Terminal 1: Khởi động LocalStack (AWS simulation)
docker run --rm -p 4566:4566 -e SERVICES=s3,sqs localstack/localstack
# Terminal 2: Upload documents to S3
python scripts/upload_to_s3.py
# Terminal 3: Send processing messages
python scripts/send.py
# Terminal 4: Process documents from queue
python scripts/receive.py📧 Contact: Made with ❤️ by Bui-Tung-Hung - Showcasing enterprise software development skills