# t3j45-r41/adaptive_cache_redis architecture

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

- Interactive diagram: https://gitdiagram.com/t3j45-r41/adaptive_cache_redis
- Repository: https://github.com/t3j45-r41/adaptive_cache_redis

## Overview

This repository is a stock-quote caching and comparative eviction-policy study, with a Redis-compatible C++ server, a Python API and MySQL persistence, and a React monitoring dashboard. The main workflow is dashboard or experiment requests through the API to the cache and relational data, with quote ingestion and workload generation supporting evaluation. The tree and excerpts show the API, cache, and persistence boundaries; benchmark execution internals and some subsystem wiring are not fully shown, so those links are omitted or documented at a high level.

Main entry points: [`frontend/src/App.tsx`](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/App.tsx) (Dashboard App), [`backend/app/main.py`](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/app/main.py) (FastAPI App), [`python/database/connection.py`](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/database/connection.py) (Relational Database), [`backend/services/db_service.py`](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/services/db_service.py) (Database Queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cache["Cache Server"]
  node_server_entry["Server Startup<br/>[main.cpp]"]
  node_tcp_server["RESP TCP Server<br/>[RedisServer.cpp]"]
  node_command_handler["Command Handler"]
  node_cache_db[("Cache Operations<br/>[RedisDatabase.cpp]")]
  node_policy_engine["Eviction Policies"]
end

subgraph group_data["Market Data"]
  node_database[("Relational Database<br/>[connection.py]")]
  node_ingestion["Quote Ingestion<br/>[stock_ingestion.py]"]
  node_workloads["Workload Generation"]
  node_analytics["Analytics Plots<br/>[analytics_plots.py]"]
end

subgraph group_api["API and Analytics"]
  node_api_app["FastAPI App<br/>[main.py]"]
  node_dashboard_routes["Dashboard Routes<br/>[dashboard.py]"]
  node_cache_routes["Cache Routes<br/>[cache.py]"]
  node_experiment_routes["Experiment Routes<br/>[experiments.py]"]
  node_analytics_routes["Analytics Routes<br/>[analytics.py]"]
  node_stock_routes["Stock Routes<br/>[stocks.py]"]
  node_db_service["Database Queries<br/>[db_service.py]"]
  node_redis_service["Redis Client<br/>[redis_service.py]"]
end

subgraph group_ui["Monitoring Dashboard"]
  node_dashboard["Dashboard App<br/>[App.tsx]"]
  node_api_client["API Client<br/>[api.ts]"]
  node_overview["Overview and Comparisons"]
  node_adaptive_view["Adaptive Monitoring"]
  node_benchmark_view["Benchmark Controls"]
  node_dbms_view["DBMS Analytics"]
  node_stock_view["Stock Market View"]
end

node_operator(("Dashboard User"))
node_mysql[("MySQL Service")]
node_finance_api["Yahoo Finance"]
node_benchmark_client["Benchmark Client"]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"requests data"| node_api_client
node_dashboard -->|"renders"| node_overview
node_dashboard -->|"renders"| node_adaptive_view
node_dashboard -->|"renders"| node_benchmark_view
node_dashboard -->|"renders"| node_dbms_view
node_dashboard -->|"renders"| node_stock_view
node_api_client -->|"calls REST"| node_api_app
node_api_app -->|"registers"| node_dashboard_routes
node_api_app -->|"registers"| node_cache_routes
node_api_app -->|"registers"| node_experiment_routes
node_api_app -->|"registers"| node_analytics_routes
node_api_app -->|"registers"| node_stock_routes
node_dashboard_routes -->|"reads cache"| node_redis_service
node_dashboard_routes -->|"queries metrics"| node_db_service
node_cache_routes -->|"controls cache"| node_redis_service
node_experiment_routes -->|"stores results"| node_db_service
node_analytics_routes -->|"queries metrics"| node_db_service
node_stock_routes -->|"reads quotes"| node_db_service
node_stock_routes -->|"checks cache"| node_redis_service
node_db_service -->|"executes queries"| node_database
node_database -->|"connects to"| node_mysql
node_ingestion -->|"stores quotes"| node_database
node_finance_api -->|"provides quotes"| node_ingestion
node_workloads -.->|"loads market data"| node_database
node_benchmark_client -->|"sends RESP2"| node_tcp_server
node_server_entry -->|"starts"| node_tcp_server
node_server_entry -->|"configures and restores"| node_cache_db
node_tcp_server -.->|"dispatches commands"| node_command_handler
node_command_handler -->|"executes commands"| node_cache_db
node_cache_db -->|"updates policy"| node_policy_engine
node_redis_service -->|"sends RESP commands"| node_tcp_server
node_analytics -.->|"uses persisted data"| node_database

click node_dashboard "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/services/api.ts"
click node_overview "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/OverviewSection.tsx"
click node_adaptive_view "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/AdaptiveMonitoringSection.tsx"
click node_benchmark_view "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/BenchmarkControlSection.tsx"
click node_dbms_view "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/DBMSAnalyticsSection.tsx"
click node_stock_view "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/StockMarketSection.tsx"
click node_api_app "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/app/main.py"
click node_dashboard_routes "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/dashboard.py"
click node_cache_routes "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/cache.py"
click node_experiment_routes "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/experiments.py"
click node_analytics_routes "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/analytics.py"
click node_stock_routes "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/stocks.py"
click node_db_service "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/services/db_service.py"
click node_redis_service "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/services/redis_service.py"
click node_database "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/database/connection.py"
click node_ingestion "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/ingestion/stock_ingestion.py"
click node_workloads "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/workload/workload_generator.py"
click node_analytics "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/analytics/analytics_plots.py"
click node_server_entry "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/main.cpp"
click node_tcp_server "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisServer.cpp"
click node_command_handler "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisCommandHandler.cpp"
click node_cache_db "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisDatabase.cpp"
click node_policy_engine "https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/eviction/AdaptiveEvictionPolicy.cpp"

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_server_entry,node_tcp_server,node_command_handler,node_cache_db,node_policy_engine,node_operator,node_benchmark_client toneBlue
class node_database,node_ingestion,node_workloads,node_analytics,node_mysql toneAmber
class node_api_app,node_dashboard_routes,node_cache_routes,node_experiment_routes,node_analytics_routes,node_stock_routes,node_db_service,node_redis_service toneMint
class node_dashboard,node_api_client,node_overview,node_adaptive_view,node_benchmark_view,node_dbms_view,node_stock_view toneRose
class node_finance_api toneIndigo
```

## Components

### Cache Server

- [Server Startup](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/main.cpp): `Redis-Server/src/main.cpp`
- [RESP TCP Server](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisServer.cpp): `Redis-Server/src/RedisServer.cpp`
- [Command Handler](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisCommandHandler.cpp): `Redis-Server/src/RedisCommandHandler.cpp`
- [Cache Operations](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/src/RedisDatabase.cpp): `Redis-Server/src/RedisDatabase.cpp`
- [Eviction Policies](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/Redis-Server/eviction/AdaptiveEvictionPolicy.cpp): `Redis-Server/eviction/AdaptiveEvictionPolicy.cpp`

### Market Data

- [Relational Database](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/database/connection.py): `python/database/connection.py`
- [Quote Ingestion](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/ingestion/stock_ingestion.py): `python/ingestion/stock_ingestion.py`
- [Workload Generation](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/workload/workload_generator.py): `python/workload/workload_generator.py`
- [Analytics Plots](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/python/analytics/analytics_plots.py): `python/analytics/analytics_plots.py`

### API and Analytics

- [FastAPI App](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/app/main.py): `backend/app/main.py`
- [Dashboard Routes](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/dashboard.py): `backend/routes/dashboard.py`
- [Cache Routes](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/cache.py): `backend/routes/cache.py`
- [Experiment Routes](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/experiments.py): `backend/routes/experiments.py`
- [Analytics Routes](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/analytics.py): `backend/routes/analytics.py`
- [Stock Routes](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/routes/stocks.py): `backend/routes/stocks.py`
- [Database Queries](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/services/db_service.py): `backend/services/db_service.py`
- [Redis Client](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/backend/services/redis_service.py): `backend/services/redis_service.py`

### Monitoring Dashboard

- [Dashboard App](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API Client](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Overview and Comparisons](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/OverviewSection.tsx): `frontend/src/components/OverviewSection.tsx`
- [Adaptive Monitoring](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/AdaptiveMonitoringSection.tsx): `frontend/src/components/AdaptiveMonitoringSection.tsx`
- [Benchmark Controls](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/BenchmarkControlSection.tsx): `frontend/src/components/BenchmarkControlSection.tsx`
- [DBMS Analytics](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/DBMSAnalyticsSection.tsx): `frontend/src/components/DBMSAnalyticsSection.tsx`
- [Stock Market View](https://github.com/t3j45-r41/adaptive_cache_redis/blob/main/frontend/src/components/StockMarketSection.tsx): `frontend/src/components/StockMarketSection.tsx`

### Other components

- **Dashboard User**
- **MySQL Service**
- **Yahoo Finance**
- **Benchmark Client**

## Connections

- Dashboard User → Dashboard App: uses
- Dashboard App → API Client: requests data (evidence: `frontend/src/App.tsx`)
- Dashboard App → Overview and Comparisons: renders (evidence: `frontend/src/App.tsx`)
- Dashboard App → Adaptive Monitoring: renders (evidence: `frontend/src/App.tsx`)
- Dashboard App → Benchmark Controls: renders (evidence: `frontend/src/App.tsx`)
- Dashboard App → DBMS Analytics: renders (evidence: `frontend/src/App.tsx`)
- Dashboard App → Stock Market View: renders (evidence: `frontend/src/App.tsx`)
- API Client → FastAPI App: calls REST (evidence: `frontend/src/services/api.ts`)
- FastAPI App → Dashboard Routes: registers (evidence: `backend/app/main.py`)
- FastAPI App → Cache Routes: registers (evidence: `backend/app/main.py`)
- FastAPI App → Experiment Routes: registers (evidence: `backend/app/main.py`)
- FastAPI App → Analytics Routes: registers (evidence: `backend/app/main.py`)
- FastAPI App → Stock Routes: registers (evidence: `backend/app/main.py`)
- Dashboard Routes → Redis Client: reads cache (evidence: `backend/routes/dashboard.py`)
- Dashboard Routes → Database Queries: queries metrics (evidence: `backend/routes/dashboard.py`)
- Cache Routes → Redis Client: controls cache (evidence: `backend/routes/cache.py`)
- Experiment Routes → Database Queries: stores results (evidence: `backend/routes/experiments.py`)
- Analytics Routes → Database Queries: queries metrics (evidence: `backend/routes/analytics.py`)
- Stock Routes → Database Queries: reads quotes (evidence: `backend/routes/stocks.py`)
- Stock Routes → Redis Client: checks cache (evidence: `backend/routes/stocks.py`)
- Database Queries → Relational Database: executes queries (evidence: `backend/services/db_service.py`)
- Relational Database → MySQL Service: connects to (evidence: `python/database/connection.py`)
- Quote Ingestion → Relational Database: stores quotes (evidence: `python/ingestion/stock_ingestion.py`)
- Yahoo Finance → Quote Ingestion: provides quotes
- Workload Generation → Relational Database: loads market data (evidence: `python/workload/workload_generator.py`)
- Benchmark Client → RESP TCP Server: sends RESP2
- Server Startup → RESP TCP Server: starts (evidence: `Redis-Server/src/main.cpp`)
- Server Startup → Cache Operations: configures and restores (evidence: `Redis-Server/src/main.cpp`)
- RESP TCP Server → Command Handler: dispatches commands
- Command Handler → Cache Operations: executes commands (evidence: `Redis-Server/src/RedisCommandHandler.cpp`)
- Cache Operations → Eviction Policies: updates policy (evidence: `Redis-Server/src/RedisDatabase.cpp`)
- Redis Client → RESP TCP Server: sends RESP commands (evidence: `backend/services/redis_service.py`)
- Analytics Plots → Relational Database: uses persisted data
