Architecture
System Architecture Overview
graph TD
Users["Users<br/><small>Web Browser — Chrome / Edge</small>"]
Nginx["Reverse Proxy — Nginx<br/><small>SSL Termination · Static Files</small>"]
FE["Frontend<br/><small>SvelteKit · Port 5180</small>"]
BE["Backend<br/><small>Python FastAPI · Port 8080</small>"]
DB["PostgreSQL + pgvector"]
AI["AI Model APIs"]
Users -->|HTTPS| Nginx
Nginx --> FE
Nginx --> BE
BE --> DB
BE --> AI
subgraph Frontend
FE
FE_detail["UI/UX · i18n TH/EN · Responsive"]
end
subgraph Backend
BE
BE_detail["REST API · Auth/JWT<br/>RAG Pipeline · Quota Engine<br/>Audit Logger"]
end
subgraph Data
DB
DB_detail["Users · Chats · Knowledge<br/>Audit Log · Quota"]
end
subgraph External
AI
AI_detail["OpenAI · Google Gemini<br/>Anthropic Claude · OpenRouter<br/>Ollama — Local"]
end
style Users fill:#e3f2fd,stroke:#1565c0,color:#0d47a1
style Nginx fill:#fff3e0,stroke:#e65100,color:#bf360c
style FE fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
style BE fill:#fce4ec,stroke:#c62828,color:#b71c1c
style DB fill:#f3e5f5,stroke:#6a1b9a,color:#4a148c
style AI fill:#e0f7fa,stroke:#00695c,color:#004d40
style FE_detail fill:none,stroke:none
style BE_detail fill:none,stroke:none
style DB_detail fill:none,stroke:none
style AI_detail fill:none,stroke:none
Technology Stack
| Layer |
Technology |
Version |
| Frontend |
SvelteKit + TailwindCSS |
Svelte 4.x |
| Backend |
Python FastAPI |
Python 3.11+ |
| Database |
PostgreSQL + pgvector |
PostgreSQL 15+ |
| Vector DB |
pgvector (extension) |
0.7+ |
| Container |
Docker + Docker Compose |
24.0+ |
| Reverse Proxy |
Nginx |
1.24+ |
| Auth |
JWT (PyJWT) + bcrypt |
|
Database Schema (Core Tables)
| Table |
Description |
user |
User data (name, email, role, profile) |
auth |
Authentication data (password hash) |
chat |
Conversations (title, history, user_id) |
chat_message |
Messages in conversations (content, model, tokens) |
group |
User groups (name, description, permissions) |
group_member |
Group membership |
knowledge |
Knowledge Bases (name, description) |
file |
Uploaded files (metadata, storage path) |
quota_policy |
Quota policies (scope, limit) |
audit_log |
Activity records (user, action, timestamp) |
model |
Custom Models / Agents |
prompt |
Prompt Templates |