# rahulabi345-lang/sential-ai architecture

> Architecture diagram of the GitHub repository rahulabi345-lang/sential-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahulabi345-lang/sential-ai
- Repository: https://github.com/rahulabi345-lang/sential-ai

## Overview

#### Purpose and Entry Points
Sentinel-AI is a Windows-focused cybersecurity monitoring, threat-detection, risk-management, and AI-assistance project. The repository contains three overlapping application layers:
- A primary production-style backend: `backend/app/main.py`
- A smaller data-security pipeline and public Python API: `data_security/pipeline.py`, `data_security/api/public_interface.py`
- A React/Vite operator dashboard: `sentinel-frontend/src/main.tsx`, `sentinel-frontend/src/App.tsx`

Top-level scripts such as `app.py`, `backend.py`, `network_monitor.py`, and `process_monitor.py` appear to be alternate or standalone entry points rather than the main integrated runtime.

#### API, Authentication, and Realtime Boundary
The backend organizes HTTP/WebSocket endpoints by operational domain: authentication, monitoring, threats, alerts, dashboards, AI, and health. API routes should remain thin transport boundaries over services and schemas.
- `backend/app/api/auth.py`
- `backend/app/api/threats.py`
- `backend/app/api/websocket.py`

Security and dependency wiring live centrally in `backend/app/core/security.py` and `backend/app/api/deps.py`. WebSocket connection management is separated into `backend/app/core/websocket.py`.

#### Monitoring-to-Detection Pipeline
Host telemetry is collected from system, process, and network sources, then passed to the detection layer for signal extraction, rules evaluation, correlation, and risk calculation.
- `backend/app/monitoring/system_collector.py`
- `backend/app/monitoring/process_collector.py`
- `backend/app/monitoring/network_collector.py`
- `backend/app/detection/engine.py`
- `backend/app/detection/correlation.py`
- `backend/app/detection/risk.py`

The analogous legacy/simpler path collects Windows events and executes an explicit pipeline: `data_security/collectors/windows_event_collector.py`, `data_security/pipeline.py`, and `data_security/detection/detection_service.py`.

#### Threat, Alert, and Persistence Domain
The core backend persists users, threats, alerts, evidence, AI conversations, knowledge data, and event-outbox records. Domain services encapsulate application operations between API handlers and ORM models.
- `backend/app/models/threat.py`
- `backend/app/models/alert.py`
- `backend/app/models/threat_evidence.py`
- `backend/app/services/threat_service.py`
- `backend/app/services/alert_service.py`

Database setup is in `backend/app/core/database.py`, with schema evolution under `backend/alembic/`. The smaller `data_security` subsystem independently uses SQLite-oriented connection/schema and repository layers: `data_security/db/connection.py`, `data_security/db/schema.sql`, and `data_security/repository/`.

#### Events and Asynchronous Work
Detection and monitoring can be decoupled through an internal event abstraction and background workers. The event bus/publisher/subscriber boundary supports handing off emitted domain events, while Celery task modules run scheduled or deferred monitoring, detection, and event work.
- `backend/app/events/bus.py`
- `backend/app/events/publisher.py`
- `backend/app/models/event_outbox.py`
- `backend/app/workers/celery_app.py`
- `backend/app/workers/monitoring_tasks.py`
- `backend/app/workers/detection_tasks.py`

Container/runtime infrastructure is represented by `backend/Dockerfile`, `backend/docker-compose.yml`, `backend/celery_worker.py`, and `backend/celery_beat.py`.

#### AI and Retrieval-Augmented Assistance
AI functionality has two layers: top-level experimental modules under `ai/`, and backend-integrated AI services. The backend AI provider/client boundary isolates model access; context, safety, prompts, and classification shape responses. RAG ingests knowledge documents, chunks and embeds content, retrieves/ranks matches, then provides grounded context to AI services.
- `backend/app/ai/service.py`
- `backend/app/ai/provider.py`
- `backend/app/ai/safety.py`
- `backend/app/rag/ingestion.py`
- `backend/app/rag/retriever.py`
- `backend/app/rag/vector_store.py`

