feat(events): implement camera event pipeline with AI detection storage

Adds the foundation for AI-powered detection events storage, query,
and snapshot management. Agents can POST detection events (motion,
person, vehicle, face, etc.) with confidence scores and metadata;
users can query, filter, and view event history.

- CameraEvent entity with EF Core configuration + migration
- ICameraEventService / CameraEventService with paged query + filters
- EventsController: 5 REST endpoints (create, get, query, attach snapshot, delete)
- Agent-side CameraStreamService: FFmpeg-based RTSP frame capture (foundation)
- Supports both ApiKey (agent) and JWT (user) authentication
This commit is contained in:
Arnaud Dartois committed 2026-07-19 12:55:05 +00:00
1 parent 159da2ca26
commit 358443ff1a
12 files changed
+2179

No files matched your search

@@ -0,0 +1,60 @@
using Heimdall.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class CameraEventConfiguration : IEntityTypeConfiguration<CameraEvent>
{
public void Configure(EntityTypeBuilder<CameraEvent> builder)
{
builder.ToTable("camera_events");
builder.HasKey(e => e.Id);
builder.Property(e => e.Type)
.HasConversion<int>()
.IsRequired();
builder.Property(e => e.Confidence)
.HasDefaultValue(0.0);
builder.Property(e => e.Label)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(e => e.SnapshotUrl)
.HasMaxLength(2000)
.IsUnicode(false);
builder.Property(e => e.SnapshotThumbUrl)
.HasMaxLength(2000)
.IsUnicode(false);
builder.Property(e => e.MetadataJson)
.HasColumnType("jsonb");
builder.Property(e => e.OccurredAt)
.IsRequired();
builder.Property(e => e.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(e => e.UpdatedAt)
.HasDefaultValueSql("NOW()");
// Indexes
builder.HasIndex(e => new { e.CameraId, e.OccurredAt })
.IsDescending(false, true); // Most recent first
builder.HasIndex(e => new { e.CameraId, e.Type });
builder.HasIndex(e => e.OccurredAt);
// Relationships
builder.HasOne(e => e.Camera)
.WithMany()
.HasForeignKey(e => e.CameraId)
.OnDelete(DeleteBehavior.Cascade);
}
}