# mahisiddhant0-oss/redistack architecture

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

- Interactive diagram: https://gitdiagram.com/mahisiddhant0-oss/redistack
- Repository: https://github.com/mahisiddhant0-oss/redistack

## Overview

Redistack is a TypeScript/Fastify learning application demonstrating Redis-backed patterns through both API routes and standalone demos. The main request workflow enters through the server and API, which dispatches to feature stores and returns results; leaderboard updates also trigger live notifications delivered over WebSockets. The README documents additional job-queue capabilities beyond the sampled routes. Relationships for those features are shown only where documentation or excerpts support them; unsampled route details are not inferred.

Main entry points: [`src/app.ts`](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/app.ts) (Fastify API), [`src/notification-service.ts`](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/notification-service.ts) (Notification service), [`src/server.ts`](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/server.ts) (Server entry), [`src/leaderboard-store.ts`](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/leaderboard-store.ts) (Leaderboard store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_server["Server entry<br/>[server.ts]"]
  node_app["Fastify API<br/>[app.ts]"]
  node_metrics["Runtime metrics<br/>[runtime-metrics.ts]"]
  node_redis_client["Redis client<br/>[redis-client.ts]"]
  node_redis_config["Redis configuration<br/>[redis-config.ts]"]
end

subgraph group_patterns["Redis patterns"]
  node_cache["Cache store<br/>[cache-store.ts]"]
  node_sessions["Session store<br/>[session-store.ts]"]
  node_limiter["Rate limiter<br/>[rate-limiter.ts]"]
  node_leaderboard["Leaderboard store"]
end

subgraph group_realtime["Live notifications"]
  node_notification["Notification service"]
end

subgraph group_jobs["Background jobs"]
  node_queue["Job queue<br/>[job-queue.ts]"]
end

subgraph group_visualizer["Redis visualizer"]
  node_visualizer["Visualizer UI<br/>[visualizer.js]"]
end

node_user(("API user"))
node_ws_clients(("WebSocket clients"))
node_browser(("Browser user"))
node_redis[("Redis")]

node_user -->|"sends requests"| node_server
node_server -->|"builds and serves"| node_app
node_app -->|"records and reads"| node_metrics
node_app -->|"dispatches cache routes"| node_cache
node_app -->|"dispatches session routes"| node_sessions
node_app -->|"checks request limits"| node_limiter
node_app -->|"dispatches score queries"| node_leaderboard
node_app -->|"registers listeners"| node_notification
node_leaderboard -->|"publishes score event"| node_notification
node_notification -->|"forwards events"| node_ws_clients
node_ws_clients -->|"opens WebSocket"| node_app
node_app -->|"dispatches job routes"| node_queue
node_browser -->|"uses dashboard"| node_visualizer
node_visualizer -->|"calls API"| node_app
node_app -->|"serves assets"| node_visualizer
node_redis_client -->|"creates client"| node_redis_config
node_server -->|"uses connection"| node_redis_client
node_cache -->|"reads and writes"| node_redis
node_sessions -->|"reads and writes"| node_redis
node_limiter -->|"runs atomic counters"| node_redis
node_leaderboard -->|"reads and writes scores"| node_redis
node_notification -->|"publishes and subscribes"| node_redis
node_queue -->|"stores and claims jobs"| node_redis

click node_server "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/server.ts"
click node_app "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/app.ts"
click node_metrics "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/runtime-metrics.ts"
click node_redis_client "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/redis-client.ts"
click node_redis_config "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/redis-config.ts"
click node_cache "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/cache-store.ts"
click node_sessions "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/session-store.ts"
click node_limiter "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/rate-limiter.ts"
click node_leaderboard "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/leaderboard-store.ts"
click node_notification "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/notification-service.ts"
click node_queue "https://github.com/mahisiddhant0-oss/redistack/blob/main/src/job-queue.ts"
click node_visualizer "https://github.com/mahisiddhant0-oss/redistack/blob/main/public/visualizer.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_server,node_app,node_metrics,node_redis_client,node_redis_config,node_user,node_ws_clients,node_browser toneBlue
class node_cache,node_sessions,node_limiter,node_leaderboard,node_redis toneAmber
class node_notification toneMint
class node_queue toneRose
class node_visualizer toneIndigo
```

## Components

### API runtime

- [Server entry](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/server.ts): `src/server.ts`
- [Fastify API](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/app.ts): `src/app.ts`
- [Runtime metrics](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/runtime-metrics.ts): `src/runtime-metrics.ts`
- [Redis client](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/redis-client.ts): `src/redis-client.ts`
- [Redis configuration](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/redis-config.ts): `src/redis-config.ts`

### Redis patterns

- [Cache store](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/cache-store.ts): `src/cache-store.ts`
- [Session store](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/session-store.ts): `src/session-store.ts`
- [Rate limiter](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/rate-limiter.ts): `src/rate-limiter.ts`
- [Leaderboard store](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/leaderboard-store.ts): `src/leaderboard-store.ts`

### Live notifications

- [Notification service](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/notification-service.ts): `src/notification-service.ts`

### Background jobs

- [Job queue](https://github.com/mahisiddhant0-oss/redistack/blob/main/src/job-queue.ts): `src/job-queue.ts`

### Redis visualizer

- [Visualizer UI](https://github.com/mahisiddhant0-oss/redistack/blob/main/public/visualizer.js): `public/visualizer.js`

### Other components

- **API user**
- **WebSocket clients**
- **Browser user**
- **Redis**

## Connections

- API user → Server entry: sends requests (evidence: `README.md`)
- Server entry → Fastify API: builds and serves (evidence: `src/server.ts`)
- Fastify API → Runtime metrics: records and reads (evidence: `src/app.ts`)
- Fastify API → Cache store: dispatches cache routes (evidence: `src/app.ts`)
- Fastify API → Session store: dispatches session routes (evidence: `src/app.ts`)
- Fastify API → Rate limiter: checks request limits (evidence: `src/app.ts`)
- Fastify API → Leaderboard store: dispatches score queries (evidence: `src/app.ts`)
- Fastify API → Notification service: registers listeners (evidence: `src/app.ts`)
- Leaderboard store → Notification service: publishes score event (evidence: `README.md`)
- Notification service → WebSocket clients: forwards events (evidence: `README.md`)
- WebSocket clients → Fastify API: opens WebSocket (evidence: `README.md`)
- Fastify API → Job queue: dispatches job routes (evidence: `src/app.ts`)
- Browser user → Visualizer UI: uses dashboard (evidence: `README.md`)
- Visualizer UI → Fastify API: calls API (evidence: `README.md`)
- Fastify API → Visualizer UI: serves assets (evidence: `src/app.ts`)
- Redis client → Redis configuration: creates client (evidence: `src/redis-client.ts`)
- Server entry → Redis client: uses connection (evidence: `src/server.ts`)
- Cache store → Redis: reads and writes (evidence: `src/cache-store.ts`)
- Session store → Redis: reads and writes (evidence: `src/session-store.ts`)
- Rate limiter → Redis: runs atomic counters (evidence: `src/rate-limiter.ts`)
- Leaderboard store → Redis: reads and writes scores (evidence: `src/leaderboard-store.ts`)
- Notification service → Redis: publishes and subscribes (evidence: `src/notification-service.ts`)
- Job queue → Redis: stores and claims jobs (evidence: `src/job-queue.ts`)
