How rahulabi345-lang/sential-ai works
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: threats.py API routes · threat_service.py Threat & alert services · celery_app.py Celery workers · service.py AI service
Components 23
Primary Backend
Production-style monitoring and threat API.
- Backend application
backend/app/main.py - API routes · Thin auth, threat, and realtime endpoint boundary.
backend/app/api/threats.py - Security & dependencies
backend/app/core/security.py - WebSocket manager
backend/app/core/websocket.py - Host telemetry collectors
backend/app/monitoring/system_collector.py - Detection engine · Extracts signals and evaluates detection rules.
backend/app/detection/engine.py - Correlation & risk
backend/app/detection/correlation.py - Threat & alert services
backend/app/services/threat_service.py - Domain models · Threats, alerts, evidence, conversations, knowledge, and outbox records.
backend/app/models/threat.py - Primary database · ORM database setup with Alembic schema evolution.
backend/app/core/database.py
Events & Workers
Decoupled event processing and scheduled work.
- Event bus
backend/app/events/bus.py - Event outbox
backend/app/models/event_outbox.py - Celery workers · Runs deferred monitoring and detection tasks.
backend/app/workers/celery_app.py
AI & RAG
Grounded AI assistance and knowledge retrieval.
- AI service · Applies prompts, context, safety, and classification.
backend/app/ai/service.py - AI provider boundary · Isolates external model access.
backend/app/ai/provider.py - Knowledge ingestion · Chunks and embeds knowledge documents.
backend/app/rag/ingestion.py - RAG retriever · Retrieves and ranks grounded knowledge context.
backend/app/rag/retriever.py
Data Security Pipeline
Independent simpler Windows-event pipeline.
- Windows event collector
data_security/collectors/windows_event_collector.py - Data security pipeline
data_security/pipeline.py - Legacy detection service
data_security/detection/detection_service.py - Legacy SQLite store
data_security/db/connection.py
Operator Dashboard
React/Vite security operations interface.
- Operator dashboard · Dashboard, threat analysis, response, analytics, and assistant UI.
sentinel-frontend/src/App.tsx - Frontend mock data · Displayed threat and log data may not yet be live.
sentinel-frontend/src/data/threatMockData.ts
Connections 24
- 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