docs: thêm Gitea + Infrastructure vào kiến trúc hệ thống
This commit is contained in:
+62
-10
@@ -8,15 +8,24 @@
|
||||
## 1. Tổng quan kiến trúc
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ TRADING PORTAL │
|
||||
├─────────────────┬─────────────────┬─────────────────────┤
|
||||
│ Frontend │ Backend API │ Backend Scheduler │
|
||||
│ (React/TS) │ (FastAPI) │ (Python async) │
|
||||
│ Port 3000 │ Port 8001 │ No HTTP port │
|
||||
├─────────────────┴─────────────────┴─────────────────────┤
|
||||
│ PostgreSQL 16 │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ TRADING PORTAL │
|
||||
├───────────────────┬───────────────────┬──────────────────────────┤
|
||||
│ Frontend │ Backend API │ Backend Scheduler │
|
||||
│ (React/TS) │ (FastAPI) │ (Python async) │
|
||||
│ Port 3000 │ Port 8001 │ No HTTP port │
|
||||
├───────────────────┴───────────────────┴──────────────────────────┤
|
||||
│ PostgreSQL 16 │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ INFRASTRUCTURE │
|
||||
├────────────┬──────────────┬─────────────────┬────────────────────┤
|
||||
│ nginx_proxy│ certbot_ssl │ Gitea (Git) │ Hermes Agent │
|
||||
│ :80/:443 │ auto-renew │ :8929 / SSH:2222│ host network │
|
||||
│ reverse │ Let's Encrypt│ git.dangloica │ AI assistant │
|
||||
└────────────┴──────────────┴─────────────────┴────────────────────┘
|
||||
```
|
||||
|
||||
### Services
|
||||
@@ -27,6 +36,47 @@
|
||||
| `backend-api` | FastAPI | 1G / 2 CPU | REST API, WebSocket, auth |
|
||||
| `backend-scheduler` | Python async | 2G / 3 CPU | Fetch candle, phân tích tín hiệu, quản lý trade |
|
||||
| `db` | PostgreSQL 16 | 2G | Lưu trữ toàn bộ dữ liệu |
|
||||
| `nginx_proxy` | nginx:1.27-alpine | — | Reverse proxy SSL cho tất cả domain |
|
||||
| `certbot_ssl` | certbot/certbot | — | Auto-renew Let's Encrypt mỗi 12h |
|
||||
| `gitea` | gitea/gitea:latest | ~300MB | Git server tại git.dangloica.org |
|
||||
| `hermes` | hermes-agent | — | AI assistant (Telegram, API, automation) |
|
||||
|
||||
### Domains & SSL
|
||||
|
||||
| Domain | SSL Cert | Backend | Ghi chú |
|
||||
|--------|----------|---------|---------|
|
||||
| `trading.dangloica.org` | Let's Encrypt (DNS-01) | frontend:3000 | Trading portal chính |
|
||||
| `git.dangloica.org` | Let's Encrypt (DNS-01) | gitea:8929 | Git server riêng |
|
||||
| `hermes.dangloica.org` | Let's Encrypt | hermes:9119 | Dashboard AI |
|
||||
|
||||
> ⚠️ **Port 80 bị firewall cloud chặn** → HTTP challenge không dùng được.
|
||||
> Cert mới phải dùng **DNS-01 challenge** + manual auth hook (TXT record trên PAVietnam DNS).
|
||||
|
||||
### Git Workflow
|
||||
|
||||
```
|
||||
Team push code → Gitea (git.dangloica.org) → Hermes pull + build + deploy
|
||||
```
|
||||
|
||||
**Repo:** `hanlap/trading-portal` (Private 🔒) — `https://git.dangloica.org/hanlap/trading-portal`
|
||||
|
||||
**Deploy command:**
|
||||
```bash
|
||||
cd /opt/data/trading-portal && git pull origin master
|
||||
docker compose build backend-api backend-scheduler frontend
|
||||
docker compose up -d backend-api backend-scheduler frontend
|
||||
```
|
||||
|
||||
**Gitea users:**
|
||||
| User | Role | Password |
|
||||
|------|------|----------|
|
||||
| `tien` | Admin | *riêng* |
|
||||
| `hanlap` | Owner repo | `***REMOVED***` |
|
||||
| `nguyendao` | Write | `***REMOVED***` |
|
||||
| `tulinh` | Write | `***REMOVED***` |
|
||||
| `namcunguyen` | Write | `***REMOVED***` |
|
||||
|
||||
**Nginx config:** `/opt/ai-agent/nginx/conf.d/hermes.conf` (bind mount vào nginx_proxy)
|
||||
|
||||
### Nguyên tắc thiết kế
|
||||
|
||||
@@ -296,7 +346,9 @@ Script `/opt/data/scripts/health_check.py`:
|
||||
|
||||
| Date | Change | Author |
|
||||
|------|--------|--------|
|
||||
| 2026-07-02 | **Audit toàn hệ thống**: fix 2 critical (real_trades PnL NULL + stale close) + 6 medium (API 404/405, Health tab, sessions, mobile nav, DB vacuum) | Hermes |
|
||||
| 2026-07-03 | **Gitea setup**: git.dangloica.org, SSL DNS-01, 5 users, repo trading-portal | Hermes |
|
||||
| 2026-07-03 | **Infrastructure doc**: thêm nginx_proxy, certbot, Gitea, Hermes vào kiến trúc | Hermes |
|
||||
| 2026-07-02 | **Audit toàn hệ thống**: fix 2 critical (real_trades PnL NULL + stale close) + 6 medium | Hermes |
|
||||
| 2026-07-02 | **Tách Signal ↔ Trade**: tạo `trade_executor.py`, signal chỉ để monitoring | Hermes |
|
||||
| 2026-07-02 | **PnL filter**: `ABS(pnl_percent) < 100` trong tất cả queries | Hermes |
|
||||
| 2026-07-02 | **Win-rate decay**: exponential λ=0.05, MIN_TRADES=15 | Hermes |
|
||||
|
||||
Reference in New Issue
Block a user