first commit

This commit is contained in:
Alberto-Audrix committed 2026-08-26 13:46:05 +07:00
commit 367533c02b
171 files changed
+101175

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
# New Dashboard Backend
Greenfield Django 5 + Wagtail 6 + DRF API aligned to `ERD_dashboard.png`.
## Services
| Compose service | Role |
| --------------- | ------------------------------------------------ |
| `api` | Gunicorn on `:8000` |
| `cron` | Same image, runs management commands on schedule |
| `db` | Postgres 16 (`--profile prod`) |
## Quick start (local, no Docker)
From `dashboard-new-v2/backend`:
```bash
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # if needed
python manage.py migrate
python manage.py seed_demo
npm run dev
# or: python manage.py runserver 0.0.0.0:8000
```
Seed creates user `admin` / `admin123`, then seeds the default Sukawarna demo data — **Kandang 4** and **Kandang 5** closed cycles (49 days each, 22 May – 9 Jul 2026) with full daily records and IoT panels. A manager login `skw_manager` / `skw_manager123` is created too. It also prints a one-time API key.
## Docker Compose
```bash
cp dashboard-new-v2/backend/.env.example dashboard-new-v2/backend/.env
# edit KARUNG_WEB_ADMIN_BASE_URL as needed
docker compose up --build
```
Production Postgres:
```bash
# set DB_ENGINE=django.db.backends.postgresql and DB_* in dashboard-new-v2/backend/.env
docker compose --profile prod up --build
```
## Auth
- **Session:** `POST /api/v1/auth/login/` then send session cookie + `X-CSRFToken` on writes
- **API key:** header `X-API-Key: <raw>` (hashed at rest)
- Public: `GET /api/v1/health/`
## External integrations
- karung-web-admin → `POST /api/v1/karungs/request/` (`KARUNG_WEB_ADMIN_BASE_URL`)
## Docs
- Curl samples: [docs/API_CURL.md](../../docs/API_CURL.md)
- Postman: [docs/postman/](../../docs/postman/)
- OpenAPI UI: `http://localhost:8000/api/docs/`
- Wagtail admin: `http://localhost:8000/admin/`