External AI/embedding providers are implied by `backend/app/ai/client.py` and `backend/app/rag/openai_embeddings.py`; credentials/configuration flow through `backend/app/core/config.py`.

#### Frontend Operator Experience
The frontend is a Vite React/TypeScript dashboard with dedicated pages for operational dashboards, threat review, logs, response workflows, analytics, settings, and an AI assistant.
- `sentinel-frontend/src/pages/Dashboard.tsx`
- `sentinel-frontend/src/pages/ThreatAnalysis.tsx`
- `sentinel-frontend/src/pages/Assistant.tsx`
- `sentinel-frontend/src/components/layout/AppLayout.tsx`

It currently includes mock-data modules, so API integration completeness should be verified before treating displayed monitoring or threat data as live: `sentinel-frontend/src/data/threatMockData.ts` and `sentinel-frontend/src/data/securityLogsMockData.ts`.

Main entry points: [`backend/app/api/threats.py`](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/api/threats.py) (API routes), [`backend/app/services/threat_service.py`](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/services/threat_service.py) (Threat & alert services), [`backend/app/workers/celery_app.py`](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/workers/celery_app.py) (Celery workers), [`backend/app/ai/service.py`](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/ai/service.py) (AI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Primary Backend"]
  node_backend_main["Backend application<br/>FastAPI entrypoint<br/>[main.py]"]
  node_api_routes["API routes<br/>HTTP/WebSocket transport<br/>[threats.py]"]
  node_security_deps["Security &amp; dependencies<br/>auth wiring<br/>[security.py]"]
  node_ws_manager["WebSocket manager<br/>connection manager<br/>[websocket.py]"]
  node_telemetry_collectors["Host telemetry collectors<br/>system/process/network monitoring"]
  node_detection_engine{{"Detection engine<br/>signal and rules engine<br/>[engine.py]"}}
  node_correlation_risk["Correlation &amp; risk<br/>detection analysis<br/>[correlation.py]"]
  node_domain_services["Threat &amp; alert services<br/>application services<br/>[threat_service.py]"]
  node_orm_models["Domain models<br/>ORM entities<br/>[threat.py]"]
  node_database[("Primary database<br/>database access<br/>[database.py]")]
end

subgraph group_async["Events &amp; Workers"]
  node_event_bus["Event bus<br/>internal event abstraction<br/>[bus.py]"]
  node_outbox["Event outbox<br/>durable domain events<br/>[event_outbox.py]"]
  node_celery_workers["Celery workers<br/>background jobs<br/>[celery_app.py]"]
end

subgraph group_ai["AI &amp; RAG"]
  node_ai_service["AI service<br/>AI orchestration<br/>[service.py]"]
  node_ai_provider["AI provider boundary<br/>model client<br/>[provider.py]"]
  node_rag_ingestion["Knowledge ingestion<br/>RAG indexing<br/>[ingestion.py]"]
  node_rag_retriever["RAG retriever<br/>context retrieval<br/>[retriever.py]"]
end

subgraph group_legacy["Data Security Pipeline"]
  node_legacy_collector["Windows event collector<br/>legacy telemetry input"]
  node_legacy_pipeline["Data security pipeline<br/>pipeline entrypoint<br/>[pipeline.py]"]
  node_legacy_detection["Legacy detection service"]
  node_legacy_sqlite[("Legacy SQLite store<br/>connection and repository layer<br/>[connection.py]")]
end

subgraph group_frontend["Operator Dashboard"]
  node_frontend_app["Operator dashboard<br/>React application<br/>[App.tsx]"]
  node_mock_data["Frontend mock data<br/>development data source<br/>[threatMockData.ts]"]
end

node_backend_main -->|"mounts"| node_api_routes
node_api_routes -->|"authenticates via"| node_security_deps
node_api_routes -->|"opens realtime connections"| node_ws_manager
node_api_routes -->|"invokes"| node_domain_services
node_telemetry_collectors -->|"telemetry"| node_detection_engine
node_detection_engine -->|"signals"| node_correlation_risk
node_correlation_risk -->|"findings and risk"| node_domain_services
node_domain_services -->|"manages"| node_orm_models
node_orm_models -->|"persists to"| node_database
node_domain_services -->|"records events"| node_outbox
node_outbox -->|"publishes"| node_event_bus
node_event_bus -->|"dispatches work"| node_celery_workers
node_celery_workers -.->|"runs monitoring"| node_telemetry_collectors
node_celery_workers -.->|"runs detection"| node_detection_engine
node_api_routes -->|"assistant requests"| node_ai_service
node_ai_service -->|"model calls"| node_ai_provider
node_ai_service -->|"requests context"| node_rag_retriever
node_rag_ingestion -->|"indexes knowledge"| node_rag_retriever
node_legacy_collector -->|"Windows events"| node_legacy_pipeline
node_legacy_pipeline -->|"processes"| node_legacy_detection
node_legacy_detection -->|"stores results"| node_legacy_sqlite
node_frontend_app -->|"operates through API"| node_api_routes
node_frontend_app -->|"realtime updates"| node_ws_manager
node_mock_data -.->|"current fallback data"| node_frontend_app

click node_backend_main "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/api/threats.py"
click node_security_deps "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/security.py"
click node_ws_manager "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/websocket.py"
click node_telemetry_collectors "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/monitoring/system_collector.py"
click node_detection_engine "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/detection/engine.py"
click node_correlation_risk "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/detection/correlation.py"
click node_domain_services "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/services/threat_service.py"
click node_orm_models "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/models/threat.py"
click node_database "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/database.py"
click node_event_bus "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/events/bus.py"
click node_outbox "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/models/event_outbox.py"
click node_celery_workers "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/workers/celery_app.py"
click node_ai_service "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/ai/service.py"
click node_ai_provider "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/ai/provider.py"
click node_rag_ingestion "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/rag/ingestion.py"
click node_rag_retriever "https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/rag/retriever.py"
click node_legacy_collector "https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/collectors/windows_event_collector.py"
click node_legacy_pipeline "https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/pipeline.py"
click node_legacy_detection "https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/detection/detection_service.py"
click node_legacy_sqlite "https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/db/connection.py"
click node_frontend_app "https://github.com/rahulabi345-lang/sential-ai/blob/main/sentinel-frontend/src/App.tsx"
click node_mock_data "https://github.com/rahulabi345-lang/sential-ai/blob/main/sentinel-frontend/src/data/threatMockData.ts"

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_backend_main,node_api_routes,node_security_deps,node_ws_manager,node_telemetry_collectors,node_detection_engine,node_correlation_risk,node_domain_services,node_orm_models,node_database toneBlue
class node_event_bus,node_outbox,node_celery_workers toneAmber
class node_ai_service,node_ai_provider,node_rag_ingestion,node_rag_retriever toneMint
class node_legacy_collector,node_legacy_pipeline,node_legacy_detection,node_legacy_sqlite toneRose
class node_frontend_app,node_mock_data toneIndigo
```

## Components

### Primary Backend

Production-style monitoring and threat API.

- [Backend application](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/main.py): FastAPI entrypoint · `backend/app/main.py`
- [API routes](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/api/threats.py): HTTP/WebSocket transport · Thin auth, threat, and realtime endpoint boundary. · `backend/app/api/threats.py`
- [Security & dependencies](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/security.py): auth wiring · `backend/app/core/security.py`
- [WebSocket manager](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/websocket.py): connection manager · `backend/app/core/websocket.py`
- [Host telemetry collectors](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/monitoring/system_collector.py): system/process/network monitoring · `backend/app/monitoring/system_collector.py`
- [Detection engine](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/detection/engine.py): signal and rules engine · Extracts signals and evaluates detection rules. · `backend/app/detection/engine.py`
- [Correlation & risk](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/detection/correlation.py): detection analysis · `backend/app/detection/correlation.py`
- [Threat & alert services](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/services/threat_service.py): application services · `backend/app/services/threat_service.py`
- [Domain models](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/models/threat.py): ORM entities · Threats, alerts, evidence, conversations, knowledge, and outbox records. · `backend/app/models/threat.py`
- [Primary database](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/core/database.py): database access · ORM database setup with Alembic schema evolution. · `backend/app/core/database.py`

### Events & Workers

Decoupled event processing and scheduled work.

- [Event bus](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/events/bus.py): internal event abstraction · `backend/app/events/bus.py`
- [Event outbox](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/models/event_outbox.py): durable domain events · `backend/app/models/event_outbox.py`
- [Celery workers](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/workers/celery_app.py): background jobs · Runs deferred monitoring and detection tasks. · `backend/app/workers/celery_app.py`

### AI & RAG

Grounded AI assistance and knowledge retrieval.

- [AI service](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/ai/service.py): AI orchestration · Applies prompts, context, safety, and classification. · `backend/app/ai/service.py`
- [AI provider boundary](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/ai/provider.py): model client · Isolates external model access. · `backend/app/ai/provider.py`
- [Knowledge ingestion](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/rag/ingestion.py): RAG indexing · Chunks and embeds knowledge documents. · `backend/app/rag/ingestion.py`
- [RAG retriever](https://github.com/rahulabi345-lang/sential-ai/blob/main/backend/app/rag/retriever.py): context retrieval · Retrieves and ranks grounded knowledge context. · `backend/app/rag/retriever.py`

### Data Security Pipeline

Independent simpler Windows-event pipeline.

- [Windows event collector](https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/collectors/windows_event_collector.py): legacy telemetry input · `data_security/collectors/windows_event_collector.py`
- [Data security pipeline](https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/pipeline.py): pipeline entrypoint · `data_security/pipeline.py`
- [Legacy detection service](https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/detection/detection_service.py): detection service · `data_security/detection/detection_service.py`
- [Legacy SQLite store](https://github.com/rahulabi345-lang/sential-ai/blob/main/data_security/db/connection.py): connection and repository layer · `data_security/db/connection.py`

### Operator Dashboard

React/Vite security operations interface.

- [Operator dashboard](https://github.com/rahulabi345-lang/sential-ai/blob/main/sentinel-frontend/src/App.tsx): React application · Dashboard, threat analysis, response, analytics, and assistant UI. · `sentinel-frontend/src/App.tsx`
- [Frontend mock data](https://github.com/rahulabi345-lang/sential-ai/blob/main/sentinel-frontend/src/data/threatMockData.ts): development data source · Displayed threat and log data may not yet be live. · `sentinel-frontend/src/data/threatMockData.ts`

## Connections

- Backend application → API routes: mounts
- API routes → Security & dependencies: authenticates via
- API routes → WebSocket manager: opens realtime connections
- API routes → Threat & alert services: invokes
- Host telemetry collectors → Detection engine: telemetry
- Detection engine → Correlation & risk: signals
- Correlation & risk → Threat & alert services: findings and risk
- Threat & alert services → Domain models: manages
- Domain models → Primary database: persists to
- Threat & alert services → Event outbox: records events
- Event outbox → Event bus: publishes
- Event bus → Celery workers: dispatches work
- Celery workers → Host telemetry collectors: runs monitoring
- Celery workers → Detection engine: runs detection
- API routes → AI service: assistant requests
- AI service → AI provider boundary: model calls
- AI service → RAG retriever: requests context
- Knowledge ingestion → RAG retriever: indexes knowledge
- Windows event collector → Data security pipeline: Windows events
- Data security pipeline → Legacy detection service: processes
- Legacy detection service → Legacy SQLite store: stores results
- Operator dashboard → API routes: operates through API
- Operator dashboard → WebSocket manager: realtime updates
- Frontend mock data → Operator dashboard: current fallback data
