docs: comprehensive README with architecture, setup, API reference
- Full project documentation in readme.md (FR) - Quick start: Docker + development modes - API endpoint reference table with auth requirements - Security documentation (JWT, API Key, rate limiting) - Test suite documentation (34 tests) - Stack technology table
This commit is contained in:
1 parent
8c7ec4d279
commit
83af89d7ec
1 file changed
+163
@@ -0,0 +1,163 @@
|
||||
# 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)
|
||||
|
||||
```bash
|
||||
# Copier la configuration
|
||||
cp .env.example .env
|
||||
# Éditer les secrets (JWT__Key, mots de passe)
|
||||
nano .env
|
||||
|
||||
# Lancer
|
||||
docker compose -f docker/docker-compose.yml up -d
|
||||
```
|
||||
|
||||
Accès :
|
||||
- **UI** : http://localhost:5000
|
||||
- **API** : http://localhost:5000/api
|
||||
- **Documentation API** : http://localhost:5000/scalar (dev)
|
||||
- **MinIO Console** : http://localhost:9001
|
||||
|
||||
### 2. Développement
|
||||
|
||||
Prérequis : .NET 10 SDK, PostgreSQL 17
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
```bash
|
||||
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!` — 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
|
||||
|
||||
```bash
|
||||
# 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
|
||||
|
||||
```yaml
|
||||
# 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 | - |
|
||||
Reference in new issue
Block a user