# nagyun-oh/2026_kw_capstone_project architecture

> Architecture diagram of the GitHub repository nagyun-oh/2026_kw_capstone_project, 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/nagyun-oh/2026_kw_capstone_project
- Repository: https://github.com/nagyun-oh/2026_kw_capstone_project

## Overview

This project collects web-security logs, analyzes requests with a FastAPI threat-detection service, stores logs and detections through a Spring backend, and presents them to administrators in a React dashboard. The central path is log ingestion and asynchronous analysis, followed by persisted results and dashboard queries; administrators can also authenticate and manage blacklist entries. The AI data-preparation and inference layers are shown separately. Backend internals, Kafka wiring, database access, and some integrations are documented in the README but their implementation files are absent from the supplied tree, so those links cite the README.

Main entry points: [`AI_new/security_ai/serving/predictor.py`](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/serving/predictor.py) (Ensemble Predictor), [`backend`](https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend) (Backend APIs), [`AI_new/security_ai/data/pipeline.py`](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/pipeline.py) (Dataset Pipeline), [`AI_new/main.py`](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/main.py) (AI API and Consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Request Edge"]
  node_waf["WAF and Proxy<br/>[headers.js]"]
end

subgraph group_ai["AI Analysis"]
  node_ai_service["AI API and Consumer<br/>[main.py]"]
  node_parsers["Request Parsers<br/>[parsers.py]"]
  node_record_schema["HTTP Record Schema<br/>[schema.py]"]
  node_canonical["Canonicalization<br/>[canonical.py]"]
  node_data_pipeline["Dataset Pipeline<br/>[pipeline.py]"]
  node_byte_tokenizer["Byte Tokenizer<br/>[byte_tokenizer.py]"]
  node_structural["Structural Features"]
  node_transformer["Byte Transformer<br/>[transformer.py]"]
  node_artifact["Model Artifacts<br/>[model_artifact.py]"]
  node_predictor["Ensemble Predictor<br/>[predictor.py]"]
  node_explainer["Prediction Explanations<br/>[explainer.py]"]
end

subgraph group_backend["Backend Services"]
  node_ingest["Log Ingestion"]
  node_backend_api["Backend APIs"]
  node_auth["Session Authentication"]
end

subgraph group_storage["Persistence and Messaging"]
  node_broker["Kafka"]
  node_database[("MySQL")]
end

subgraph group_ui["Admin Dashboard"]
  node_frontend_app["Admin App<br/>[App.js]"]
  node_auth_hook["Authentication State<br/>[useAuth.js]"]
  node_api_client["HTTP API Client<br/>[apiClient.js]"]
  node_security_data["Security Data Queries<br/>[useSecurityData.js]"]
  node_dashboard["Security Dashboard<br/>[Dashboard.js]"]
  node_websocket["Live Notifications<br/>[useWebSocket.js]"]
end

node_client(("Web Request"))
node_admin(("Administrator"))

node_client -->|"sends requests"| node_waf
node_waf -->|"routes traffic"| node_ingest
node_ingest -->|"publishes logs"| node_broker
node_broker -->|"streams logs"| node_ai_service
node_ai_service -->|"publishes detections"| node_broker
node_ai_service -->|"runs inference"| node_predictor
node_parsers -->|"normalizes records"| node_canonical
node_parsers -->|"creates records"| node_record_schema
node_data_pipeline -->|"parses datasets"| node_parsers
node_data_pipeline -->|"canonicalizes records"| node_canonical
node_data_pipeline -->|"uses record schema"| node_record_schema
node_predictor -->|"prepares requests"| node_data_pipeline
node_predictor -->|"tokenizes requests"| node_byte_tokenizer
node_predictor -->|"extracts features"| node_structural
node_predictor -->|"scores requests"| node_transformer
node_predictor -->|"loads models"| node_artifact
node_predictor -->|"explains results"| node_explainer
node_predictor -->|"returns predictions"| node_ai_service
node_broker -->|"delivers detections"| node_ingest
node_ingest -->|"stores logs"| node_database
node_ingest -.->|"provides log APIs"| node_backend_api
node_backend_api -->|"reads and writes"| node_database
node_backend_api -->|"enforces sessions"| node_auth
node_backend_api -->|"consumes log stream"| node_broker
node_backend_api -.->|"notifies dashboard"| node_broker
node_admin -->|"uses dashboard"| node_frontend_app
node_frontend_app -->|"checks session"| node_auth_hook
node_auth_hook -->|"sends auth requests"| node_api_client
node_frontend_app -->|"shows security data"| node_dashboard
node_dashboard -->|"loads records"| node_security_data
node_security_data -->|"queries APIs"| node_api_client
node_api_client -->|"calls REST APIs"| node_backend_api
node_dashboard -->|"opens live channel"| node_websocket
node_websocket -.->|"receives notifications"| node_backend_api

click node_waf "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/waf/njs/headers.js"
click node_ingest "https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend"
click node_ai_service "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/main.py"
click node_parsers "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/parsers.py"
click node_record_schema "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/schema.py"
click node_canonical "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/canonical.py"
click node_data_pipeline "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/pipeline.py"
click node_byte_tokenizer "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/byte_tokenizer.py"
click node_structural "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/structural_features.py"
click node_transformer "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/transformer.py"
click node_artifact "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/serving/model_artifact.py"
click node_predictor "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/serving/predictor.py"
click node_explainer "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/xai/explainer.py"
click node_backend_api "https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend"
click node_auth "https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend"
click node_frontend_app "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/App.js"
click node_auth_hook "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useAuth.js"
click node_api_client "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/api/apiClient.js"
click node_security_data "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useSecurityData.js"
click node_dashboard "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/Dashboard.js"
click node_websocket "https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useWebSocket.js"

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_waf toneBlue
class node_ai_service,node_parsers,node_record_schema,node_canonical,node_data_pipeline,node_byte_tokenizer,node_structural,node_transformer,node_artifact,node_predictor,node_explainer toneAmber
class node_ingest,node_backend_api,node_auth,node_client toneMint
class node_broker,node_database toneRose
class node_frontend_app,node_auth_hook,node_api_client,node_security_data,node_dashboard,node_websocket,node_admin toneIndigo
```

## Components

### Request Edge

- [WAF and Proxy](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/waf/njs/headers.js): `waf/njs/headers.js`

### AI Analysis

- [AI API and Consumer](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/main.py): `AI_new/main.py`
- [Request Parsers](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/parsers.py): `AI_new/security_ai/data/parsers.py`
- [HTTP Record Schema](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/schema.py): `AI_new/security_ai/data/schema.py`
- [Canonicalization](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/canonical.py): `AI_new/security_ai/data/canonical.py`
- [Dataset Pipeline](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/data/pipeline.py): `AI_new/security_ai/data/pipeline.py`
- [Byte Tokenizer](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/byte_tokenizer.py): `AI_new/security_ai/model/byte_tokenizer.py`
- [Structural Features](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/structural_features.py): `AI_new/security_ai/model/structural_features.py`
- [Byte Transformer](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/model/transformer.py): `AI_new/security_ai/model/transformer.py`
- [Model Artifacts](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/serving/model_artifact.py): `AI_new/security_ai/serving/model_artifact.py`
- [Ensemble Predictor](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/serving/predictor.py): `AI_new/security_ai/serving/predictor.py`
- [Prediction Explanations](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/AI_new/security_ai/xai/explainer.py): `AI_new/security_ai/xai/explainer.py`

### Backend Services

- [Log Ingestion](https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend): `backend`
- [Backend APIs](https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend): `backend`
- [Session Authentication](https://github.com/nagyun-oh/2026_kw_capstone_project/tree/develop/backend): `backend`

### Persistence and Messaging

- **Kafka**
- **MySQL**

### Admin Dashboard

- [Admin App](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/App.js): `frontend/src/App.js`
- [Authentication State](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useAuth.js): `frontend/src/hooks/useAuth.js`
- [HTTP API Client](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/api/apiClient.js): `frontend/src/api/apiClient.js`
- [Security Data Queries](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useSecurityData.js): `frontend/src/hooks/useSecurityData.js`
- [Security Dashboard](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/Dashboard.js): `frontend/src/Dashboard.js`
- [Live Notifications](https://github.com/nagyun-oh/2026_kw_capstone_project/blob/develop/frontend/src/hooks/useWebSocket.js): `frontend/src/hooks/useWebSocket.js`

### Other components

- **Web Request**
- **Administrator**

## Connections

- Web Request → WAF and Proxy: sends requests (evidence: `README.md`)
- WAF and Proxy → Log Ingestion: routes traffic (evidence: `README.md`)
- Log Ingestion → Kafka: publishes logs (evidence: `README.md`)
- Kafka → AI API and Consumer: streams logs (evidence: `README.md`)
- AI API and Consumer → Kafka: publishes detections (evidence: `AI_new/main.py`)
- AI API and Consumer → Ensemble Predictor: runs inference (evidence: `AI_new/main.py`)
- Request Parsers → Canonicalization: normalizes records (evidence: `AI_new/security_ai/data/parsers.py`)
- Request Parsers → HTTP Record Schema: creates records (evidence: `AI_new/security_ai/data/parsers.py`)
- Dataset Pipeline → Request Parsers: parses datasets (evidence: `AI_new/security_ai/data/pipeline.py`)
- Dataset Pipeline → Canonicalization: canonicalizes records (evidence: `AI_new/security_ai/data/pipeline.py`)
- Dataset Pipeline → HTTP Record Schema: uses record schema (evidence: `AI_new/security_ai/data/pipeline.py`)
- Ensemble Predictor → Dataset Pipeline: prepares requests (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → Byte Tokenizer: tokenizes requests (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → Structural Features: extracts features (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → Byte Transformer: scores requests (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → Model Artifacts: loads models (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → Prediction Explanations: explains results (evidence: `AI_new/security_ai/serving/predictor.py`)
- Ensemble Predictor → AI API and Consumer: returns predictions (evidence: `AI_new/main.py`)
- Kafka → Log Ingestion: delivers detections (evidence: `README.md`)
- Log Ingestion → MySQL: stores logs (evidence: `README.md`)
- Log Ingestion → Backend APIs: provides log APIs
- Backend APIs → MySQL: reads and writes (evidence: `README.md`)
- Backend APIs → Session Authentication: enforces sessions (evidence: `README.md`)
- Backend APIs → Kafka: consumes log stream (evidence: `README.md`)
- Backend APIs → Kafka: notifies dashboard (evidence: `README.md`)
- Administrator → Admin App: uses dashboard (evidence: `README.md`)
- Admin App → Authentication State: checks session (evidence: `frontend/src/App.js`)
- Authentication State → HTTP API Client: sends auth requests (evidence: `frontend/src/hooks/useAuth.js`)
- Admin App → Security Dashboard: shows security data (evidence: `frontend/src/App.js`)
- Security Dashboard → Security Data Queries: loads records (evidence: `frontend/src/Dashboard.js`)
- Security Data Queries → HTTP API Client: queries APIs (evidence: `frontend/src/hooks/useSecurityData.js`)
- HTTP API Client → Backend APIs: calls REST APIs (evidence: `README.md`)
- Security Dashboard → Live Notifications: opens live channel (evidence: `frontend/src/Dashboard.js`)
- Live Notifications → Backend APIs: receives notifications (evidence: `README.md`)
