# taylorliu11/securitylog-cleaning architecture

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

- Interactive diagram: https://gitdiagram.com/taylorliu11/securitylog-cleaning
- Repository: https://github.com/taylorliu11/securitylog-cleaning

## Overview

##### What this project is (type + purpose)
From the tree + README, this is an **ETL pipeline** project focused on **processing raw AWS Honeypot security logs**. It has three major parts:
- **ETL scripts (Python)**: cleaning + loading logic (`etl/cleaner.py`, `etl/database_loader.py`)
- **Backend service (TypeScript/Node, likely Cloudflare Workers)**: API/RPC layer (`backend/src/index.ts`, `backend/wrangler.toml`)
- **Frontend (static HTML)**: minimal UI entrypoint (`frontend/index.html`)
- **SQL assets**: schema + stored procedures/RPC (`sql/setup_table.sql`, `sql/dashboard_rpc.sql`)
- **CI/CD deployment**: GitHub Actions workflow (`.github/workflows/deploy.yml`)

##### ETL layer (`etl/`)
- `cleaner.py`: transformation/normalization of raw logs (parse, sanitize, dedupe, enrich, etc.)
- `database_loader.py`: persistence step (connects to DB, inserts/updates tables)

##### Database layer (`sql/`)
- `setup_table.sql`: initial schema/table definitions
- `dashboard_rpc.sql`: database-side RPC functions / views / stored queries to support dashboarding

##### Backend API layer (`backend/`)
- `src/index.ts`: request handler / API routes / RPC proxy
- `wrangler.toml`: strong indicator this is **Cloudflare Workers** (or at least wrangler-based deployment)
- `package.json` + `tsconfig.json`: TypeScript build tooling

##### Frontend (`frontend/`)
- `index.html`: likely a static page (maybe a simple dashboard, possibly calling backend endpoints)

##### Deployment (`.github/workflows/deploy.yml`)
CI/CD as a side-lane: “GitHub Actions deploy → Worker + (maybe) frontend hosting”. Even if minimal, include it because it explains how things get released.

##### What to include from the README (and what’s missing)
- which DB is used (D1, Postgres, Supabase, R2, etc.)
- what endpoints exist and whether it’s true “RPC” passthrough
- Inspect `etl/database_loader.py` for:
- connection string type (psycopg2, sqlalchemy, sqlite, etc.)
- target tables and write patterns (append-only vs upsert, partitioning, etc.)

##### Raw AWS Honeypot Logs (Source)
- “AWS” boundary around it if applicable

##### ETL Batch Pipeline (Python)
- Optional: “Scheduler/Trigger” (cron, GitHub Actions, AWS EventBridge) — mark TBD if not found

##### Database
- “Schema: setup_table.sql”
- “RPC/queries: dashboard_rpc.sql”

##### Backend API (Cloudflare Worker, TypeScript)
- `src/index.ts`
- Deployed via `wrangler.toml`
- Role: serves dashboard data, calls DB RPC or runs queries

##### Frontend (Static Web UI)
- `frontend/index.html`
- Role: calls backend API, renders dashboard

##### CI/CD
- GitHub Actions workflow (`deploy.yml`) deploying worker and possibly frontend/sql migrations

- **Logs Source → ETL Cleaner**
- **ETL Cleaner → ETL Loader**
- **ETL Loader → Database**
- **Frontend → Backend API**
- **Backend API → Database**
- **DB → Backend API → Frontend**

- **GitHub Actions → Cloudflare Workers**
- **GitHub Actions → Static Hosting** (if used)

##### Architectural patterns/design principles
- **Separation of concerns**:
- Batch ETL (Python) is isolated from online serving (Worker + frontend)
- **Data contract boundary**:
- Cleaned schema in DB becomes the contract between ETL and serving layer
- **Serverless edge API**:
- Worker provides low-latency API without managing servers
- **DB-centric analytics**:
- `dashboard_rpc.sql` implies pushing aggregation logic into DB for efficiency and consistency

##### Relevant technologies
Where confirmed or strongly implied:
- Python ETL scripts
- TypeScript backend
- Cloudflare Workers/Wrangler (very likely due to `wrangler.toml`)
- SQL migrations / stored procedures
- GitHub Actions for deploy

If DB type isn’t confirmed yet, put “Database (TBD: Postgres/MySQL/D1/…)” until verified.

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% External Sources
%% =========================
subgraph "External Systems (Dashed)" 
direction TB
AWS["AWS Honeypot Logs\n(CloudWatch/S3/etc.) (TBD)"]:::external
Browser["User Browser"]:::external
end

%% =========================
%% Batch / Data Pipeline
%% =========================
subgraph "Batch ETL Pipeline (Python)"
direction TB

Scheduler["Trigger/Scheduler\n(Cron/EventBridge/GitHub Actions) (TBD)"]:::tbd
ETL["ETL Batch Job\n(Python)"]:::etl

