Aaryan17 commited on
Commit
73c4eaa
·
verified ·
1 Parent(s): 2959187

fix: sdk=docker, app_port=7860, SQLite+Redis

Browse files
Files changed (1) hide show
  1. README.md +23 -252
README.md CHANGED
@@ -1,252 +1,23 @@
1
- ---
2
- title: MAC - MBM AI Cloud
3
- emoji: 🤖
4
- colorFrom: red
5
- colorTo: blue
6
- sdk: static
7
- pinned: true
8
- license: mit
9
- ---
10
-
11
- <p align="center">
12
- <img src="logo.png" alt="MAC — MBM AI Cloud" width="160" />
13
- </p>
14
-
15
- <h1 align="center">MAC — MBM AI Cloud</h1>
16
-
17
- <p align="center">
18
- <strong>Self-hosted AI platform for MBM University Jodhpur.</strong><br/>
19
- Private ChatGPT-style chat, Jupyter-style notebooks, RAG over college documents,<br/>
20
- face-based attendance, AI exam grading all running on the college's own GPUs.
21
- </p>
22
-
23
- <p align="center">
24
- <img src="https://img.shields.io/badge/Python-3.11+-3776AB?style=flat-square&logo=python&logoColor=white" />
25
- <img src="https://img.shields.io/badge/FastAPI-0.115-009688?style=flat-square&logo=fastapi&logoColor=white" />
26
- <img src="https://img.shields.io/badge/SvelteKit-2-FF3E00?style=flat-square&logo=svelte&logoColor=white" />
27
- <img src="https://img.shields.io/badge/PostgreSQL-16-4169E1?style=flat-square&logo=postgresql&logoColor=white" />
28
- <img src="https://img.shields.io/badge/Redis-7-DC382D?style=flat-square&logo=redis&logoColor=white" />
29
- <img src="https://img.shields.io/badge/vLLM-inference-6B4FBB?style=flat-square" />
30
- <img src="https://img.shields.io/badge/Docker-Compose-2496ED?style=flat-square&logo=docker&logoColor=white" />
31
- <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" />
32
- </p>
33
-
34
- ---
35
-
36
- ## What is MAC?
37
-
38
- **MAC (MBM AI Cloud)** is a fully on-premise AI platform built for MBM University, Jodhpur. It gives students, faculty, and admins a unified interface for AI-powered tools — with **zero external API calls**. All inference runs locally on the university's GPU cluster via [vLLM](https://github.com/vllm-project/vllm).
39
-
40
- > Think: a private, self-hosted ChatGPT + Jupyter + Google Classroom, built and controlled entirely by the university.
41
-
42
- ---
43
-
44
- ## Features
45
-
46
- | Feature | Description |
47
- |---|---|
48
- | **AI Chat** | Streaming chat with open-source LLMs (Qwen, DeepSeek, etc.). Custom system prompts, guardrails, multi-language support (19 Indian languages). |
49
- | **Notebooks** | Kaggle/Colab-style code execution cells (Python, JS, SQL) backed by Docker kernel containers or remote GPU workers. |
50
- | **RAG Search** | Upload PDFs and documents; query them with AI-augmented answers. Per-subject collections. |
51
- | **Attendance** | Face-capture based check-in. Faculty creates session → students selfie-check-in → export CSV/PDF. |
52
- | **Copy Check** | Upload exam answer sheets; AI grades per-question with marks + feedback; plagiarism detection across submissions. |
53
- | **Doubts Forum** | Students post questions; AI drafts answers; faculty moderates. |
54
- | **File Sharing** | Admin/faculty distribute class materials; per-file download analytics. |
55
- | **API Keys** | Scoped `mac_sk_*` API keys for students to access models from anywhere (OpenAI-compatible endpoint). |
56
- | **Multi-node Cluster** | GPU worker nodes register via one-time token, send heartbeats every 10 s; master load-balances LLM requests by GPU utilisation. |
57
- | **Admin Console** | Feature flags, quota overrides, guardrail rules, cluster management, system diagnostics. |
58
-
59
- ---
60
-
61
- ## Architecture
62
-
63
- ```
64
- Browser / API Client
65
- │ HTTPS
66
-
67
- Nginx (port 80/443)
68
-
69
- ├─ / → SvelteKit PWA (static)
70
- └─ /api/v1/* → FastAPI backend
71
-
72
- ┌─────────────┼──────────────┬────────────┐
73
- ▼ ▼ ▼ ▼
74
- PostgreSQL Redis Qdrant SearXNG
75
- (primary DB) (JWT blacklist (RAG vectors) (web search)
76
- rate limits)
77
-
78
- load_balancer.get_best_worker()
79
-
80
- GPU Worker Nodes (LAN)
81
- └── vLLM (OpenAI-compatible)
82
- └── worker_agent.py (heartbeat every 10 s)
83
- ```
84
-
85
- **Routing algorithm:** `gpu_util × 0.5 + vram_ratio × 0.3` — workers stale after 30 s are skipped.
86
-
87
- ---
88
-
89
- ## Repository Layout
90
-
91
- ```
92
- mac/ FastAPI backend
93
- routers/ API route handlers (thin — parse, auth, call service)
94
- services/ Business logic (no HTTP types)
95
- models/ SQLAlchemy ORM models
96
- schemas/ Pydantic request/response schemas
97
- middleware/ Auth, rate-limit, feature-gate middleware
98
- utils/ JWT, security helpers
99
-
100
- frontend/ SvelteKit 2 PWA
101
- src/routes/ Page components (chat, dashboard, notebooks, rag, …)
102
- src/lib/ API client, stores, i18n (19 languages), utils
103
-
104
- alembic/ Database migration environment + versioned revisions
105
- installer/ Windows GUI installer (PyInstaller + Tkinter)
106
- nginx/ Reverse proxy config (HTTP + HTTPS)
107
- tests/ pytest suite
108
- dist/ Built installer — MAC-Installer.exe
109
- docker-compose.yml Master node deployment stack
110
- docker-compose.worker.yml Worker node deployment stack
111
- worker_agent.py Worker enrollment + heartbeat agent
112
- ```
113
-
114
- ---
115
-
116
- ## Quick Start
117
-
118
- **Prerequisites:** Docker Desktop, Python 3.11+, Git
119
-
120
- ```bash
121
- git clone https://github.com/mbmuniversity2026/MAC.git
122
- cd MAC
123
- cp .env.example .env # edit DB password, model paths, etc.
124
- ```
125
-
126
- Start all services:
127
-
128
- ```bash
129
- docker compose up -d --build
130
- ```
131
-
132
- Open **http://localhost** — the setup wizard runs on first boot to create the admin account.
133
- API docs: **http://localhost:8000/docs**
134
-
135
- ---
136
-
137
- ## Adding a GPU Worker Node
138
-
139
- On the **master**, mint an enrollment token:
140
-
141
- ```bash
142
- curl -X POST http://MASTER_IP:8000/api/v1/cluster/enroll-token \
143
- -H "Authorization: Bearer ADMIN_JWT" \
144
- -d '{"label": "Lab PC 1", "expires_hours": 24}'
145
- ```
146
-
147
- On the **worker PC**, create a `.env` with:
148
-
149
- ```env
150
- MAC_MASTER_URL=http://MASTER_IP:8000
151
- MAC_ENROLL_TOKEN=<token from above>
152
- MAC_VLLM_PORT=8001
153
- ```
154
-
155
- Then start the worker stack:
156
-
157
- ```bash
158
- docker compose -f docker-compose.worker.yml up -d
159
- ```
160
-
161
- Approve the node in **Admin → Cluster** tab. The node starts receiving LLM requests immediately.
162
-
163
- ---
164
-
165
- ## Windows Installer
166
-
167
- A standalone GUI installer (`dist/MAC-Installer.exe`) handles everything:
168
- - Clones the repo, configures `.env`, sets a static IP on the network adapter, starts all Docker services.
169
-
170
- To rebuild it:
171
-
172
- ```powershell
173
- powershell -ExecutionPolicy Bypass -File .\installer\build_installer.ps1
174
- ```
175
-
176
- ---
177
-
178
- ## Tech Stack
179
-
180
- | Layer | Technology |
181
- |---|---|
182
- | Backend API | FastAPI 0.115, Python 3.11+ |
183
- | Database | PostgreSQL 16 + Alembic |
184
- | Cache / Rate-limit / Blacklist | Redis 7 |
185
- | LLM inference | vLLM (OpenAI-compatible, GPU) |
186
- | Vector DB | Qdrant |
187
- | Web search | SearXNG |
188
- | Frontend | SvelteKit 2 + Svelte 5 + Tailwind CSS 3 + Vite 6 |
189
- | Reverse proxy | Nginx |
190
- | Containerisation | Docker Compose |
191
- | Installer | PyInstaller (Windows) |
192
-
193
- ---
194
-
195
- ## Documentation
196
-
197
- | Document | Description |
198
- |---|---|
199
- | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | Full architecture, subsystem deep-dives, deployment guide |
200
- | [docs/MAC-CONTEXT.md](docs/MAC-CONTEXT.md) | Complete agent context — stack, auth, routing, design decisions |
201
- | [docs/MAC-PROGRESS.md](docs/MAC-PROGRESS.md) | Build progress log and roadmap |
202
-
203
- ---
204
-
205
- ## License
206
-
207
- MIT © MBM University Jodhpur
208
-
209
- Environment flags:
210
- - MAC_MODEL_AUTO_DOWNLOAD_ON_USE=true
211
- - MAC_MODEL_AUTO_DOWNLOAD_LIMIT=0
212
-
213
- This enables background pulling for configured open-source repositories when API usage begins.
214
-
215
- ## Testing
216
-
217
- Run full tests:
218
-
219
- ```bash
220
- pytest
221
- ```
222
-
223
- Run CPU-safe subset (no GPU-specific tests):
224
-
225
- ```bash
226
- pytest -k "not gpu"
227
- ```
228
-
229
- ## Windows Installer
230
-
231
- Build the standalone installer executable:
232
-
233
- ```powershell
234
- powershell -ExecutionPolicy Bypass -File .\installer\build_installer.ps1
235
- ```
236
-
237
- Output artifact:
238
- - dist/MAC-Installer.exe
239
-
240
- The installer uses embedded base64 branding assets from installer/embedded_assets.py so branding is retained even if source image files are unavailable during runtime.
241
-
242
- ## Security and Operations Notes
243
-
244
- - Keep .env secrets private and never commit credentials.
245
- - PostgreSQL is the canonical datastore in deployment.
246
- - Apply migrations via Alembic before serving traffic.
247
- - Use scoped API keys for automation instead of sharing admin JWTs.
248
-
249
- ## License
250
-
251
- Internal/Institutional project repository.
252
-
 
1
+ ---
2
+ title: MAC - MBM AI Cloud
3
+ emoji: 🤖
4
+ colorFrom: red
5
+ colorTo: blue
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: true
9
+ license: mit
10
+ ---
11
+
12
+ <p align="center">
13
+ <img src="logo.png" alt="MAC" width="120" />
14
+ </p>
15
+
16
+ <h1 align="center">MAC — MBM AI Cloud</h1>
17
+ <p align="center">Self-hosted AI platform for MBM University Jodhpur</p>
18
+
19
+ > This Space runs the full MAC backend (FastAPI + SQLite + Redis) live on Docker.
20
+ > Source code & full deployment guide: https://github.com/mbmuniversity2026/MAC
21
+
22
+ **Default admin login:** `admin@mbm.ac.in` / `Admin@1234`
23
+ (seeded automatically on first boot)