# jaiprasadbheemavarapu-hub/medichain-finder architecture

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

- Interactive diagram: https://gitdiagram.com/jaiprasadbheemavarapu-hub/medichain-finder
- Repository: https://github.com/jaiprasadbheemavarapu-hub/medichain-finder

## Overview

MediChain is a pharmacy and emergency-inventory finder backend. Its main user workflow is searching medicines, matching inventory to pharmacy records, and returning shop availability and location; shop opening status is computed from recorded hours. Shopkeepers can register and manage inventory, while administrators authenticate and verify shops. The server excerpt shows in-memory shop and inventory state rather than a persistent database. Some route bodies and the HTML page were not sampled, so the graph limits connections to behavior visible in the supplied source.

Main entry points: [`server.js`](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js) (Express Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express Server<br/>[server.js]"]
end

subgraph group_access["Identity And Review"]
  node_auth_routes["Auth Routes<br/>[server.js]"]
  node_token_auth["Token Middleware<br/>[server.js]"]
  node_shop_review["Shop Verification<br/>[server.js]"]
end

subgraph group_inventory["Pharmacy Inventory"]
  node_shop_state[("Shop Records<br/>[server.js]")]
  node_inventory_state[("Inventory Records<br/>[server.js]")]
  node_search["Medicine Search<br/>[server.js]"]
  node_availability["Shop Availability<br/>[server.js]"]
end

node_requester(("Medicine Seeker"))
node_shopkeeper(("Shopkeeper"))
node_admin(("Super Admin"))

node_requester -->|"sends search"| node_server
node_shopkeeper -->|"sends requests"| node_server
node_admin -->|"sends requests"| node_server
node_server -->|"dispatches auth"| node_auth_routes
node_server -->|"dispatches search"| node_search
node_server -->|"checks protected routes"| node_token_auth
node_auth_routes -->|"reads and updates"| node_shop_state
node_auth_routes -->|"registers shops"| node_shop_state
node_shop_review -->|"marks verified"| node_shop_state
node_search -->|"reads stock"| node_inventory_state
node_search -->|"matches shops"| node_shop_state
node_search -->|"computes status"| node_availability
node_availability -->|"returns results"| node_server

click node_server "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_auth_routes "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_token_auth "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_shop_review "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_shop_state "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_inventory_state "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_search "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js"
click node_availability "https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/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_server toneBlue
class node_auth_routes,node_token_auth,node_shop_review toneAmber
class node_shop_state,node_inventory_state,node_search,node_availability toneMint
class node_requester,node_shopkeeper,node_admin toneIndigo
```

## Components

### HTTP API

- [Express Server](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`

### Identity And Review

- [Auth Routes](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`
- [Token Middleware](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`
- [Shop Verification](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`

### Pharmacy Inventory

- [Shop Records](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`
- [Inventory Records](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`
- [Medicine Search](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`
- [Shop Availability](https://github.com/jaiprasadbheemavarapu-hub/medichain-finder/blob/main/server.js): `server.js`

### Other components

- **Medicine Seeker**
- **Shopkeeper**
- **Super Admin**

## Connections

- Medicine Seeker → Express Server: sends search
- Shopkeeper → Express Server: sends requests
- Super Admin → Express Server: sends requests
- Express Server → Auth Routes: dispatches auth
- Express Server → Medicine Search: dispatches search
- Express Server → Token Middleware: checks protected routes
- Auth Routes → Shop Records: reads and updates
- Auth Routes → Shop Records: registers shops
- Shop Verification → Shop Records: marks verified
- Medicine Search → Inventory Records: reads stock
- Medicine Search → Shop Records: matches shops
- Medicine Search → Shop Availability: computes status
- Shop Availability → Express Server: returns results
