dizai is an end-to-end platform for geological-hazard prevention and response: a Cesium-powered GIS one-map, a multi-hazard point registry (landslide / rockfall / debris flow / ground collapse), MQTT device monitoring, dual-track (rule chain + ML) four-level alert handling, patrol inspection, emergency plans, statistical reporting, and a FastAPI + scikit-learn ML microservice for model registry, training, evaluation, and champion inference. It runs as a self-contained local single-machine stack — no Docker required.
Actual screenshots from a local run, using a reproducible sample dataset.
- GIS one-map — Cesium 3D globe, hazard layers, and basemap switching, built on the self-developed
@gis/coreCesium adapter. - Hazard registry — landslide / rockfall / debris-flow / ground-collapse points with spatial attributes and an ltree organization tree.
- Device monitoring — MQTT device access and token management.
- Alert handling — dual-track warning (rule chain + ML) with four-level alerts (red / orange / yellow / blue) and a handling workflow.
- Patrol, emergency & reporting — patrol inspection, emergency plans, and statistical reports.
- ML microservice — model registry, synthetic-data training, evaluation, and champion inference (
ml-service, FastAPI + scikit-learn). - Local single-machine loop — one unified
scripts.localentry (doctor / init / start / status / stop) driving a complete stack over local PostgreSQL + PostGIS + Redis.
| Layer | Tech |
|---|---|
| Backend | FastAPI · SQLAlchemy async · Alembic · Celery · python-jose (JWT) |
| Frontend | Vue 3 · TypeScript · Vite · Cesium · Element Plus · ECharts · vue-i18n |
| ML | scikit-learn · xgboost · lightgbm · onnxruntime (FastAPI microservice) |
| Data | PostgreSQL · PostGIS · ltree · Redis (broker) |
| Rule engine | Python asyncio rule chain (filter / transform / action / rest-call / js-script) |
Prerequisites: macOS + PostgreSQL 18 + PostGIS + Redis + Node 22+.
# 1. Create database & extensions
psql postgres -c "CREATE ROLE dizai WITH LOGIN PASSWORD 'dizai';"
psql postgres -c "CREATE DATABASE dizai OWNER dizai;"
psql -d dizai -c "CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS ltree;"
# 2. Configure env & install deps
cp deploy/.env.example .env # set JWT_SECRET_KEY=$(openssl rand -hex 32)
python3 -m venv .venv && source .venv/bin/activate && pip install -e ".[dev]"
cd src && npm install && cd ..
# 3. Health check → migrate & seed → start stack
python -m scripts.local doctor # exit code 0 required
python -m scripts.local init # alembic + ml tables + seed + sample data (idempotent)
python -m scripts.local start # backend:8000 / frontend:5173 / ml:8001 / 2 workersOpen http://127.0.0.1:5173 and log in as admin (default password admin123456, overridable via DIZAI_ADMIN_PASSWORD before running init; change it after first login). Stop the stack with python -m scripts.local stop.
Full steps: docs/本地启动.md. Acceptance gate: docs/本地验收.md.
docs/本地启动.md— environment setup & startupdocs/本地验收.md— automated acceptance & quality gatesdocs/界面预览.md— UI screenshots- THIRDPARTY.md — third-party licenses & attributions
- NOTICE — Apache-2.0 notices
dizai/
├── app/ # FastAPI backend (api/core/db/migrations/models/notify/rule_engine/schemas/services/tasks/iot)
├── src/ # frontend Vue3 + TS + Cesium (source in src/src; @gis/core Cesium adapter)
├── ml-service/ # ML microservice (registry / training / eval / inference)
├── scripts/ # local.py (runtime entry) + seed*.py
├── deploy/ # .env.example
├── docker/ # deployment reference
├── docs/ # documentation
└── tests/ # backend tests
Issues and PRs welcome — see CONTRIBUTING.md and CODE_OF_CONDUCT.md. PRs must pass CI (ruff + frontend build + compile check); backend tests need PostgreSQL/Redis, so run pytest -q locally before submitting.
Apache License 2.0 — see LICENSE. Third-party notices: NOTICE and THIRDPARTY.md.
For operational geological-hazard decisions, consult qualified professional authorities.



