docs: initial spec
This commit is contained in:
commit
0680f832a5
3 files changed
+1736
No files matched your search
@@ -0,0 +1,828 @@
|
||||
# Heimdall - Plan d'implémentation
|
||||
|
||||
## Phase 0 - Initialisation projet
|
||||
|
||||
### Objectif
|
||||
|
||||
Créer le socle technique stable.
|
||||
|
||||
Durée estimée : 1-2 jours.
|
||||
|
||||
---
|
||||
|
||||
## Repository
|
||||
|
||||
Créer :
|
||||
|
||||
```
|
||||
Heimdall
|
||||
│
|
||||
├── src
|
||||
│ ├── Heimdall.Domain
|
||||
│ ├── Heimdall.Application
|
||||
│ ├── Heimdall.Infrastructure
|
||||
│ ├── Heimdall.Api
|
||||
│ ├── Heimdall.Web
|
||||
│ ├── Heimdall.Agent
|
||||
│ ├── Heimdall.Workers
|
||||
│ ├── Heimdall.Contracts
|
||||
│ └── Heimdall.Shared
|
||||
│
|
||||
├── tests
|
||||
│ ├── Heimdall.Domain.Tests
|
||||
│ ├── Heimdall.Application.Tests
|
||||
│ ├── Heimdall.Infrastructure.Tests
|
||||
│ ├── Heimdall.Api.Tests
|
||||
│ ├── Heimdall.Agent.Tests
|
||||
│ └── Heimdall.IntegrationTests
|
||||
│
|
||||
├── docker
|
||||
│
|
||||
├── .github/workflows
|
||||
│
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 1 - Solution .NET 10 + Clean Architecture
|
||||
|
||||
## Objectif
|
||||
|
||||
Créer tous les projets avec références correctes.
|
||||
|
||||
---
|
||||
|
||||
## Domain
|
||||
|
||||
Aucune dépendance externe.
|
||||
|
||||
Références autorisées :
|
||||
|
||||
```
|
||||
Domain
|
||||
|
|
||||
X
|
||||
```
|
||||
|
||||
Contient :
|
||||
|
||||
* Entities
|
||||
* Value Objects
|
||||
* Enums
|
||||
* Domain Events
|
||||
* Business Rules
|
||||
|
||||
---
|
||||
|
||||
Exemple :
|
||||
|
||||
```
|
||||
CameraStatus.cs
|
||||
|
||||
EventType.cs
|
||||
|
||||
StorageProvider.cs
|
||||
|
||||
Site.cs
|
||||
|
||||
Camera.cs
|
||||
|
||||
Person.cs
|
||||
|
||||
Vehicle.cs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Application
|
||||
|
||||
Dépend :
|
||||
|
||||
```
|
||||
Application
|
||||
|
|
||||
v
|
||||
Domain
|
||||
```
|
||||
|
||||
Contient :
|
||||
|
||||
* Commands
|
||||
* Queries
|
||||
* DTO
|
||||
* Validators
|
||||
* Interfaces
|
||||
* Specifications
|
||||
|
||||
Technologies :
|
||||
|
||||
* MediatR
|
||||
* FluentValidation
|
||||
|
||||
---
|
||||
|
||||
## Infrastructure
|
||||
|
||||
Dépend :
|
||||
|
||||
```
|
||||
Infrastructure
|
||||
|
||||
|
|
||||
v
|
||||
|
||||
Application
|
||||
Domain
|
||||
```
|
||||
|
||||
Contient :
|
||||
|
||||
* EF Core
|
||||
* PostgreSQL
|
||||
* Identity
|
||||
* File storage
|
||||
* S3
|
||||
* External services
|
||||
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
Dépend :
|
||||
|
||||
```
|
||||
API
|
||||
|
||||
|
|
||||
Application
|
||||
Infrastructure
|
||||
```
|
||||
|
||||
Contient :
|
||||
|
||||
* REST endpoints
|
||||
* Authentication
|
||||
* API Keys
|
||||
* OpenAPI
|
||||
|
||||
---
|
||||
|
||||
## Agent
|
||||
|
||||
Même architecture :
|
||||
|
||||
```
|
||||
Heimdall.Agent
|
||||
|
||||
Domain
|
||||
|
||||
Application
|
||||
|
||||
Infrastructure
|
||||
```
|
||||
|
||||
Mais orientée :
|
||||
|
||||
* Worker Service
|
||||
* Communication API
|
||||
* Camera management
|
||||
|
||||
---
|
||||
|
||||
## Web
|
||||
|
||||
Blazor :
|
||||
|
||||
```
|
||||
Heimdall.Web
|
||||
```
|
||||
|
||||
Dernière phase.
|
||||
|
||||
---
|
||||
|
||||
# Phase 2 - Framework de tests
|
||||
|
||||
## Objectif
|
||||
|
||||
Avoir les tests avant le métier.
|
||||
|
||||
---
|
||||
|
||||
Stack :
|
||||
|
||||
* xUnit
|
||||
* Shouldly
|
||||
* NSubstitute
|
||||
* Testcontainers
|
||||
* FluentAssertions éventuellement
|
||||
|
||||
---
|
||||
|
||||
## Tests Domain
|
||||
|
||||
Premier projet.
|
||||
|
||||
Exemple :
|
||||
|
||||
```
|
||||
CameraTests.cs
|
||||
|
||||
PersonTests.cs
|
||||
|
||||
VehicleTests.cs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Exemple TDD :
|
||||
|
||||
Avant code :
|
||||
|
||||
```csharp
|
||||
[Fact]
|
||||
public void Camera_should_start_disabled()
|
||||
{
|
||||
var camera = new Camera();
|
||||
|
||||
camera.Status.ShouldBe(CameraStatus.Disabled);
|
||||
}
|
||||
```
|
||||
|
||||
Puis seulement :
|
||||
|
||||
```csharp
|
||||
public class Camera
|
||||
{
|
||||
public CameraStatus Status {get;private set;}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 3 - CI/CD DockerHub
|
||||
|
||||
## Objectif
|
||||
|
||||
Chaque commit doit être compilable.
|
||||
|
||||
---
|
||||
|
||||
Pipeline :
|
||||
|
||||
```
|
||||
Push
|
||||
|
||||
↓
|
||||
|
||||
Restore
|
||||
|
||||
↓
|
||||
|
||||
Build
|
||||
|
||||
↓
|
||||
|
||||
Unit Tests
|
||||
|
||||
↓
|
||||
|
||||
Coverage
|
||||
|
||||
↓
|
||||
|
||||
Docker Build
|
||||
|
||||
↓
|
||||
|
||||
Docker Push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Images :
|
||||
|
||||
```
|
||||
heimdall/api
|
||||
|
||||
heimdall/agent
|
||||
|
||||
heimdall/web
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Tags :
|
||||
|
||||
```
|
||||
latest
|
||||
|
||||
1.0.0
|
||||
|
||||
commit-sha
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Quality gates :
|
||||
|
||||
* Build OK
|
||||
* Tests OK
|
||||
* Coverage minimum
|
||||
* Sonar optionnel
|
||||
|
||||
---
|
||||
|
||||
# Phase 4 - Socle métier commun
|
||||
|
||||
## Objectif
|
||||
|
||||
Construire les fondations.
|
||||
|
||||
Ordre :
|
||||
|
||||
1. Tenant / Site
|
||||
2. User
|
||||
3. Permissions
|
||||
4. Audit
|
||||
5. Configuration
|
||||
6. Events
|
||||
|
||||
---
|
||||
|
||||
## Entities
|
||||
|
||||
Premier modèle :
|
||||
|
||||
```
|
||||
Site
|
||||
|
||||
Camera
|
||||
|
||||
Person
|
||||
|
||||
Vehicle
|
||||
|
||||
LicensePlate
|
||||
|
||||
Event
|
||||
|
||||
StoragePolicy
|
||||
|
||||
ApiKey
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Avant chaque Entity :
|
||||
|
||||
Créer :
|
||||
|
||||
```
|
||||
Tests
|
||||
|
||||
↓
|
||||
|
||||
Implementation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 5 - API Core
|
||||
|
||||
Développer API et tests ensemble.
|
||||
|
||||
---
|
||||
|
||||
## Première fonctionnalité
|
||||
|
||||
Health Check.
|
||||
|
||||
Test :
|
||||
|
||||
```
|
||||
GET /health
|
||||
|
||||
200 OK
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Puis :
|
||||
|
||||
## Site Management
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
CreateSiteCommandTests
|
||||
|
||||
GetSiteQueryTests
|
||||
|
||||
DeleteSiteTests
|
||||
```
|
||||
|
||||
Code ensuite.
|
||||
|
||||
---
|
||||
|
||||
## Camera Management
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
CreateCameraTests
|
||||
|
||||
UpdateCameraTests
|
||||
|
||||
DisableCameraTests
|
||||
```
|
||||
|
||||
Puis implémentation.
|
||||
|
||||
---
|
||||
|
||||
# Phase 6 - Agent Heimdall
|
||||
|
||||
Développement parallèle API.
|
||||
|
||||
Objectif :
|
||||
|
||||
Premier agent connecté.
|
||||
|
||||
---
|
||||
|
||||
## Fonctionnalités V1
|
||||
|
||||
### Agent Registration
|
||||
|
||||
Test :
|
||||
|
||||
```
|
||||
Agent can register to server
|
||||
```
|
||||
|
||||
Puis code.
|
||||
|
||||
---
|
||||
|
||||
### Heartbeat
|
||||
|
||||
Test :
|
||||
|
||||
```
|
||||
Agent sends heartbeat
|
||||
```
|
||||
|
||||
Puis code.
|
||||
|
||||
---
|
||||
|
||||
### Site association
|
||||
|
||||
Test :
|
||||
|
||||
```
|
||||
Agent belongs to site
|
||||
```
|
||||
|
||||
Puis code.
|
||||
|
||||
---
|
||||
|
||||
Architecture :
|
||||
|
||||
```
|
||||
Agent
|
||||
|
||||
|
|
||||
|
||||
HTTPS
|
||||
|
||||
|
|
||||
|
||||
API
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 7 - Camera Discovery
|
||||
|
||||
## Agent
|
||||
|
||||
Implémentation :
|
||||
|
||||
ONVIF discovery.
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
Should discover camera
|
||||
|
||||
Should reject invalid credentials
|
||||
|
||||
Should detect capabilities
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Mock :
|
||||
|
||||
Créer :
|
||||
|
||||
```
|
||||
FakeOnvifClient
|
||||
```
|
||||
|
||||
Tests sans caméra réelle.
|
||||
|
||||
---
|
||||
|
||||
# Phase 8 - Video Pipeline
|
||||
|
||||
## FFmpeg abstraction
|
||||
|
||||
Ne jamais appeler FFmpeg directement partout.
|
||||
|
||||
Créer :
|
||||
|
||||
```csharp
|
||||
IVideoRecorder
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Test :
|
||||
|
||||
```
|
||||
Recorder creates segment
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Implémentation :
|
||||
|
||||
* FFmpeg
|
||||
* Hardware acceleration
|
||||
|
||||
---
|
||||
|
||||
# Phase 9 - IA Pipeline
|
||||
|
||||
## Abstraction
|
||||
|
||||
Créer :
|
||||
|
||||
```csharp
|
||||
IAiDetectionService
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Mock :
|
||||
|
||||
```csharp
|
||||
FakeAiDetectionService
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
Person detection creates event
|
||||
|
||||
Unknown face creates alert
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Implémentation :
|
||||
|
||||
CodeProject.AI.
|
||||
|
||||
---
|
||||
|
||||
# Phase 10 - Storage
|
||||
|
||||
## Abstraction
|
||||
|
||||
Créer :
|
||||
|
||||
```csharp
|
||||
IStorageProvider
|
||||
```
|
||||
|
||||
Implémentations :
|
||||
|
||||
```
|
||||
LocalStorageProvider
|
||||
|
||||
S3StorageProvider
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
File saved
|
||||
|
||||
File deleted
|
||||
|
||||
Retention applied
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 11 - Hangfire
|
||||
|
||||
Implémenter :
|
||||
|
||||
* Retention jobs
|
||||
* Health checks
|
||||
* Cleanup
|
||||
|
||||
---
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
Expired recording is deleted
|
||||
|
||||
Active recording is kept
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 12 - Security
|
||||
|
||||
## Identity
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
User can login
|
||||
|
||||
Permission denied
|
||||
|
||||
Permission granted
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Keys
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
Generate key
|
||||
|
||||
Validate key
|
||||
|
||||
Expired key rejected
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Phase 13 - Blazor Web
|
||||
|
||||
Seulement maintenant.
|
||||
|
||||
---
|
||||
|
||||
Développement :
|
||||
|
||||
Tests :
|
||||
|
||||
* Component tests
|
||||
* bUnit
|
||||
|
||||
---
|
||||
|
||||
Ordre :
|
||||
|
||||
1. Layout
|
||||
2. Authentication
|
||||
3. Dashboard
|
||||
4. Sites
|
||||
5. Cameras
|
||||
6. Events
|
||||
7. Persons
|
||||
8. Vehicles
|
||||
9. Administration
|
||||
|
||||
---
|
||||
|
||||
# Phase 14 - Dashboard KPI
|
||||
|
||||
Créer les APIs d'abord.
|
||||
|
||||
Tests :
|
||||
|
||||
```
|
||||
Dashboard returns camera KPI
|
||||
|
||||
Dashboard returns event KPI
|
||||
|
||||
Dashboard returns storage KPI
|
||||
```
|
||||
|
||||
Puis UI MudBlazor.
|
||||
|
||||
---
|
||||
|
||||
# Phase 15 - Production Ready
|
||||
|
||||
## Observabilité
|
||||
|
||||
Ajouter :
|
||||
|
||||
* Serilog
|
||||
* Sentry
|
||||
* GlitchTip
|
||||
* OpenTelemetry
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
Générer :
|
||||
|
||||
* README
|
||||
* Architecture Decision Records
|
||||
* API documentation
|
||||
* Deployment guide
|
||||
|
||||
---
|
||||
|
||||
# Stratégie Git
|
||||
|
||||
## Branches
|
||||
|
||||
```
|
||||
main
|
||||
|
||||
develop
|
||||
|
||||
feature/*
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Commit convention
|
||||
|
||||
```
|
||||
feat:
|
||||
|
||||
fix:
|
||||
|
||||
test:
|
||||
|
||||
refactor:
|
||||
|
||||
docs:
|
||||
|
||||
ci:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Definition of Done
|
||||
|
||||
Une fonctionnalité est terminée uniquement si :
|
||||
|
||||
✅ Tests écrits avant le code
|
||||
✅ Code fonctionnel
|
||||
✅ Couverture TU OK
|
||||
✅ Documentation XML
|
||||
✅ Logs présents
|
||||
✅ Gestion des erreurs
|
||||
✅ Validation FluentValidation
|
||||
✅ Docker OK
|
||||
✅ CI verte
|
||||
|
||||
---
|
||||
|
||||
# Ordre global résumé
|
||||
|
||||
```
|
||||
1. Solution .NET 10
|
||||
2. Clean Architecture
|
||||
3. Tests Framework
|
||||
4. CI DockerHub
|
||||
5. Domain Model
|
||||
6. Application Layer
|
||||
7. API Core
|
||||
8. Agent Core
|
||||
9. ONVIF
|
||||
10. FFmpeg
|
||||
11. CodeProject.AI
|
||||
12. Storage
|
||||
13. Hangfire
|
||||
14. Security
|
||||
15. Blazor UI
|
||||
16. Dashboard
|
||||
17. Production Hardening
|
||||
```
|
||||
Reference in new issue
Block a user