# lutherkingcp0/traceguard architecture

> Architecture diagram of the GitHub repository lutherkingcp0/traceguard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lutherkingcp0/traceguard
- Repository: https://github.com/lutherkingcp0/traceguard

## Overview

TraceGuard is a Django security-auditing application with a React interface: users authenticate, then work in role-specific areas for resources, audit events, anomaly detection, and reporting. The backend exposes those capabilities through routed APIs; the audit service records tamper-evident events, while detection scores event behavior and dashboards summarize audit and detection data. The graph emphasizes relationships visible in the excerpts or SOURCE INDEX. Frontend-to-API wiring and several unsampled subsystem details are not shown, so those links are omitted.

Main entry points: [`projet/urls.py`](https://github.com/lutherkingcp0/traceguard/blob/main/projet/urls.py) (API routes), [`audit/models.py`](https://github.com/lutherkingcp0/traceguard/blob/main/audit/models.py) (Hash-chained events), [`comptes/serializers.py`](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/serializers.py) (Account serializers), [`audit/services.py`](https://github.com/lutherkingcp0/traceguard/blob/main/audit/services.py) (Audit logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts and access"]
  node_auth_api["Session auth API<br/>[api.py]"]
  node_accounts_admin["Account admin API<br/>[api_admin.py]"]
  node_account_models["Users and roles<br/>[models.py]"]
  node_account_serializers["Account serializers<br/>[serializers.py]"]
  node_spaces["Role-based spaces<br/>[espaces.py]"]
end

subgraph group_audit["Audit trail"]
  node_audit_api["Audit event API<br/>[api.py]"]
  node_audit_service["Audit logger<br/>[services.py]"]
  node_audit_events[("Hash-chained events<br/>[models.py]")]
  node_audit_router["Audit DB router<br/>[routers.py]"]
  node_audit_signals["ORM audit signals<br/>[signals.py]"]
  node_audit_db[("Audit database")]
end

subgraph group_detection["Detection and insights"]
  node_detection_api["Detection API<br/>[api.py]"]
  node_detection_metrics["Detection metrics<br/>[metriques.py]"]
  node_detection_service["Anomaly scoring<br/>[services.py]"]
  node_anomalies[("Anomaly records<br/>[models.py]")]
  node_dashboard_api["Dashboard synthesis<br/>[api.py]"]
  node_dashboard_views["Reports and views<br/>[views.py]"]
end

subgraph group_product["Resources and interface"]
  node_routes["API routes<br/>[urls.py]"]
  node_spa["SPA serving<br/>[spa.py]"]
  node_frontend["React application<br/>[App.tsx]"]
  node_resources_api["Resource API<br/>[api.py]"]
  node_resources["Business resources<br/>[models.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_routes -->|"serves fallback"| node_spa
node_routes -->|"routes auth"| node_auth_api
node_routes -->|"routes admin"| node_accounts_admin
node_routes -->|"routes resources"| node_resources_api
node_routes -->|"routes events"| node_audit_api
node_routes -->|"routes detection"| node_detection_api
node_routes -->|"routes synthesis"| node_dashboard_api
node_auth_api -->|"derives space"| node_spaces
node_auth_api -->|"validates input"| node_account_serializers
node_accounts_admin -->|"serializes accounts"| node_account_serializers
node_account_serializers -->|"reads and writes"| node_account_models
node_account_serializers -->|"serializes resources"| node_resources
node_resources_api -->|"serializes resources"| node_account_serializers
node_resources_api -.->|"reads and writes"| node_resources
node_audit_api -->|"logs events"| node_audit_service
node_audit_api -->|"queries events"| node_audit_events
node_audit_service -->|"writes and verifies"| node_audit_events
node_audit_service -->|"selects audit DB"| node_audit_router
node_audit_router -->|"routes audit models"| node_audit_db
node_audit_signals -->|"records changes"| node_audit_service
node_audit_signals -->|"observes events"| node_audit_events
node_detection_api -->|"uses metrics"| node_detection_metrics
node_detection_api -->|"queries anomalies"| node_anomalies
node_detection_service -->|"extracts features"| node_audit_events
node_dashboard_api -->|"summarizes events"| node_audit_events
node_dashboard_api -->|"uses metrics"| node_detection_metrics
node_dashboard_api -->|"summarizes anomalies"| node_anomalies
node_dashboard_views -->|"reads events"| node_audit_events
node_dashboard_views -->|"checks integrity"| node_audit_service
node_dashboard_views -->|"reads anomalies"| node_anomalies

click node_routes "https://github.com/lutherkingcp0/traceguard/blob/main/projet/urls.py"
click node_spa "https://github.com/lutherkingcp0/traceguard/blob/main/projet/spa.py"
click node_frontend "https://github.com/lutherkingcp0/traceguard/blob/main/frontend/src/App.tsx"
click node_auth_api "https://github.com/lutherkingcp0/traceguard/blob/main/comptes/api.py"
click node_accounts_admin "https://github.com/lutherkingcp0/traceguard/blob/main/comptes/api_admin.py"
click node_account_models "https://github.com/lutherkingcp0/traceguard/blob/main/comptes/models.py"
click node_account_serializers "https://github.com/lutherkingcp0/traceguard/blob/main/comptes/serializers.py"
click node_spaces "https://github.com/lutherkingcp0/traceguard/blob/main/comptes/espaces.py"
click node_resources_api "https://github.com/lutherkingcp0/traceguard/blob/main/metier/api.py"
click node_resources "https://github.com/lutherkingcp0/traceguard/blob/main/metier/models.py"
click node_audit_api "https://github.com/lutherkingcp0/traceguard/blob/main/audit/api.py"
click node_audit_service "https://github.com/lutherkingcp0/traceguard/blob/main/audit/services.py"
click node_audit_events "https://github.com/lutherkingcp0/traceguard/blob/main/audit/models.py"
click node_audit_router "https://github.com/lutherkingcp0/traceguard/blob/main/audit/routers.py"
click node_audit_signals "https://github.com/lutherkingcp0/traceguard/blob/main/audit/signals.py"
click node_detection_api "https://github.com/lutherkingcp0/traceguard/blob/main/detection/api.py"
click node_detection_metrics "https://github.com/lutherkingcp0/traceguard/blob/main/detection/metriques.py"
click node_detection_service "https://github.com/lutherkingcp0/traceguard/blob/main/detection/services.py"
click node_anomalies "https://github.com/lutherkingcp0/traceguard/blob/main/detection/models.py"
click node_dashboard_api "https://github.com/lutherkingcp0/traceguard/blob/main/dashboard/api.py"
click node_dashboard_views "https://github.com/lutherkingcp0/traceguard/blob/main/dashboard/views.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_api,node_accounts_admin,node_account_models,node_account_serializers,node_spaces,node_user toneBlue
class node_audit_api,node_audit_service,node_audit_events,node_audit_router,node_audit_signals,node_audit_db toneAmber
class node_detection_api,node_detection_metrics,node_detection_service,node_anomalies,node_dashboard_api,node_dashboard_views toneMint
class node_routes,node_spa,node_frontend,node_resources_api,node_resources toneRose
```

## Components

### Accounts and access

- [Session auth API](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/api.py): `comptes/api.py`
- [Account admin API](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/api_admin.py): `comptes/api_admin.py`
- [Users and roles](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/models.py): `comptes/models.py`
- [Account serializers](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/serializers.py): `comptes/serializers.py`
- [Role-based spaces](https://github.com/lutherkingcp0/traceguard/blob/main/comptes/espaces.py): `comptes/espaces.py`

### Audit trail

- [Audit event API](https://github.com/lutherkingcp0/traceguard/blob/main/audit/api.py): `audit/api.py`
- [Audit logger](https://github.com/lutherkingcp0/traceguard/blob/main/audit/services.py): `audit/services.py`
- [Hash-chained events](https://github.com/lutherkingcp0/traceguard/blob/main/audit/models.py): `audit/models.py`
- [Audit DB router](https://github.com/lutherkingcp0/traceguard/blob/main/audit/routers.py): `audit/routers.py`
- [ORM audit signals](https://github.com/lutherkingcp0/traceguard/blob/main/audit/signals.py): `audit/signals.py`
- **Audit database**

### Detection and insights

- [Detection API](https://github.com/lutherkingcp0/traceguard/blob/main/detection/api.py): `detection/api.py`
- [Detection metrics](https://github.com/lutherkingcp0/traceguard/blob/main/detection/metriques.py): `detection/metriques.py`
- [Anomaly scoring](https://github.com/lutherkingcp0/traceguard/blob/main/detection/services.py): `detection/services.py`
- [Anomaly records](https://github.com/lutherkingcp0/traceguard/blob/main/detection/models.py): `detection/models.py`
- [Dashboard synthesis](https://github.com/lutherkingcp0/traceguard/blob/main/dashboard/api.py): `dashboard/api.py`
- [Reports and views](https://github.com/lutherkingcp0/traceguard/blob/main/dashboard/views.py): `dashboard/views.py`

### Resources and interface

- [API routes](https://github.com/lutherkingcp0/traceguard/blob/main/projet/urls.py): `projet/urls.py`
- [SPA serving](https://github.com/lutherkingcp0/traceguard/blob/main/projet/spa.py): `projet/spa.py`
- [React application](https://github.com/lutherkingcp0/traceguard/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Resource API](https://github.com/lutherkingcp0/traceguard/blob/main/metier/api.py): `metier/api.py`
- [Business resources](https://github.com/lutherkingcp0/traceguard/blob/main/metier/models.py): `metier/models.py`

### Other components

- **User**

## Connections

- User → React application: uses
- API routes → SPA serving: serves fallback (evidence: `projet/urls.py`)
- API routes → Session auth API: routes auth (evidence: `projet/urls.py`)
- API routes → Account admin API: routes admin (evidence: `projet/urls.py`)
- API routes → Resource API: routes resources (evidence: `projet/urls.py`)
- API routes → Audit event API: routes events (evidence: `projet/urls.py`)
- API routes → Detection API: routes detection (evidence: `projet/urls.py`)
- API routes → Dashboard synthesis: routes synthesis (evidence: `projet/urls.py`)
- Session auth API → Role-based spaces: derives space (evidence: `comptes/api.py`)
- Session auth API → Account serializers: validates input (evidence: `comptes/api.py`)
- Account admin API → Account serializers: serializes accounts (evidence: `comptes/api_admin.py`)
- Account serializers → Users and roles: reads and writes (evidence: `comptes/serializers.py`)
- Account serializers → Business resources: serializes resources (evidence: `comptes/serializers.py`)
- Resource API → Account serializers: serializes resources (evidence: `metier/api.py`)
- Resource API → Business resources: reads and writes (evidence: `metier/api.py`)
- Audit event API → Audit logger: logs events (evidence: `audit/api.py`)
- Audit event API → Hash-chained events: queries events (evidence: `audit/api.py`)
- Audit logger → Hash-chained events: writes and verifies (evidence: `audit/services.py`)
- Audit logger → Audit DB router: selects audit DB (evidence: `audit/services.py`)
- Audit DB router → Audit database: routes audit models (evidence: `audit/routers.py`)
- ORM audit signals → Audit logger: records changes (evidence: `audit/signals.py`)
- ORM audit signals → Hash-chained events: observes events (evidence: `audit/signals.py`)
- Detection API → Detection metrics: uses metrics (evidence: `detection/api.py`)
- Detection API → Anomaly records: queries anomalies (evidence: `detection/api.py`)
- Anomaly scoring → Hash-chained events: extracts features (evidence: `detection/services.py`)
- Dashboard synthesis → Hash-chained events: summarizes events (evidence: `dashboard/api.py`)
- Dashboard synthesis → Detection metrics: uses metrics (evidence: `dashboard/api.py`)
- Dashboard synthesis → Anomaly records: summarizes anomalies (evidence: `dashboard/api.py`)
- Reports and views → Hash-chained events: reads events (evidence: `dashboard/views.py`)
- Reports and views → Audit logger: checks integrity (evidence: `dashboard/views.py`)
- Reports and views → Anomaly records: reads anomalies (evidence: `dashboard/views.py`)
