# jinayshah-888/csf architecture

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

- Interactive diagram: https://gitdiagram.com/jinayshah-888/csf
- Repository: https://github.com/jinayshah-888/csf

## Overview

CSF is an inline reverse-proxy firewall: HTTP requests are admitted and authenticated, extracted into inspectable values, evaluated by a cost-ordered detection cascade, adjudicated, then allowed through or blocked. A companion console API and React dashboard expose status, traffic, alerts, attack/JWT labs, and benchmarks. Edges reflect the README, excerpts, and SOURCE INDEX references; several runtime details are unsampled, so uncertain relationships are omitted.

Main entry points: [`backend/csf/gateway.py`](https://github.com/jinayshah-888/csf/blob/main/backend/csf/gateway.py) (Inline gateway), [`frontend/src/App.jsx`](https://github.com/jinayshah-888/csf/blob/main/frontend/src/App.jsx) (Dashboard app), [`frontend/src/components/ui.jsx`](https://github.com/jinayshah-888/csf/blob/main/frontend/src/components/ui.jsx) (Shared UI components), [`backend/csf/semantic/detector.py`](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/detector.py) (Semantic detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway &amp; admission"]
  node_gateway["Inline gateway<br/>[gateway.py]"]
  node_framing["HTTP framing<br/>[framing.py]"]
  node_jwt["JWT verification<br/>[jwtverify.py]"]
  node_jwks["JWKS rotation<br/>[jwks.py]"]
  node_resilience["Rate limits &amp; breaker<br/>[resilience.py]"]
  node_extraction["Request extraction<br/>[extraction.py]"]
  node_normalization["Value normalization<br/>[normalization.py]"]
end

subgraph group_detection["Detection cascade"]
  node_s1["CRS rules<br/>[s1_rules.py]"]
  node_sidecar["Coraza sidecar<br/>[main.go]"]
  node_semantic["Semantic detector<br/>[detector.py]"]
  node_sql["SQL analysis<br/>[sql.py]"]
  node_shell["Shell analysis<br/>[shell.py]"]
  node_traversal["Traversal analysis<br/>[traversal.py]"]
  node_xss["XSS analysis<br/>[xss.py]"]
  node_features["Model features<br/>[features.py]"]
  node_learned["Learned detector<br/>[detector.py]"]
end

subgraph group_policy["Policy &amp; observability"]
  node_decision["Decision engine<br/>[decision.py]"]
  node_verdict["Verdict types<br/>[verdict.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_integrity["Config integrity"]
  node_telemetry["Telemetry &amp; metrics<br/>[telemetry.py]"]
end

subgraph group_console["Console API"]
  node_console["Console API<br/>[server.py]"]
end

subgraph group_frontend["Dashboard"]
  node_frontend["Dashboard app<br/>[App.jsx]"]
  node_api["Dashboard API client<br/>[api.js]"]
  node_dashboard["Status dashboard<br/>[Dashboard.jsx]"]
  node_attacklab["Attack lab<br/>[AttackLab.jsx]"]
  node_jwtlab["JWT lab<br/>[JwtLab.jsx]"]
  node_traffic["Traffic view<br/>[Traffic.jsx]"]
  node_benchmarks["Benchmarks view<br/>[Benchmarks.jsx]"]
  node_scenarios["Scenarios view<br/>[Scenarios.jsx]"]
  node_ui["Shared UI components<br/>[ui.jsx]"]
end

node_client(("HTTP client"))
node_upstream["Protected upstream"]
node_operator(("Operator"))

node_client -->|"sends requests"| node_gateway
node_gateway -->|"checks framing"| node_framing
node_gateway -->|"verifies tokens"| node_jwt
node_gateway -->|"applies limits"| node_resilience
node_gateway -->|"extracts values"| node_extraction
node_extraction -->|"normalizes values"| node_normalization
node_gateway -->|"runs stage"| node_s1
node_s1 -->|"queries rules"| node_sidecar
node_gateway -->|"runs stage"| node_semantic
node_semantic -->|"analyzes SQL"| node_sql
node_semantic -->|"analyzes shell"| node_shell
node_semantic -->|"analyzes paths"| node_traversal
node_semantic -->|"analyzes XSS"| node_xss
node_gateway -->|"runs stage"| node_learned
node_learned -->|"builds features"| node_features
node_features -->|"reads candidates"| node_extraction
node_gateway -->|"submits evidence"| node_decision
node_decision -->|"uses verdict types"| node_verdict
node_gateway -->|"forwards allowed traffic"| node_upstream
node_gateway -->|"records activity"| node_telemetry
node_operator -.->|"inspects gateway"| node_console
node_config -->|"configures"| node_framing
node_config -->|"configures"| node_resilience
node_integrity -.->|"checks integrity"| node_config
node_console -->|"builds gateway"| node_gateway
node_frontend -->|"renders page"| node_dashboard
node_frontend -->|"renders page"| node_attacklab
node_frontend -->|"renders page"| node_jwtlab
node_frontend -->|"renders page"| node_traffic
node_frontend -->|"renders page"| node_benchmarks
node_frontend -->|"calls"| node_api
node_api -.->|"requests console data"| node_console
node_attacklab -->|"uses scenarios"| node_scenarios
node_dashboard -->|"renders with"| node_ui
node_attacklab -->|"renders with"| node_ui
node_jwtlab -->|"renders with"| node_ui
node_traffic -->|"renders with"| node_ui
node_benchmarks -->|"renders with"| node_ui
node_scenarios -->|"renders with"| node_ui
node_jwt -.->|"uses key rotation"| node_jwks

click node_gateway "https://github.com/jinayshah-888/csf/blob/main/backend/csf/gateway.py"
click node_framing "https://github.com/jinayshah-888/csf/blob/main/backend/csf/framing.py"
click node_jwt "https://github.com/jinayshah-888/csf/blob/main/backend/csf/jwtverify.py"
click node_jwks "https://github.com/jinayshah-888/csf/blob/main/backend/csf/jwks.py"
click node_resilience "https://github.com/jinayshah-888/csf/blob/main/backend/csf/resilience.py"
click node_extraction "https://github.com/jinayshah-888/csf/blob/main/backend/csf/extraction.py"
click node_normalization "https://github.com/jinayshah-888/csf/blob/main/backend/csf/normalization.py"
click node_s1 "https://github.com/jinayshah-888/csf/blob/main/backend/csf/s1_rules.py"
click node_sidecar "https://github.com/jinayshah-888/csf/blob/main/s1-sidecar/main.go"
click node_semantic "https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/detector.py"
click node_sql "https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/sql.py"
click node_shell "https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/shell.py"
click node_traversal "https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/traversal.py"
click node_xss "https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/xss.py"
click node_features "https://github.com/jinayshah-888/csf/blob/main/backend/csf/model/features.py"
click node_learned "https://github.com/jinayshah-888/csf/blob/main/backend/csf/model/detector.py"
click node_decision "https://github.com/jinayshah-888/csf/blob/main/backend/csf/decision.py"
click node_verdict "https://github.com/jinayshah-888/csf/blob/main/backend/csf/verdict.py"
click node_config "https://github.com/jinayshah-888/csf/blob/main/backend/csf/config.py"
click node_integrity "https://github.com/jinayshah-888/csf/blob/main/backend/csf/config_integrity.py"
click node_telemetry "https://github.com/jinayshah-888/csf/blob/main/backend/csf/telemetry.py"
click node_console "https://github.com/jinayshah-888/csf/blob/main/console-api/server.py"
click node_frontend "https://github.com/jinayshah-888/csf/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/jinayshah-888/csf/blob/main/frontend/src/api.js"
click node_dashboard "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Dashboard.jsx"
click node_attacklab "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/AttackLab.jsx"
click node_jwtlab "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/JwtLab.jsx"
click node_traffic "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Traffic.jsx"
click node_benchmarks "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Benchmarks.jsx"
click node_scenarios "https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Scenarios.jsx"
click node_ui "https://github.com/jinayshah-888/csf/blob/main/frontend/src/components/ui.jsx"

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_gateway,node_framing,node_jwt,node_jwks,node_resilience,node_extraction,node_normalization,node_client toneBlue
class node_s1,node_sidecar,node_semantic,node_sql,node_shell,node_traversal,node_xss,node_features,node_learned toneAmber
class node_decision,node_verdict,node_config,node_integrity,node_telemetry toneMint
class node_console toneRose
class node_frontend,node_api,node_dashboard,node_attacklab,node_jwtlab,node_traffic,node_benchmarks,node_scenarios,node_ui,node_upstream,node_operator toneIndigo
```

## Components

### Gateway & admission

- [Inline gateway](https://github.com/jinayshah-888/csf/blob/main/backend/csf/gateway.py): `backend/csf/gateway.py`
- [HTTP framing](https://github.com/jinayshah-888/csf/blob/main/backend/csf/framing.py): `backend/csf/framing.py`
- [JWT verification](https://github.com/jinayshah-888/csf/blob/main/backend/csf/jwtverify.py): `backend/csf/jwtverify.py`
- [JWKS rotation](https://github.com/jinayshah-888/csf/blob/main/backend/csf/jwks.py): `backend/csf/jwks.py`
- [Rate limits & breaker](https://github.com/jinayshah-888/csf/blob/main/backend/csf/resilience.py): `backend/csf/resilience.py`
- [Request extraction](https://github.com/jinayshah-888/csf/blob/main/backend/csf/extraction.py): `backend/csf/extraction.py`
- [Value normalization](https://github.com/jinayshah-888/csf/blob/main/backend/csf/normalization.py): `backend/csf/normalization.py`

### Detection cascade

- [CRS rules](https://github.com/jinayshah-888/csf/blob/main/backend/csf/s1_rules.py): `backend/csf/s1_rules.py`
- [Coraza sidecar](https://github.com/jinayshah-888/csf/blob/main/s1-sidecar/main.go): `s1-sidecar/main.go`
- [Semantic detector](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/detector.py): `backend/csf/semantic/detector.py`
- [SQL analysis](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/sql.py): `backend/csf/semantic/sql.py`
- [Shell analysis](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/shell.py): `backend/csf/semantic/shell.py`
- [Traversal analysis](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/traversal.py): `backend/csf/semantic/traversal.py`
- [XSS analysis](https://github.com/jinayshah-888/csf/blob/main/backend/csf/semantic/xss.py): `backend/csf/semantic/xss.py`
- [Model features](https://github.com/jinayshah-888/csf/blob/main/backend/csf/model/features.py): `backend/csf/model/features.py`
- [Learned detector](https://github.com/jinayshah-888/csf/blob/main/backend/csf/model/detector.py): `backend/csf/model/detector.py`

### Policy & observability

- [Decision engine](https://github.com/jinayshah-888/csf/blob/main/backend/csf/decision.py): `backend/csf/decision.py`
- [Verdict types](https://github.com/jinayshah-888/csf/blob/main/backend/csf/verdict.py): `backend/csf/verdict.py`
- [Runtime configuration](https://github.com/jinayshah-888/csf/blob/main/backend/csf/config.py): `backend/csf/config.py`
- [Config integrity](https://github.com/jinayshah-888/csf/blob/main/backend/csf/config_integrity.py): `backend/csf/config_integrity.py`
- [Telemetry & metrics](https://github.com/jinayshah-888/csf/blob/main/backend/csf/telemetry.py): `backend/csf/telemetry.py`

### Console API

- [Console API](https://github.com/jinayshah-888/csf/blob/main/console-api/server.py): `console-api/server.py`

### Dashboard

- [Dashboard app](https://github.com/jinayshah-888/csf/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Dashboard API client](https://github.com/jinayshah-888/csf/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Status dashboard](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Attack lab](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/AttackLab.jsx): `frontend/src/pages/AttackLab.jsx`
- [JWT lab](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/JwtLab.jsx): `frontend/src/pages/JwtLab.jsx`
- [Traffic view](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Traffic.jsx): `frontend/src/pages/Traffic.jsx`
- [Benchmarks view](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Benchmarks.jsx): `frontend/src/pages/Benchmarks.jsx`
- [Scenarios view](https://github.com/jinayshah-888/csf/blob/main/frontend/src/pages/Scenarios.jsx): `frontend/src/pages/Scenarios.jsx`
- [Shared UI components](https://github.com/jinayshah-888/csf/blob/main/frontend/src/components/ui.jsx): `frontend/src/components/ui.jsx`

### Other components

- **HTTP client**
- **Protected upstream**
- **Operator**

## Connections

- HTTP client → Inline gateway: sends requests (evidence: `README.md`)
- Inline gateway → HTTP framing: checks framing (evidence: `backend/csf/gateway.py`)
- Inline gateway → JWT verification: verifies tokens (evidence: `backend/csf/gateway.py`)
- Inline gateway → Rate limits & breaker: applies limits (evidence: `backend/csf/gateway.py`)
- Inline gateway → Request extraction: extracts values (evidence: `backend/csf/gateway.py`)
- Request extraction → Value normalization: normalizes values (evidence: `backend/csf/extraction.py`)
- Inline gateway → CRS rules: runs stage (evidence: `backend/csf/main.py`)
- CRS rules → Coraza sidecar: queries rules (evidence: `README.md`)
- Inline gateway → Semantic detector: runs stage (evidence: `backend/csf/main.py`)
- Semantic detector → SQL analysis: analyzes SQL (evidence: `backend/csf/semantic/detector.py`)
- Semantic detector → Shell analysis: analyzes shell (evidence: `backend/csf/semantic/detector.py`)
- Semantic detector → Traversal analysis: analyzes paths (evidence: `backend/csf/semantic/detector.py`)
- Semantic detector → XSS analysis: analyzes XSS (evidence: `backend/csf/semantic/detector.py`)
- Inline gateway → Learned detector: runs stage (evidence: `backend/csf/main.py`)
- Learned detector → Model features: builds features (evidence: `backend/csf/model/detector.py`)
- Model features → Request extraction: reads candidates (evidence: `backend/csf/model/features.py`)
- Inline gateway → Decision engine: submits evidence (evidence: `backend/csf/gateway.py`)
- Decision engine → Verdict types: uses verdict types (evidence: `backend/csf/decision.py`)
- Inline gateway → Protected upstream: forwards allowed traffic (evidence: `README.md`)
- Inline gateway → Telemetry & metrics: records activity (evidence: `backend/csf/gateway.py`)
- Operator → Console API: inspects gateway (evidence: `console-api/server.py`)
- Runtime configuration → HTTP framing: configures (evidence: `backend/csf/config.py`)
- Runtime configuration → Rate limits & breaker: configures (evidence: `backend/csf/config.py`)
- Config integrity → Runtime configuration: checks integrity (evidence: `README.md`)
- Console API → Inline gateway: builds gateway (evidence: `console-api/server.py`)
- Dashboard app → Status dashboard: renders page (evidence: `frontend/src/App.jsx`)
- Dashboard app → Attack lab: renders page (evidence: `frontend/src/App.jsx`)
- Dashboard app → JWT lab: renders page (evidence: `frontend/src/App.jsx`)
- Dashboard app → Traffic view: renders page (evidence: `frontend/src/App.jsx`)
- Dashboard app → Benchmarks view: renders page (evidence: `frontend/src/App.jsx`)
- Dashboard app → Dashboard API client: calls (evidence: `frontend/src/App.jsx`)
- Dashboard API client → Console API: requests console data (evidence: `README.md`)
- Attack lab → Scenarios view: uses scenarios (evidence: `frontend/src/pages/AttackLab.jsx`)
- Status dashboard → Shared UI components: renders with (evidence: `frontend/src/pages/Dashboard.jsx`)
- Attack lab → Shared UI components: renders with (evidence: `frontend/src/pages/AttackLab.jsx`)
- JWT lab → Shared UI components: renders with (evidence: `frontend/src/pages/JwtLab.jsx`)
- Traffic view → Shared UI components: renders with (evidence: `frontend/src/pages/Traffic.jsx`)
- Benchmarks view → Shared UI components: renders with (evidence: `frontend/src/pages/Benchmarks.jsx`)
- Scenarios view → Shared UI components: renders with (evidence: `frontend/src/pages/Scenarios.jsx`)
- JWT verification → JWKS rotation: uses key rotation (evidence: `README.md`)