subgraph "ETL Steps"
direction TB
Cleaner["ETL Cleaner / Transform\n(normalize/sanitize/dedupe/enrich)\nPython"]:::etl
Loader["ETL Database Loader / Load\n(INSERT/UPSERT cleaned records)\nPython"]:::etl
end

end

%% =========================
%% Data Store
%% =========================
subgraph "Database Layer"
direction TB
DB[("Analytics Database\n(TBD: Postgres/MySQL/D1/...)")]:::db

subgraph "DB Assets (SQL)"
direction TB
SchemaSQL["Schema/Tables\nsetup_table.sql"]:::sql
RPCSQL["Dashboard RPC / Views / Stored Queries\ndashboard_rpc.sql"]:::sql
end

end

%% =========================
%% Serving / Dashboard
%% =========================
subgraph "Online Serving (Cloudflare + Static Web)"
direction TB

Frontend["Static Web UI\nfrontend/index.html"]:::frontend

subgraph "Backend API"
direction TB
Worker["Edge API Service\nCloudflare Worker (wrangler)\nTypeScript"]:::backend
APIHandler["Request Handler / Routes / RPC Proxy\nbackend/src/index.ts"]:::backend
Wrangler["Deployment Config\nwrangler.toml"]:::config
Build["Build/Deps Tooling\npackage.json"]:::config
end

end

%% =========================
%% CI/CD
%% =========================
subgraph "CI/CD"
direction TB
GHA["GitHub Actions Workflow\ndeploy.yml"]:::cicd
end

%% =========================
%% Data Pipeline Flow
%% =========================
AWS -->|"raw_logs"| Cleaner
Scheduler -.->|"invokes"| ETL
ETL -->|"runs"| Cleaner
Cleaner -->|"normalized_events"| Loader
Loader -->|"sql_writes (insert/upsert)"| DB

SchemaSQL -.->|"defines_schema"| DB
RPCSQL -.->|"defines_rpc/views"| DB

%% =========================
%% Serving Flow
%% =========================
Browser -->|"HTTPS (load)"| Frontend
Frontend -->|"HTTPS fetch (JSON)"| Worker
Worker -->|"executes"| APIHandler
APIHandler -->|"SQL queries / RPC calls"| DB
DB -->|"aggregations / metrics"| APIHandler
APIHandler -->|"JSON responses"| Worker
Worker -->|"JSON responses"| Frontend

Wrangler -.->|"configures_deploy"| Worker
Build -.->|"builds_bundle"| Worker

%% =========================
%% CI/CD Flow
%% =========================
GHA -->|"deploys"| Worker
GHA -.->|"deploys (TBD)"| Frontend
GHA -.->|"apply_sql (manual_or_automated) (TBD)"| DB

%% =========================
%% Click Events (from component mapping)
%% =========================
click ETL "https://github.com/taylorliu11/securitylog-cleaning/tree/main/etl/"
click Cleaner "https://github.com/taylorliu11/securitylog-cleaning/blob/main/etl/cleaner.py"
click Loader "https://github.com/taylorliu11/securitylog-cleaning/blob/main/etl/database_loader.py"
click SchemaSQL "https://github.com/taylorliu11/securitylog-cleaning/blob/main/sql/setup_table.sql"
click RPCSQL "https://github.com/taylorliu11/securitylog-cleaning/blob/main/sql/dashboard_rpc.sql"
click APIHandler "https://github.com/taylorliu11/securitylog-cleaning/blob/main/backend/src/index.ts"
click Wrangler "https://github.com/taylorliu11/securitylog-cleaning/blob/main/backend/wrangler.toml"
click Build "https://github.com/taylorliu11/securitylog-cleaning/blob/main/backend/package.json"
click Frontend "https://github.com/taylorliu11/securitylog-cleaning/blob/main/frontend/index.html"
click GHA "https://github.com/taylorliu11/securitylog-cleaning/blob/main/.github/workflows/deploy.yml"

%% =========================
%% Styles
%% =========================
classDef external fill:#ECEFF4,stroke:#4C566A,stroke-width:1.5px,stroke-dasharray: 6 4,color:#2E3440;
classDef etl fill:#E6F4EA,stroke:#2E7D32,stroke-width:1.5px,color:#1B5E20;
classDef db fill:#E8F5E9,stroke:#1B5E20,stroke-width:2px,color:#1B5E20;
classDef sql fill:#FFF3E0,stroke:#EF6C00,stroke-width:1.5px,color:#E65100;
classDef backend fill:#E3F2FD,stroke:#1565C0,stroke-width:1.5px,color:#0D47A1;
classDef frontend fill:#E1F5FE,stroke:#0277BD,stroke-width:1.5px,color:#01579B;
classDef cicd fill:#FFF8E1,stroke:#FF8F00,stroke-width:1.5px,color:#E65100;
classDef config fill:#EDE7F6,stroke:#5E35B1,stroke-width:1.5px,color:#311B92;
classDef tbd fill:#F5F5F5,stroke:#616161,stroke-width:1.5px,stroke-dasharray: 4 3,color:#424242;
```
