# akolovs2/pc_web_monitor architecture

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

- Interactive diagram: https://gitdiagram.com/akolovs2/pc_web_monitor
- Repository: https://github.com/akolovs2/pc_web_monitor

## Overview

HomeLab Monitor is a self-hosted monitoring and container-control application. A user logs in, then views host CPU/RAM and live container data; the dashboard can request container actions. The backend also exposes deprecated process-kill routes. The graph follows documented and excerpted wiring; container implementation details and some runtime integrations are not shown, so those internals are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/main.py) (API application), [`frontend/vite-project/src/App.tsx`](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/App.tsx) (Routes and app), [`frontend/vite-project/src/pages/Metrics.tsx`](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/pages/Metrics.tsx) (Metrics dashboard), [`frontend/vite-project/src/hooks/useMetrics.ts`](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/hooks/useMetrics.ts) (Live metrics hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web dashboard"]
  node_app["Routes and app<br/>[App.tsx]"]
  node_login["Login page<br/>[Login.tsx]"]
  node_authui["Auth client<br/>[auth.ts]"]
  node_guards["Route guards"]
  node_metricsui["Metrics dashboard<br/>[Metrics.tsx]"]
  node_livehook["Live metrics hook<br/>[useMetrics.ts]"]
  node_dashboardparts["Dashboard components"]
  node_metrictypes["Metrics types<br/>[Metrics.ts]"]
end

subgraph group_backend["API and monitoring"]
  node_api["API application<br/>[main.py]"]
  node_metricroutes["Metrics routes<br/>[metrics.py]"]
  node_metricservice["Metrics collection<br/>[metrics_service.py]"]
  node_containeroutes["Container routes<br/>[containers.py]"]
  node_taskroutes["Task routes<br/>[tasks.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_identity["Authentication and persistence"]
  node_authroutes["Auth routes<br/>[auth.py]"]
  node_authservice["Token and user service<br/>[auth_service.py]"]
  node_userdb[("User database<br/>[database.py]")]
end

subgraph group_host["Host integrations"]
  node_containerservice["Container operations"]
  node_processservice["Process control<br/>[process_service.py]"]
end

node_user(("Homelab user"))
node_host(("Monitored host"))
node_browser(("Browser"))

node_user -->|"uses dashboard"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_metricsui
node_app -->|"wraps routes"| node_guards
node_login -->|"submits credentials"| node_authui
node_guards -->|"checks session"| node_authui
node_metricsui -->|"reads live state"| node_livehook
node_metricsui -->|"renders"| node_dashboardparts
node_livehook -.->|"opens WebSocket"| node_api
node_livehook -.->|"requests actions"| node_api
node_livehook -->|"uses data shape"| node_metrictypes
node_metricsui -->|"uses data shape"| node_metrictypes
node_authui -.->|"HTTP auth calls"| node_authroutes
node_api -->|"registers router"| node_authroutes
node_api -->|"registers router"| node_metricroutes
node_api -->|"registers protected router"| node_containeroutes
node_api -->|"registers protected router"| node_taskroutes
node_api -->|"initializes database"| node_userdb
node_api -->|"starts monitor"| node_metricroutes
node_authroutes -->|"calls auth logic"| node_authservice
node_authservice -->|"reads and writes"| node_userdb
node_metricroutes -->|"calls collector"| node_metricservice
node_containeroutes -->|"calls operations"| node_containerservice
node_taskroutes -->|"calls kill process"| node_processservice
node_taskroutes -->|"uses response schema"| node_schemas
node_processservice -.->|"controls processes"| node_host
node_containerservice -.->|"manages Docker"| node_host
node_metricservice -.->|"samples system"| node_host
node_api -.->|"serves API"| node_browser

click node_app "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/App.tsx"
click node_login "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/pages/Login.tsx"
click node_authui "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/services/auth.ts"
click node_guards "https://github.com/akolovs2/pc_web_monitor/tree/main/frontend/vite-project/src/features/auth"
click node_metricsui "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/pages/Metrics.tsx"
click node_livehook "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/hooks/useMetrics.ts"
click node_dashboardparts "https://github.com/akolovs2/pc_web_monitor/tree/main/frontend/vite-project/src/features/dashboard"
click node_metrictypes "https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/types/Metrics.ts"
click node_api "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/auth.py"
click node_authservice "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/auth_service.py"
click node_userdb "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/models/database.py"
click node_metricroutes "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/metrics.py"
click node_metricservice "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/metrics_service.py"
click node_containeroutes "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/containers.py"
click node_containerservice "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/containers_service.py"
click node_taskroutes "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/tasks.py"
click node_processservice "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/process_service.py"
click node_schemas "https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/models/schemas.py"

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_app,node_login,node_authui,node_guards,node_metricsui,node_livehook,node_dashboardparts,node_metrictypes,node_user,node_browser toneBlue
class node_api,node_metricroutes,node_metricservice,node_containeroutes,node_taskroutes,node_schemas toneAmber
class node_authroutes,node_authservice,node_userdb toneMint
class node_containerservice,node_processservice toneRose
class node_host toneIndigo
```

## Components

### Web dashboard

- [Routes and app](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/App.tsx): `frontend/vite-project/src/App.tsx`
- [Login page](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/pages/Login.tsx): `frontend/vite-project/src/pages/Login.tsx`
- [Auth client](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/services/auth.ts): `frontend/vite-project/src/services/auth.ts`
- [Route guards](https://github.com/akolovs2/pc_web_monitor/tree/main/frontend/vite-project/src/features/auth): `frontend/vite-project/src/features/auth`
- [Metrics dashboard](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/pages/Metrics.tsx): `frontend/vite-project/src/pages/Metrics.tsx`
- [Live metrics hook](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/hooks/useMetrics.ts): `frontend/vite-project/src/hooks/useMetrics.ts`
- [Dashboard components](https://github.com/akolovs2/pc_web_monitor/tree/main/frontend/vite-project/src/features/dashboard): `frontend/vite-project/src/features/dashboard`
- [Metrics types](https://github.com/akolovs2/pc_web_monitor/blob/main/frontend/vite-project/src/types/Metrics.ts): `frontend/vite-project/src/types/Metrics.ts`

### API and monitoring

- [API application](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/main.py): `backend/app/main.py`
- [Metrics routes](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/metrics.py): `backend/app/routers/metrics.py`
- [Metrics collection](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/metrics_service.py): `backend/app/services/metrics_service.py`
- [Container routes](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/containers.py): `backend/app/routers/containers.py`
- [Task routes](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/tasks.py): `backend/app/routers/tasks.py`
- [API schemas](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`

### Authentication and persistence

- [Auth routes](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Token and user service](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [User database](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/models/database.py): `backend/app/models/database.py`

### Host integrations

- [Container operations](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/containers_service.py): `backend/app/services/containers_service.py`
- [Process control](https://github.com/akolovs2/pc_web_monitor/blob/main/backend/app/services/process_service.py): `backend/app/services/process_service.py`

### Other components

- **Homelab user**
- **Monitored host**
- **Browser**

## Connections

- Homelab user → Routes and app: uses dashboard (evidence: `frontend/vite-project/src/App.tsx`)
- Routes and app → Login page: routes to (evidence: `frontend/vite-project/src/App.tsx`)
- Routes and app → Metrics dashboard: routes to (evidence: `frontend/vite-project/src/App.tsx`)
- Routes and app → Route guards: wraps routes (evidence: `frontend/vite-project/src/App.tsx`)
- Login page → Auth client: submits credentials (evidence: `frontend/vite-project/src/pages/Login.tsx`)
- Route guards → Auth client: checks session (evidence: `frontend/vite-project/src/features/auth/ProtectedRoute.tsx`)
- Metrics dashboard → Live metrics hook: reads live state (evidence: `frontend/vite-project/src/pages/Metrics.tsx`)
- Metrics dashboard → Dashboard components: renders (evidence: `frontend/vite-project/src/pages/Metrics.tsx`)
- Live metrics hook → API application: opens WebSocket
- Live metrics hook → API application: requests actions
- Live metrics hook → Metrics types: uses data shape (evidence: `frontend/vite-project/src/hooks/useMetrics.ts`)
- Metrics dashboard → Metrics types: uses data shape
- Auth client → Auth routes: HTTP auth calls
- API application → Auth routes: registers router (evidence: `backend/app/main.py`)
- API application → Metrics routes: registers router (evidence: `backend/app/main.py`)
- API application → Container routes: registers protected router (evidence: `backend/app/main.py`)
- API application → Task routes: registers protected router (evidence: `backend/app/main.py`)
- API application → User database: initializes database (evidence: `backend/app/main.py`)
- API application → Metrics routes: starts monitor (evidence: `backend/app/main.py`)
- Auth routes → Token and user service: calls auth logic (evidence: `backend/app/routers/auth.py`)
- Token and user service → User database: reads and writes (evidence: `backend/app/services/auth_service.py`)
- Metrics routes → Metrics collection: calls collector (evidence: `backend/app/routers/metrics.py`)
- Container routes → Container operations: calls operations (evidence: `backend/app/routers/containers.py`)
- Task routes → Process control: calls kill process (evidence: `backend/app/routers/tasks.py`)
- Task routes → API schemas: uses response schema (evidence: `backend/app/routers/tasks.py`)
- Process control → Monitored host: controls processes
- Container operations → Monitored host: manages Docker
- Metrics collection → Monitored host: samples system
- API application → Browser: serves API
