# ramijaber4/logsanalyzer architecture

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

- Interactive diagram: https://gitdiagram.com/ramijaber4/logsanalyzer
- Repository: https://github.com/ramijaber4/logsanalyzer

## Overview

Log Analyzer accepts raw log lines, processes them asynchronously in batches, and exposes aggregated global and per-component metrics through a browser UI and API. The main path runs from a log sender through the FastAPI queue, worker, parser and calculator, then MySQL; the browser uses a lightweight proxy to access API routes and static UI. Reset and health/statistics routes are distinct backend capabilities. The README documents the UI, while its implementation was not sampled; links involving its API use follow the documented proxy behavior.

Main entry points: [`app.py`](https://github.com/ramijaber4/logsanalyzer/blob/main/app.py) (FastAPI routes), [`worker.py`](https://github.com/ramijaber4/logsanalyzer/blob/main/worker.py) (Batch worker), [`frontend/frontend_server.py`](https://github.com/ramijaber4/logsanalyzer/blob/main/frontend/frontend_server.py) (Frontend proxy), [`database.py`](https://github.com/ramijaber4/logsanalyzer/blob/main/database.py) (Database manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser interface"]
  node_ui["HTML and JS UI<br/>[index.html]"]
  node_proxy["Frontend proxy<br/>[frontend_server.py]"]
end

subgraph group_api["API service"]
  node_api_app["FastAPI routes<br/>[app.py]"]
end

subgraph group_processing["Log processing"]
  node_queue["Async log queue<br/>[queue_manager.py]"]
  node_worker["Batch worker<br/>[worker.py]"]
  node_parser["Log parser<br/>[processing_logs.py]"]
  node_calculator["Metrics calculator<br/>[processing_logs.py]"]
end

subgraph group_persistence["Metrics storage"]
  node_db_manager["Database manager<br/>[database.py]"]
  node_schema["Metrics tables<br/>[init.sql]"]
end

node_browser(("Browser user"))
node_sender(("Log sender"))
node_mysql[("MySQL")]

node_browser -->|"requests UI"| node_proxy
node_proxy -->|"serves UI"| node_ui
node_proxy -->|"forwards API"| node_api_app
node_api_app -->|"returns API response"| node_proxy
node_proxy -->|"returns response"| node_browser
node_sender -->|"submits logs"| node_api_app
node_api_app -->|"enqueues logs"| node_queue
node_api_app -->|"reads stats"| node_db_manager
node_db_manager -->|"returns stats"| node_api_app
node_api_app -->|"resets metrics"| node_db_manager
node_api_app -->|"resets memory"| node_calculator
node_worker -->|"dequeues logs"| node_queue
node_worker -->|"parses lines"| node_parser
node_parser -->|"returns log"| node_worker
node_worker -->|"aggregates logs"| node_calculator
node_worker -->|"flushes batches"| node_db_manager
node_db_manager -->|"queries and updates"| node_mysql
node_schema -->|"defines tables"| node_mysql

click node_ui "https://github.com/ramijaber4/logsanalyzer/blob/main/frontend/index.html"
click node_proxy "https://github.com/ramijaber4/logsanalyzer/blob/main/frontend/frontend_server.py"
click node_api_app "https://github.com/ramijaber4/logsanalyzer/blob/main/app.py"
click node_queue "https://github.com/ramijaber4/logsanalyzer/blob/main/queue_manager.py"
click node_worker "https://github.com/ramijaber4/logsanalyzer/blob/main/worker.py"
click node_parser "https://github.com/ramijaber4/logsanalyzer/blob/main/processing_logs.py"
click node_calculator "https://github.com/ramijaber4/logsanalyzer/blob/main/processing_logs.py"
click node_db_manager "https://github.com/ramijaber4/logsanalyzer/blob/main/database.py"
click node_schema "https://github.com/ramijaber4/logsanalyzer/blob/main/init.sql"

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_ui,node_proxy,node_browser toneBlue
class node_api_app,node_mysql toneAmber
class node_queue,node_worker,node_parser,node_calculator toneMint
class node_db_manager,node_schema toneRose
class node_sender toneIndigo
```

## Components

### Browser interface

- [HTML and JS UI](https://github.com/ramijaber4/logsanalyzer/blob/main/frontend/index.html): `frontend/index.html`
- [Frontend proxy](https://github.com/ramijaber4/logsanalyzer/blob/main/frontend/frontend_server.py): `frontend/frontend_server.py`

### API service

- [FastAPI routes](https://github.com/ramijaber4/logsanalyzer/blob/main/app.py): `app.py`

### Log processing

- [Async log queue](https://github.com/ramijaber4/logsanalyzer/blob/main/queue_manager.py): `queue_manager.py`
- [Batch worker](https://github.com/ramijaber4/logsanalyzer/blob/main/worker.py): `worker.py`
- [Log parser](https://github.com/ramijaber4/logsanalyzer/blob/main/processing_logs.py): `processing_logs.py`
- [Metrics calculator](https://github.com/ramijaber4/logsanalyzer/blob/main/processing_logs.py): `processing_logs.py`

### Metrics storage

- [Database manager](https://github.com/ramijaber4/logsanalyzer/blob/main/database.py): `database.py`
- [Metrics tables](https://github.com/ramijaber4/logsanalyzer/blob/main/init.sql): `init.sql`

### Other components

- **Browser user**
- **Log sender**
- **MySQL**

## Connections

- Browser user → Frontend proxy: requests UI
- Frontend proxy → HTML and JS UI: serves UI
- Frontend proxy → FastAPI routes: forwards API
- FastAPI routes → Frontend proxy: returns API response
- Frontend proxy → Browser user: returns response
- Log sender → FastAPI routes: submits logs
- FastAPI routes → Async log queue: enqueues logs
- FastAPI routes → Database manager: reads stats
- Database manager → FastAPI routes: returns stats
- FastAPI routes → Database manager: resets metrics
- FastAPI routes → Metrics calculator: resets memory
- Batch worker → Async log queue: dequeues logs
- Batch worker → Log parser: parses lines
- Log parser → Batch worker: returns log
- Batch worker → Metrics calculator: aggregates logs
- Batch worker → Database manager: flushes batches
- Database manager → MySQL: queries and updates
- Metrics tables → MySQL: defines tables
