f03ed9169538245b3d2dbb8a7ee9b8301ed38a43
Introduce SystemMetricsProvider that reads /proc on Linux (with safe fallbacks on other platforms) and includes CPU usage, memory usage, disk usage, and uptime in every heartbeat payload. Allows Central to monitor agent health proactively.
Heimdall — Plateforme de Surveillance Vidéo
Heimdall est une plateforme de surveillance vidéo multi-sites avec détection IA. Architecture .NET 10 Clean Architecture avec Blazor Server + PostgreSQL.
Architecture
Heimdall.Central (Api + Web + Workers) Heimdall.Agent
┌──────────────────────────────┐ ┌──────────────┐
│ 🌐 Blazor UI (MudBlazor) │ │ 📹 FFmpeg │
│ 🔌 REST API │ ←──HTTPS──→ │ 🧠 IA locale│
│ ⏰ Hangfire Workers │ │ 💓 Heartbeat│
│ 🗄️ PostgreSQL │ └──────────────┘
└──────────────────────────────┘
Projets
| Projet | Rôle |
|---|---|
Heimdall.Domain |
Entités, énums, value objects |
Heimdall.Application |
Interfaces services, DTOs, validation |
Heimdall.Infrastructure |
EF Core, Identity, JWT, API Key, Hangfire |
Heimdall.Api |
REST API (controllers, middleware) |
Heimdall.Web |
Blazor Server UI (MudBlazor) |
Heimdall.Workers |
Hangfire background jobs (heartbeat monitor) |
Heimdall.Agent |
Agent d'enregistrement et heartbeat |
Démarrage rapide
1. Docker (production — Docker Hub)
Les images pré-buildées sont disponibles sur Docker Hub :
| Image | Description |
|---|---|
eltruncho/heimdall-central:latest |
API + Web UI + Workers |
eltruncho/heimdall-agent:latest |
Agent d'enregistrement |
# Copier la configuration
cp .env.example .env
# Éditer les secrets (JWT__Key, mots de passe)
nano .env
# Lancer (pull images depuis Docker Hub)
docker compose -f docker/docker-compose.prod.yml up -d
Accès :
- UI : http://localhost:5000
- API : http://localhost:5000/api
- Documentation API : http://localhost:5000/scalar (dev)
- Alarik Console : http://localhost:9001
2. Build local (développement)
cp .env.example .env
# Éditer les secrets
nano .env
# Build & lancer depuis les sources
docker compose -f docker/docker-compose.yml up -d
3. Développement
Prérequis : .NET 10 SDK, PostgreSQL 17
# Lancer PostgreSQL
docker run -d --name pg -e POSTGRES_DB=heimdall -e POSTGRES_USER=heimdall \
-e POSTGRES_PASSWORD=heimdall -p 5432:5432 postgres:17-alpine
# Lancer l'API
make dev-api
# Lancer le worker (dans un autre terminal)
make dev-worker
# Lancer le web UI (dans un autre terminal)
make dev-web
Commandes Make
make build # Build .NET
make test # Run tests
make docker-up # docker compose up
make docker-down # docker compose down
make dev-api # API en dev
make dev-web # Web UI en dev
Authentification
| Méthode | Usage | Endpoints |
|---|---|---|
| JWT | Humains (Admin/Supervisor/Viewer) | POST /api/auth/login |
| API Key | Agents | Authorization: Bearer <key> |
| 2FA TOTP | Sécurité renforcée | POST /api/auth/2fa/verify |
Comptes par défaut (dev) :
admin@heimdall.test/Admin123!Pass— Admin
API — Endpoints principaux
| Méthode | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
- | Créer un compte |
| POST | /api/auth/login |
- | Connexion |
| GET | /api/sites |
JWT | Lister les sites |
| POST | /api/sites |
JWT | Créer un site |
| POST | /api/sites/{id}/tokens |
JWT | Générer token agent |
| POST | /api/agents/register |
- | Enregistrer un agent |
| POST | /api/agents/{id}/heartbeat |
API Key | Heartbeat agent |
| GET | /api/users |
JWT | Lister utilisateurs |
| POST | /api/users |
JWT | Créer utilisateur |
| PUT | /api/users/{id}/roles |
JWT | Modifier rôles |
| POST | /api/users/{id}/lock |
JWT | Verrouiller compte |
| POST | /api/users/{id}/reset-password |
JWT | Reset mot de passe |
| GET | /api/cameras/by-site/{siteId} |
JWT | Caméras d'un site |
| POST | /api/cameras |
JWT | Ajouter une caméra |
| GET | /api/stats |
JWT | Statistiques globales |
| GET | /api/audit-logs |
JWT | Journal d'audit |
Sécurité
- JWT 15min access + refresh token
- API Key HMACSHA256 + comparaison constant-time
- Rate limiting : 10 req/min auth, 200 req/min API
- CORS configurable
- Journal d'audit : toutes les actions critiques sont loguées
- ASP.NET Identity : lockout après 5 tentatives
Tests
# Tout exécuter
dotnet test
# Résultat attendu
34 tests — 0 failed, 0 skipped
| Suite | Tests | Ce qui est testé |
|---|---|---|
| Domain | 13 | Entités (Site, Agent, Camera) |
| Integration | 16 | API (Auth, Sites, Users, Cameras, Agents) |
| Placeholder | 5 | Projets vides |
Déploiement Docker
Depuis Docker Hub (recommandé)
# docker-compose.prod.yml minimal
services:
postgresql:
image: postgres:17-alpine
environment:
POSTGRES_DB: heimdall
POSTGRES_USER: heimdall
POSTGRES_PASSWORD: <mot-de-passe>
volumes:
- pgdata:/var/lib/postgresql/data
heimdall-central:
image: eltruncho/heimdall-central:latest
environment:
DATABASE_URL: "Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=<mot-de-passe>"
JWT__Key: "<votre-clé-32-caractères-min>"
ports:
- "5000:8080"
depends_on:
postgresql:
condition: service_healthy
Build local
# docker-compose.yml minimal
services:
heimdall-central:
build:
context: .
dockerfile: docker/Dockerfile.central
environment:
DATABASE_URL: "Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall"
JWT__Key: "<votre-clé-32-caractères-min>"
ports:
- "5000:8080"
Stack technique
| Technologie | Version |
|---|---|
| .NET | 10.0 |
| EF Core | 10.0.8 |
| Npgsql | 10.0.3 |
| PostgreSQL | 17 |
| Blazor Server | 10.0 |
| MudBlazor | 9.1.0 |
| Hangfire | 1.8.17 |
| xUnit | - |
| Shouldly | - |
Description
Intelligent Local AI Video Surveillance Platform https://www.tordais.cc
32 MiB
0 Stars
0 Watchers
0 Forks