# anirudhmadaan/typing-diary-backend architecture

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

- Interactive diagram: https://gitdiagram.com/anirudhmadaan/typing-diary-backend
- Repository: https://github.com/anirudhmadaan/typing-diary-backend

## Overview

Typing Diary Backend is an Express API for accounts, diary entries, and settings synced across devices. A client sends requests to the API; account routes handle registration and session checks, while diary and settings routes validate and update user data. The server persists shared state in Upstash Redis when configured, or in a local file outside Vercel. The excerpts show these features and persistence logic in server.js; other route details are not independently inspected.

Main entry points: [`server.js`](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js) (Express API), [`api/index.js`](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/api/index.js) (Vercel Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_vercel_adapter["Vercel Adapter<br/>[index.js]"]
  node_express_api["Express API<br/>[server.js]"]
  node_health["Health Routes<br/>[server.js]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Account Routes<br/>[server.js]"]
  node_session["Session Security<br/>[server.js]"]
end

subgraph group_product["Diary And Settings"]
  node_diary_routes["Diary Entries<br/>[server.js]"]
  node_settings_routes["Synced Settings<br/>[server.js]"]
end

subgraph group_state["Persistence"]
  node_state_manager["State Manager<br/>[server.js]"]
  node_local_store[("Local State File<br/>[server.js]")]
  node_redis[("Upstash Redis")]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_express_api
node_vercel_adapter -->|"exports app"| node_express_api
node_express_api -->|"serves routes"| node_health
node_express_api -->|"serves routes"| node_auth_routes
node_express_api -->|"serves routes"| node_diary_routes
node_express_api -->|"serves routes"| node_settings_routes
node_auth_routes -->|"sets sessions"| node_session
node_auth_routes -->|"reads and updates"| node_state_manager
node_diary_routes -->|"reads and updates"| node_state_manager
node_settings_routes -->|"reads and updates"| node_state_manager
node_state_manager -->|"reads and writes"| node_redis
node_state_manager -->|"reads and writes"| node_local_store

click node_vercel_adapter "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/api/index.js"
click node_express_api "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_health "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_auth_routes "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_session "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_diary_routes "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_settings_routes "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_state_manager "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js"
click node_local_store "https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.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_vercel_adapter,node_express_api,node_health,node_client toneBlue
class node_auth_routes,node_session toneAmber
class node_diary_routes,node_settings_routes toneMint
class node_state_manager,node_local_store,node_redis toneRose
```

## Components

### API

- [Vercel Adapter](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/api/index.js): `api/index.js`
- [Express API](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`
- [Health Routes](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`

### Identity

- [Account Routes](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`
- [Session Security](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`

### Diary And Settings

- [Diary Entries](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`
- [Synced Settings](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`

### Persistence

- [State Manager](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`
- [Local State File](https://github.com/anirudhmadaan/typing-diary-backend/blob/main/server.js): `server.js`
- **Upstash Redis**

### Other components

- **API Client**

## Connections

- API Client → Express API: sends requests (evidence: `README.md`)
- Vercel Adapter → Express API: exports app (evidence: `api/index.js`)
- Express API → Health Routes: serves routes (evidence: `server.js`)
- Express API → Account Routes: serves routes (evidence: `server.js`)
- Express API → Diary Entries: serves routes (evidence: `server.js`)
- Express API → Synced Settings: serves routes (evidence: `server.js`)
- Account Routes → Session Security: sets sessions (evidence: `server.js`)
- Account Routes → State Manager: reads and updates (evidence: `server.js`)
- Diary Entries → State Manager: reads and updates (evidence: `server.js`)
- Synced Settings → State Manager: reads and updates (evidence: `server.js`)
- State Manager → Upstash Redis: reads and writes (evidence: `server.js`)
- State Manager → Local State File: reads and writes (evidence: `server.js`)
