first commit

This commit is contained in:
mega 2026-03-19 11:32:17 +00:00
commit 4b98219bf7
144 changed files with 31561 additions and 0 deletions

112
README.md Normal file
View file

@ -0,0 +1,112 @@
# DemoBMS
Intelligent Data Center Infrastructure Management platform.
## Stack
- **Frontend:** Next.js 16 + TypeScript + shadcn/ui + Recharts
- **Backend:** Python FastAPI
- **Database:** PostgreSQL + TimescaleDB
- **Auth:** Clerk
- **Runtime:** Docker Compose
---
## Ports
| Service | Port |
|----------|------|
| Frontend | 5646 |
| Backend | 8000 (internal — not exposed publicly) |
| Database | 5432 (internal) |
The frontend is the only service that needs to be reachable. Point your reverse proxy at port **5646**.
---
## API Calls & Reverse Proxy
The frontend never hardcodes a backend hostname. All API calls use the relative path `/api/backend/*`, which Next.js rewrites to the backend on the internal Docker network (`BACKEND_INTERNAL_URL`). From the browser's perspective everything is same-origin — your reverse proxy only needs to forward to port 5646.
```
Browser → Reverse Proxy → :5646 (Next.js)
↓ server-side rewrite
:8000 (FastAPI) — internal only
```
---
## Quick Start
### 1. Configure Clerk (required for auth)
Create a free account at https://clerk.com, create an application, then fill in the keys:
**`frontend/.env.local`**
```
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
```
**`backend/.env`**
```
CLERK_SECRET_KEY=sk_test_...
CLERK_JWKS_URL=https://your-app.clerk.accounts.dev/.well-known/jwks.json
```
### 2. Run with Docker Compose
```bash
docker compose up --build
```
- Frontend: http://your-server:5646
- API Docs: http://your-server:5646/api/backend/docs
### 3. Run locally (development)
**Frontend**
```bash
cd frontend
pnpm install
pnpm dev --port 5646
```
**Backend**
```bash
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload
```
**Database only (via Docker)**
```bash
docker compose up db
```
---
## Project Structure
```
/bms
/frontend Next.js app
/backend FastAPI app
/simulators Sensor bots (Phase 2)
docker-compose.yml
```
## Phase Progress
- [x] Phase 1 — Foundation (current)
- [ ] Phase 2 — Data Pipeline & Simulator Bots
- [ ] Phase 3 — Core Dashboard (live data)
- [ ] Phase 4 — Environmental Monitoring
- [ ] Phase 5 — Power Management
- [ ] Phase 6 — Cooling & AI Panel
- [ ] Phase 7 — Asset Management
- [ ] Phase 8 — Alarms & Events
- [ ] Phase 9 — Reports
- [ ] Phase 10 — Polish & Hardening