Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Fetched from the repository for this visit.
🇻🇳 Tiếng Việt | 🇺🇸 English
Created by Lê Minh Hiếu — Trader turned Builder 🇻🇳
AI-powered legal assistant for Vietnamese businesses
An AI platform for legal research, contract review, and legal document drafting — all in a VSCode-style interface.
Landing Page — Hero, features, pricing
Dashboard — VSCode-style 3-panel layout
AI Contract Review — Risk analysis, highlights, recommendations
Contract Upload — Drag & drop, AI auto-analysis
The AI is now "Cursor for lawyers" — full autonomous document manipulation capabilities.
Legal AI can autonomously manage your documents and contracts:
"Liệt kê tất cả hợp đồng"
"Đọc hợp đồng thuê mặt bằng số 123"
"Sửa điều khoản phạt trong HĐ này cho đúng luật"
"Soạn NDA giữa công ty A và B, thời hạn 2 năm"
"So sánh bản cũ và bản mới của HĐ lao động"
"Review tất cả 5 hợp đồng trong thư mục Dự án X"
"Tạo thư mục 'Khách hàng ABC' và di chuyển 3 hợp đồng vào đó"
"Xem lịch sử chỉnh sửa của tài liệu này"
The AI can chain multiple tools together to complete complex tasks:
User: "Sửa điều khoản phạt trong HĐ ABC cho đúng luật"
AI:
1. read_document → Gets current content
2. search_law → Finds relevant penalty law (8% max per Commercial Law)
3. edit_document → Replaces old penalty clause with compliant version
4. document_history → Shows what changed
User: "Soạn NDA giữa công ty A và B, lưu vào thư mục Khách hàng A"
AI:
1. generate_document → Creates NDA from requirements
2. create_folder → Creates "Khách hàng A" folder (if doesn't exist)
3. write_document → Saves NDA to folder
list_documents — List all documents/contracts with search & filterread_document — Read full content or specific sectionswrite_document — Create new documents with metadata & tagsedit_document — Find & replace text, track changescompare_documents — Diff two documents (summary/detailed/clause-by-clause)create_folder — Create organizational folders for cases/projectsmove_document — Move documents between foldersdelete_document — Soft delete (recoverable for 30 days)generate_document — AI drafts legal documents from requirementsbatch_review — Review multiple documents for risks simultaneouslydocument_history — View full edit history and audit trailUpload contracts for instant AI-powered review:
Review a contract:
POST /v1/contracts/{contract_id}/review-ai
Get review results:
GET /v1/contracts/{contract_id}/review-ai
Response structure:
{
"review_id": "review_20250319_143000",
"contract_title": "Hợp đồng thuê mặt bằng",
"contract_type": "lease",
"parties": ["Công ty A", "Công ty B"],
"risk_score": 72,
"risk_level": "HIGH",
"summary": "Hợp đồng có 5 điều khoản rủi ro cao...",
"clauses": [
{
"clause_number": "Điều 5",
"title": "Phạt vi phạm",
"content": "Bên B phải trả phạt 20%...",
"risk_level": "CRITICAL",
"risk_score": 95,
"issue": "Mức phạt 20% vượt quá quy định",
"law_reference": "Điều 301 Luật TM 2005: phạt ≤ 8%",
"suggestion": "Giảm mức phạt xuống ≤ 8%"
}
],
"missing_clauses": [
{
"clause": "Force Majeure",
"importance": "HIGH",
"suggestion": "Thêm Điều 156 BLDS 2015"
}
],
"compliance": {
"civil_code": {"status": "PARTIAL", "issues": 2},
"commercial_law": {"status": "VIOLATION", "issues": 1},
"labor_law": {"status": "N/A"}
},
"recommendations": [
{
"priority": 1,
"action": "Sửa Điều 5: giảm phạt 20% → 8%",
"reason": "Vi phạm Điều 301 Luật TM 2005"
}
]
}
Self-hosted deployments include a full Platform Super Admin panel for system administration:
Navigate to /platform-admin (requires superadmin role)
The Platform Admin panel provides complete control over your self-hosted Legal AI deployment:
# Navigate to platform admin
https://your-domain.com/platform-admin
# Available stats:
- Total companies, users, documents, contracts
- Vietnamese law database size (60K+ documents, 117K+ chunks)
- Daily/monthly query volumes
- Active users, storage usage
- Usage trends (30-day charts)
- Revenue estimates by plan
# Management capabilities:
- Create/edit/deactivate companies
- Change subscription plans (trial → starter → pro → enterprise)
- Adjust quota limits per company
- Reset user passwords, change roles
- View company-specific usage history
- Configure system-wide settings
- Track LLM costs per company
- Full audit trail of admin actions
Legal AI Agent can automatically crawl Vietnamese legal websites to build and update your document database.
.env:
CRAWLKIT_API_KEY=your_api_key_here
Via API:
POST /crawler/crawl
{
"url": "https://thuvienphapluat.vn/van-ban/..."
}
Via AI Chat:
"Crawl văn bản tại https://thuvienphapluat.vn/van-ban/123"
Other endpoints:
GET /crawler/sources — List supported legal sourcesPOST /crawler/discover — Discover legal document links from a pagePOST /crawler/batch — Batch crawl multiple URLsGET /crawler/status — Check CrawlKit configurationGet your free CrawlKit API key →
git clone https://github.com/Paparusi/legal-ai-agent.git
cd legal-ai-agent
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your credentials
# Run migrations
python scripts/run_migration.py
# Load Vietnamese law data (optional, ~40K documents)
python scripts/load_law_data.py
python scripts/index_chunks.py
uvicorn src.api.main:app --host 0.0.0.0 --port 8080
Open http://localhost:8080/static/app.html
# 1. Clone
git clone https://github.com/Paparusi/legal-ai-agent.git
cd legal-ai-agent
# 2. Configure
cp .env.example .env
nano .env # Add your ANTHROPIC_API_KEY
# 3. Start (PostgreSQL + App)
docker compose up -d
# 4. Open
# http://localhost:8080/static/app.html
This starts PostgreSQL 15 (with pgvector) and the FastAPI app automatically.
⚠️ Note: The database schema is created automatically on first startup, but law documents are empty by default. To populate the legal database:
# Option 1: Crawl Vietnamese legal websites (recommended)
docker compose exec app python scripts/crawl_thuvien.py
# Option 2: Load from backup (if you have one)
docker compose exec app python scripts/load_law_data.py
Without legal data, the AI can still review/draft contracts, but legal search won't work.
Works on any Docker-capable device — NAS, Raspberry Pi, VPS, or local server.
# SSH into your NAS/server
git clone https://github.com/Paparusi/legal-ai-agent.git
cd legal-ai-agent
cp .env.example .env
# Edit .env — only ANTHROPIC_API_KEY is required
nano .env
# Start
docker compose up -d
# Access from any device on your network:
# http://NAS_IP:8080/static/app.html
System requirements:
Ports: 8080 (web UI), 5432 (PostgreSQL, optional external access)
Persistent data: PostgreSQL data is stored in a Docker volume (pgdata). Your data survives container restarts and updates.
Update to latest version:
git pull
docker compose build
docker compose up -d
├── src/
│ ├── api/
│ │ ├── main.py # FastAPI app + all routes
│ │ ├── routes/ # Route modules
│ │ │ ├── auth.py # Login, register, API keys
│ │ │ ├── contracts.py # Contract CRUD
│ │ │ ├── documents.py # Document upload
│ │ │ ├── chats.py # Chat history
│ │ │ ├── company.py # Company management
│ │ │ └── admin.py # Admin dashboard
│ │ └── middleware/
│ │ ├── auth.py # API key verification
│ │ └── logging.py # Usage logging
│ └── agents/
│ ├── legal_agent.py # AI agent with 11 tools
│ └── company_memory.py # Company context memory
├── static/
│ ├── app.html # Main SPA (~5600 lines)
│ ├── index.html # Landing page
│ ├── admin.html # Admin dashboard
│ └── manifest.json # PWA manifest
├── scripts/
│ ├── load_law_data.py # Import law documents
│ ├── index_chunks.py # Chunk & index for search
│ └── run_migration.py # DB migrations
├── docker-compose.yml # One-command deploy
├── Dockerfile # Container build
├── .env.example # Environment template
├── requirements.txt
└── Procfile # Railway/Heroku deploy
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/auth/register | Register |
| POST | /v1/auth/login | Login |
| POST | /v1/auth/api-key | Generate API key |
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/legal/ask | Ask AI agent |
| POST | /v1/legal/ask-stream | Ask AI (SSE streaming) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/contracts | List contracts |
| POST | /v1/contracts/upload | Upload contract |
| POST | /v1/contracts/batch-upload | Batch upload contracts |
| POST | /v1/contracts/{id}/review | AI contract review |
| POST | /v1/contracts/{id}/report | Export Word report |
| POST | /v1/contracts/{id}/diff | Compare 2 contracts |
| GET | /v1/contracts/{id}/suggestions | AI suggestions |
| POST | /v1/contracts/bulk-analyze | Bulk analysis |
| GET | /v1/contracts/calendar | Contract calendar |
| GET | /v1/contracts/risk-overview | Risk overview |
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/legal/search | Search laws |
| GET | /v1/search/all | Search everything |
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/analytics | Usage statistics |
| GET | /v1/audit-log | Activity log |
| GET | /v1/insights | AI insights |
Bring Your Own LLM — Connect your preferred AI provider with API Key or OAuth:
| Provider | Models | Auth Methods | Context |
|---|---|---|---|
| 🔵 Anthropic Claude | Sonnet 4, Opus 4, Haiku 3.5 | API Key | 200K tokens |
| 🟢 OpenAI GPT | GPT-4o, GPT-4o Mini, O1 | API Key, OAuth | 128-200K tokens |
| 🔴 Google Gemini | Gemini 2.5 Pro/Flash, 2.0 Flash | API Key, OAuth | 1M tokens |
| ⚫ Custom/Local | Ollama, vLLM, LM Studio | API Key | Variable |
POST /v1/llm/configure with your API key| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/llm/providers | List all providers + models |
| POST | /v1/llm/configure | Set API key (manual) |
| POST | /v1/llm/test | Test current connection |
| GET | /v1/llm/status | Current provider status |
| GET | /v1/llm/models | List models |
| POST | /v1/llm/model | Set model |
| GET | /v1/llm/oauth/{provider}/authorize | Start OAuth flow |
| GET | /v1/llm/oauth/callback | OAuth callback |
| POST | /v1/llm/oauth/{provider}/refresh | Refresh OAuth token |
ANTHROPIC_API_KEY env var if not configured# Encryption key for API keys (generate with: python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())")
LLM_ENCRYPTION_KEY=your-32-byte-key
# OAuth credentials (optional, for OAuth flow)
OPENAI_CLIENT_ID=your-openai-client-id
OPENAI_CLIENT_SECRET=your-openai-client-secret
GEMINI_CLIENT_ID=your-google-client-id
GEMINI_CLIENT_SECRET=your-google-client-secret
OAUTH_REDIRECT_URI=http://localhost:8080/v1/llm/oauth/callback
# Default fallback (if no provider configured)
ANTHROPIC_API_KEY=your-anthropic-key
| Tier | USD | VND | Queries/day | Contracts | Key Features |
|---|---|---|---|---|---|
| Free | $0 | 0₫ | 10 | 1 | Basic search, 2 templates |
| Starter | $29/mo | 725K₫ | 100 | 20 | AI review, all templates |
| Professional | $99/mo | 2.5M₫ | 500 | Unlimited | API, custom LLM, analytics |
| Enterprise | $499/mo | 12.5M₫ | Unlimited | Unlimited | SLA 99.9%, dedicated support |
Discounts: Annual -20% · Startups -30% · NGOs -50%
GET /v1/pricing # Get pricing tiers
8 ready-to-use Vietnamese contract templates:
| Template | Law Reference |
|---|---|
| Hợp đồng lao động | BLLĐ 2019 |
| Hợp đồng thuê mặt bằng | BLDS 2015 |
| Hợp đồng mua bán | Luật TM 2005 |
| Hợp đồng dịch vụ | BLDS 2015 |
| Hợp tác kinh doanh (BCC) | Luật ĐT 2020 |
| NDA / Bảo mật | Luật SHTT 2005 |
| Hợp đồng vay | BLDS 2015 |
| Hợp đồng đại lý | Luật TM 2005 |
All templates include {{fillable_fields}}, legal notes, and specific law article references.
GET /v1/templates # List all templates
GET /v1/templates/{id} # Get template content
POST /v1/templates/generate # AI-fill template
Support Vietnamese and English:
# Vietnamese (default)
curl -H "Accept-Language: vi" /v1/pricing
# English
curl -H "Accept-Language: en" /v1/pricing
The search engine indexes Vietnamese legal documents including:
See CONTRIBUTING.md for guidelines. Areas that need help:
MIT — free to use, including commercially.
This is an assistive tool and does not replace professional legal advice. Always consult a qualified lawyer for important legal decisions.
Love this project? Become a sponsor! 🙏
Your support helps maintain and expand this open-source Vietnamese legal AI platform. By sponsoring, you're supporting:
| Tier | Monthly | Benefits |
|---|---|---|
| ☕ Coffee | $5 | Your name in sponsors list |
| 🥉 Bronze | $25 | Logo in README + priority issue response (24h) |
| 🥈 Silver | $100 | Direct support channel + feature request priority |
| 🥇 Gold | $500 | Prominent logo + custom features + quarterly calls |
| 🏢 Enterprise | Custom | SLA, white-label, custom development, private hosting |
👉 View all tiers & sponsor now
For Enterprise inquiries: GitHub Issues or @gau_trader on Telegram
No sponsors yet — be the first! Your logo could be here. 🚀
See .github/SPONSORS.md for full details.
Made with ❤️ by Lê Minh Hiếu 🇻🇳
GitHub checked 63h ago - refresh overdue. Recently viewed repositories target hourly refresh.