# hrishikeshsehan64/cache architecture

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

- Interactive diagram: https://gitdiagram.com/hrishikeshsehan64/cache
- Repository: https://github.com/hrishikeshsehan64/cache

## Overview

This is a small Express product CRUD API. Requests enter through the server and product routes; read routes check an in-memory, 60-second cache before controller handlers fetch data, while mutations clear the cache. The service layer delegates product operations to JSON-file persistence. The sampled source shows the main request and storage flows; no README documents additional capabilities.

Main entry points: [`routes/productRoutes.js`](https://github.com/hrishikeshsehan64/cache/blob/main/routes/productRoutes.js) (Product routes), [`controllers/productController.js`](https://github.com/hrishikeshsehan64/cache/blob/main/controllers/productController.js) (Product controller), [`server.js`](https://github.com/hrishikeshsehan64/cache/blob/main/server.js) (Express server), [`services/productService.js`](https://github.com/hrishikeshsehan64/cache/blob/main/services/productService.js) (Product service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Product routes<br/>[productRoutes.js]"]
end

subgraph group_logic["Product logic"]
  node_controller["Product controller"]
  node_service["Product service<br/>[productService.js]"]
end

subgraph group_state["Product state"]
  node_cache[("Response cache<br/>[cache.js]")]
  node_db["Product persistence<br/>[productsDB.js]"]
  node_json["Product JSON file<br/>[db.json]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"dispatches handlers"| node_controller
node_routes -->|"checks reads"| node_cache
node_controller -->|"calls operations"| node_service
node_controller -->|"stores and clears"| node_cache
node_service -->|"delegates operations"| node_db
node_db -->|"reads and writes"| node_json

click node_server "https://github.com/hrishikeshsehan64/cache/blob/main/server.js"
click node_routes "https://github.com/hrishikeshsehan64/cache/blob/main/routes/productRoutes.js"
click node_controller "https://github.com/hrishikeshsehan64/cache/blob/main/controllers/productController.js"
click node_service "https://github.com/hrishikeshsehan64/cache/blob/main/services/productService.js"
click node_cache "https://github.com/hrishikeshsehan64/cache/blob/main/middleware/cache.js"
click node_db "https://github.com/hrishikeshsehan64/cache/blob/main/database/productsDB.js"
click node_json "https://github.com/hrishikeshsehan64/cache/blob/main/db.json"

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_routes,node_client toneBlue
class node_controller,node_service toneAmber
class node_cache,node_db,node_json toneMint
```

## Components

### API routing

- [Express server](https://github.com/hrishikeshsehan64/cache/blob/main/server.js): `server.js`
- [Product routes](https://github.com/hrishikeshsehan64/cache/blob/main/routes/productRoutes.js): `routes/productRoutes.js`

### Product logic

- [Product controller](https://github.com/hrishikeshsehan64/cache/blob/main/controllers/productController.js): `controllers/productController.js`
- [Product service](https://github.com/hrishikeshsehan64/cache/blob/main/services/productService.js): `services/productService.js`

### Product state

- [Response cache](https://github.com/hrishikeshsehan64/cache/blob/main/middleware/cache.js): `middleware/cache.js`
- [Product persistence](https://github.com/hrishikeshsehan64/cache/blob/main/database/productsDB.js): `database/productsDB.js`
- [Product JSON file](https://github.com/hrishikeshsehan64/cache/blob/main/db.json): `db.json`

### Other components

- **API client**

## Connections

- API client → Express server: sends requests
- Express server → Product routes: mounts routes (evidence: `server.js`)
- Product routes → Product controller: dispatches handlers (evidence: `routes/productRoutes.js`)
- Product routes → Response cache: checks reads (evidence: `routes/productRoutes.js`)
- Product controller → Product service: calls operations (evidence: `controllers/productController.js`)
- Product controller → Response cache: stores and clears (evidence: `controllers/productController.js`)
- Product service → Product persistence: delegates operations (evidence: `services/productService.js`)
- Product persistence → Product JSON file: reads and writes (evidence: `database/productsDB.js`)
