SentriScope System Architecture
High-level system architecture for SentriScope: multi-tenant Django SaaS layers, application responsibilities, host routing, and platform invariants.
1. Executive Summary
SentriScope is a production-grade SaaS Cyber Risk Intelligence Platform built on Django. It is SaaS-first by design — multi-tenancy, audit logging, and tenant isolation are architectural foundations, not retrofitted features.
The platform provides enterprise security teams with:
- Canonical data normalization — All security data (assets, vulnerabilities, identities, incidents, threat intelligence) normalized into a single canonical model regardless of source.
- Risk-based prioritization — Deterministic, explainable risk scoring with full scoring lineage.
- Intelligence-driven correlation — Attack paths, IOC correlation, threat actor profiling, and assessment management.
- AI-augmented query — Natural language to SQL pipeline over canonical data with strict schema grounding and security guardrails.
- Connector ecosystem — Governed ingestion from EDR, CMDB, vulnerability scanners, threat intel feeds, ITSM, and security rating platforms.
2. High-Level Architecture
┌────────────────────────────────────────────────────────┐
│ Load Balancer │
│ (SSL termination, routing) │
└──────────────┬─────────────────────┬───────────────────┘
│ │
┌───────▼──────┐ ┌──────▼───────┐
│ Django App │ │ Django App │
│ (WSGI/ASGI) │ │ (WSGI/ASGI) │
│ Instance 1 │ │ Instance N │
└───────┬──────┘ └──────┬───────┘
│ │
┌─────────▼─────────────────────▼─────────┐
│ Middleware Pipeline │
│ SecurityHeadersMiddleware │
│ HostRoutingMiddleware (URLconf switch) │
│ SessionMiddleware │
│ AuthenticationMiddleware │
│ TenantContextMiddleware ◄── Fail-closed │
│ AuditMiddleware │
│ CSPMiddleware │
└─────────┬───────────────────────────────┘
│
┌─────────▼─────────────────────────────────┐
│ Application Layer │
│ tenants │ accounts │ audit │ console │
│ platform_console │ security │ jobs │
│ canonical │ connectors │ reference │
│ intelligence_dashboard │ decision_intel │
│ llm │ compliance │ billing │ entitlements │
└─────────┬───────────────────────────────┘
│
┌─────────▼────────────┐ ┌──────────────┐
│ Database Layer │ │ Redis/Cache │
│ Default DB (Shared) │ │ (per-tenant │
│ Tenant DB 1 (Dedic.) │ │ key space) │
│ Tenant DB N (Dedic.) │ └──────────────┘
└───────────────────────┘ ┌──────────────┐
│ Celery │
│ (tenant-ctx │
│ enforced) │
└──────────────┘
3. Application Responsibilities
| App | Responsibility | Tenant-Scoped? |
|---|---|---|
tenants |
Tenant lifecycle, resolution, ORM enforcement, DB routing | Platform-level |
accounts |
Users, roles, memberships, authentication | Platform-level (users) + Tenant (memberships) |
audit |
Immutable audit log, security event recording | Filtered by tenant, stored platform-level |
console |
Platform API: plans, quotas, feature flags, tenant management | Platform-level |
platform_console |
Portal UI: tenants, reference data, settings, roles | Platform-level |
security |
Encryption, secret management, password validation | Cross-cutting |
jobs |
Celery task base classes, tenant-aware execution | Cross-cutting |
canonical |
Canonical assets, assessments, controls, exposures | Tenant-scoped |
connectors |
Connector framework and governed integrations | Tenant-scoped |
reference |
Platform-shared reference data (CVE, CWE, MITRE) | Platform-level |
compliance |
Compliance foundations, controls | Tenant-scoped |
billing |
Billing settings, Mercado Pago | Platform-level |
entitlements |
Entitlements and quotas | Platform-level |
intelligence_dashboard |
Global Intelligence Dashboard | Tenant-scoped |
decision_intelligence |
Decision Intelligence Layer (DIL): scoring, aging, systemic patterns | Tenant-scoped |
llm |
LLM integration, NL→SQL pipeline, schema grounding, guardrails | Tenant-scoped |
attack_graph |
Attack path discovery, graph snapshots | Tenant-scoped |
feeds |
Threat intel feeds, FeedArticle, TenantFeedSubscription | Platform-level + Tenant-scoped |
4. Directory Structure
sentriscope/
├── config/ # Django project configuration
│ ├── settings/
│ │ ├── base.py # Shared, security-hardened defaults
│ │ ├── development.py # Local dev overrides
│ │ ├── production.py # Production enforcement
│ │ └── test.py # Test-optimized settings
│ ├── celery.py # Celery with tenant enforcement
│ ├── urls.py / urls_portal.py / urls_tenant.py / urls_public.py
│ └── wsgi.py / asgi.py
├── apps/
│ ├── tenants/ # Multi-tenant core
│ ├── accounts/ # Identity, RBAC, authentication
│ ├── audit/ # Immutable audit logging
│ ├── console/ # Platform API (control plane)
│ ├── platform_console/ # Portal UI
│ ├── security/ # Encryption, secrets, validators
│ ├── jobs/ # Tenant-aware Celery tasks
│ ├── canonical/ # Canonical data models
│ ├── connectors/ # Connector framework and integrations
│ ├── reference/ # Platform-shared reference data
│ ├── compliance/ # Compliance and governance
│ ├── billing/ # Billing
│ ├── entitlements/ # Entitlements and quotas
│ ├── intelligence_dashboard/ # Intelligence dashboard
│ ├── decision_intelligence/ # Decision Intelligence Layer
│ ├── llm/ # LLM integration
│ └── attack_graph/ # Attack graph
├── templates/ # Django templates (pt-BR)
├── static/ # Static assets
├── # Active documentation (see README.md)
└── conftest.py # Shared test fixtures
5. Host-Based Multi-Application Routing
The platform serves three distinct applications from one codebase using host-based URLconf switching:
| Host Pattern | URLconf | Host Type | Description |
|---|---|---|---|
platform portal host |
portal URL configuration |
portal |
Platform management UI |
tenant application host |
tenant URL configuration |
tenant |
Tenant application + API |
public website host |
public URL configuration |
public |
Public landing page |
| Any other host | — | — | 404 (fail-closed) |
HostRoutingMiddleware sets request.urlconf and request._host_type before any view runs. Unknown hosts return 404 immediately — no routing to any view.
6. Key Invariants
These invariants are enforced at the platform level and must never be violated:
- Every business model inherits
TenantAwareTimestampedModel. - Every ORM query outside a tenant context raises
TenantContextError. - Tenant A can never read or write Tenant B's data — enforced by ORM, RLS, and middleware.
- Every security-relevant action is audit-logged via
log_audit_event(). - Every Celery task carries
tenant_idand uses@tenant_task(). - No global cache keys — all cache keys are tenant-scoped.
- No credentials stored in plaintext — encrypted via Secrets Manager.
- Platform scope and Tenant scope are mutually exclusive per session.
7. Extension Model
Future products plug into this platform without modifying platform core:
- Create a new app under
apps/(e.g.,apps/vuln_scanner/) - Inherit from
TenantAwareTimestampedModelfor all business data models - Use
TenantAwareManager(automatic viaTenantAwareModel) - Use
TenantAwareTaskas the Celery base class - Declare feature flags in
PlanFeatureFlagfor feature gating - Use
log_audit_event()for all security-relevant operations
No changes to the platform core are required.