# adityajha002/niji architecture

> Architecture diagram of the GitHub repository adityajha002/niji, 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/adityajha002/niji
- Repository: https://github.com/adityajha002/niji

## Overview

NIJI is a hyperlocal marketplace discovery product: shoppers search for nearby in-stock products, while shop owners create shops and manage listings. The frontend routes users into search, product/shop views, authentication, and owner dashboards; backend APIs persist marketplace data and enqueue product enrichment; a separate search service indexes and searches products with geographic and price filters. The README documents the sync pipeline and integrations; some route and UI internals were not sampled, so those links are cited only where documented.

Main entry points: [`backend/server.js`](https://github.com/adityajha002/niji/blob/main/backend/server.js) (Express API), [`frontend/src/routes/AppRoutes.tsx`](https://github.com/adityajha002/niji/blob/main/frontend/src/routes/AppRoutes.tsx) (Client routing), [`meilisearch/src/server.js`](https://github.com/adityajha002/niji/blob/main/meilisearch/src/server.js) (Search service), [`backend/routes/productRoutes.js`](https://github.com/adityajha002/niji/blob/main/backend/routes/productRoutes.js) (Product API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Shopper and owner client"]
  node_routes["Client routing<br/>[AppRoutes.tsx]"]
  node_authui["Authentication UI<br/>[auth.tsx]"]
  node_authstate["Auth state<br/>[authContext.tsx]"]
  node_searchui["Product search UI<br/>[search.tsx]"]
  node_browseui["Product and shop views<br/>[productView.tsx]"]
  node_ownerui["Shop management<br/>[dashboard.tsx]"]
  node_clientapi["API services<br/>[productService.ts]"]
end

subgraph group_api["Marketplace API"]
  node_backend["Express API<br/>[server.js]"]
  node_authapi["Authentication API<br/>[authRoutes.js]"]
  node_shopapi["Shop API<br/>[shopRoutes.js]"]
  node_productapi["Product API<br/>[productRoutes.js]"]
  node_searchapi["Search gateway<br/>[searchRoutes.js]"]
  node_postgres[("Postgres data<br/>[db.js]")]
  node_images["Image storage<br/>[cloudinary.js]"]
  node_queue["Product sync queue<br/>[Queue.js]"]
  node_gemini["Keyword generation<br/>[geminiKeywords.js]"]
end

subgraph group_search["Search and indexing"]
  node_searchserver["Search service<br/>[server.js]"]
  node_searchops["Search and indexing<br/>[searchProducts.js]"]
  node_bulkindex["Database reindexing<br/>[indexAll.js]"]
  node_retryindex["Queue reprocessing<br/>[reQueue.js]"]
  node_meili[("Meilisearch index<br/>[meiliClient.js]")]
end

node_shopper(("Shopper"))
node_owner(("Shop owner"))
node_supabase[("Supabase Postgres")]
node_cloudinary["Cloudinary"]
node_geminisvc["Gemini API"]

node_shopper -->|"uses"| node_routes
node_owner -->|"uses"| node_routes
node_routes -->|"routes to"| node_searchui
node_routes -->|"routes to"| node_browseui
node_routes -->|"routes to"| node_ownerui
node_routes -->|"routes to"| node_authui
node_authui -->|"uses"| node_authstate
node_searchui -->|"requests search"| node_clientapi
node_browseui -.->|"loads listings"| node_clientapi
node_ownerui -.->|"manages listings"| node_clientapi
node_clientapi -->|"calls API"| node_backend
node_backend -->|"mounts routes"| node_authapi
node_backend -->|"mounts routes"| node_shopapi
node_backend -->|"mounts routes"| node_productapi
node_backend -->|"mounts routes"| node_searchapi
node_authapi -->|"reads and writes"| node_postgres
node_shopapi -->|"reads and writes"| node_postgres
node_productapi -->|"reads and writes"| node_postgres
node_shopapi -->|"uploads images"| node_images
node_productapi -->|"uploads images"| node_images
node_productapi -->|"queues product"| node_queue
node_backend -->|"retries queue"| node_queue
node_queue -->|"generates keywords"| node_gemini
node_queue -->|"persists sync state"| node_postgres
node_gemini -.->|"requests keywords"| node_geminisvc
node_backend -.->|"sends indexed products"| node_searchserver
node_searchapi -.->|"forwards searches"| node_searchserver
node_searchserver -->|"dispatches search"| node_searchops
node_searchserver -->|"rebuilds index"| node_bulkindex
node_searchserver -->|"retries indexing"| node_retryindex
node_searchops -->|"searches index"| node_meili
node_bulkindex -->|"writes documents"| node_meili
node_bulkindex -->|"reads products"| node_supabase
node_retryindex -->|"updates documents"| node_meili
node_retryindex -->|"reads queued data"| node_supabase

click node_routes "https://github.com/adityajha002/niji/blob/main/frontend/src/routes/AppRoutes.tsx"
click node_authui "https://github.com/adityajha002/niji/blob/main/frontend/src/pages/auth/auth.tsx"
click node_authstate "https://github.com/adityajha002/niji/blob/main/frontend/src/context/authContext.tsx"
click node_searchui "https://github.com/adityajha002/niji/blob/main/frontend/src/pages/search/search.tsx"
click node_browseui "https://github.com/adityajha002/niji/blob/main/frontend/src/pages/product/productView.tsx"
click node_ownerui "https://github.com/adityajha002/niji/blob/main/frontend/src/pages/dashboard/dashboard.tsx"
click node_clientapi "https://github.com/adityajha002/niji/blob/main/frontend/src/services/productService.ts"
click node_backend "https://github.com/adityajha002/niji/blob/main/backend/server.js"
click node_authapi "https://github.com/adityajha002/niji/blob/main/backend/routes/authRoutes.js"
click node_shopapi "https://github.com/adityajha002/niji/blob/main/backend/routes/shopRoutes.js"
click node_productapi "https://github.com/adityajha002/niji/blob/main/backend/routes/productRoutes.js"
click node_searchapi "https://github.com/adityajha002/niji/blob/main/backend/routes/searchRoutes.js"
click node_postgres "https://github.com/adityajha002/niji/blob/main/backend/config/db.js"
click node_images "https://github.com/adityajha002/niji/blob/main/backend/config/cloudinary.js"
click node_queue "https://github.com/adityajha002/niji/blob/main/backend/config/services/Queue.js"
click node_gemini "https://github.com/adityajha002/niji/blob/main/backend/config/services/geminiKeywords.js"
click node_searchserver "https://github.com/adityajha002/niji/blob/main/meilisearch/src/server.js"
click node_searchops "https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/searchProducts.js"
click node_bulkindex "https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/indexAll.js"
click node_retryindex "https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/reQueue.js"
click node_meili "https://github.com/adityajha002/niji/blob/main/meilisearch/src/config/meiliClient.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_routes,node_authui,node_authstate,node_searchui,node_browseui,node_ownerui,node_clientapi toneBlue
class node_backend,node_authapi,node_shopapi,node_productapi,node_searchapi,node_postgres,node_images,node_queue,node_gemini,node_supabase toneAmber
class node_searchserver,node_searchops,node_bulkindex,node_retryindex,node_meili,node_geminisvc toneMint
class node_shopper,node_owner,node_cloudinary toneIndigo
```

## Components

### Shopper and owner client

- [Client routing](https://github.com/adityajha002/niji/blob/main/frontend/src/routes/AppRoutes.tsx): `frontend/src/routes/AppRoutes.tsx`
- [Authentication UI](https://github.com/adityajha002/niji/blob/main/frontend/src/pages/auth/auth.tsx): `frontend/src/pages/auth/auth.tsx`
- [Auth state](https://github.com/adityajha002/niji/blob/main/frontend/src/context/authContext.tsx): `frontend/src/context/authContext.tsx`
- [Product search UI](https://github.com/adityajha002/niji/blob/main/frontend/src/pages/search/search.tsx): `frontend/src/pages/search/search.tsx`
- [Product and shop views](https://github.com/adityajha002/niji/blob/main/frontend/src/pages/product/productView.tsx): `frontend/src/pages/product/productView.tsx`
- [Shop management](https://github.com/adityajha002/niji/blob/main/frontend/src/pages/dashboard/dashboard.tsx): `frontend/src/pages/dashboard/dashboard.tsx`
- [API services](https://github.com/adityajha002/niji/blob/main/frontend/src/services/productService.ts): `frontend/src/services/productService.ts`

### Marketplace API

- [Express API](https://github.com/adityajha002/niji/blob/main/backend/server.js): `backend/server.js`
- [Authentication API](https://github.com/adityajha002/niji/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Shop API](https://github.com/adityajha002/niji/blob/main/backend/routes/shopRoutes.js): `backend/routes/shopRoutes.js`
- [Product API](https://github.com/adityajha002/niji/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [Search gateway](https://github.com/adityajha002/niji/blob/main/backend/routes/searchRoutes.js): `backend/routes/searchRoutes.js`
- [Postgres data](https://github.com/adityajha002/niji/blob/main/backend/config/db.js): `backend/config/db.js`
- [Image storage](https://github.com/adityajha002/niji/blob/main/backend/config/cloudinary.js): `backend/config/cloudinary.js`
- [Product sync queue](https://github.com/adityajha002/niji/blob/main/backend/config/services/Queue.js): `backend/config/services/Queue.js`
- [Keyword generation](https://github.com/adityajha002/niji/blob/main/backend/config/services/geminiKeywords.js): `backend/config/services/geminiKeywords.js`

### Search and indexing

- [Search service](https://github.com/adityajha002/niji/blob/main/meilisearch/src/server.js): `meilisearch/src/server.js`
- [Search and indexing](https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/searchProducts.js): `meilisearch/src/services/searchProducts.js`
- [Database reindexing](https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/indexAll.js): `meilisearch/src/services/indexAll.js`
- [Queue reprocessing](https://github.com/adityajha002/niji/blob/main/meilisearch/src/services/reQueue.js): `meilisearch/src/services/reQueue.js`
- [Meilisearch index](https://github.com/adityajha002/niji/blob/main/meilisearch/src/config/meiliClient.js): `meilisearch/src/config/meiliClient.js`

### Other components

- **Shopper**
- **Shop owner**
- **Supabase Postgres**
- **Cloudinary**
- **Gemini API**

## Connections

- Shopper → Client routing: uses (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Shop owner → Client routing: uses (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Client routing → Product search UI: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Client routing → Product and shop views: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Client routing → Shop management: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Client routing → Authentication UI: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Authentication UI → Auth state: uses (evidence: `frontend/src/pages/auth/auth.tsx`)
- Product search UI → API services: requests search (evidence: `frontend/src/services/productService.ts`)
- Product and shop views → API services: loads listings
- Shop management → API services: manages listings (evidence: `frontend/src/pages/dashboard/dashboard.tsx`)
- API services → Express API: calls API (evidence: `frontend/src/services/productService.ts`)
- Express API → Authentication API: mounts routes (evidence: `backend/server.js`)
- Express API → Shop API: mounts routes (evidence: `backend/server.js`)
- Express API → Product API: mounts routes (evidence: `backend/server.js`)
- Express API → Search gateway: mounts routes (evidence: `backend/server.js`)
- Authentication API → Postgres data: reads and writes (evidence: `backend/routes/authRoutes.js`)
- Shop API → Postgres data: reads and writes (evidence: `backend/routes/shopRoutes.js`)
- Product API → Postgres data: reads and writes (evidence: `backend/routes/productRoutes.js`)
- Shop API → Image storage: uploads images (evidence: `backend/routes/shopRoutes.js`)
- Product API → Image storage: uploads images (evidence: `backend/routes/productRoutes.js`)
- Product API → Product sync queue: queues product (evidence: `backend/routes/productRoutes.js`)
- Express API → Product sync queue: retries queue (evidence: `backend/server.js`)
- Product sync queue → Keyword generation: generates keywords (evidence: `backend/config/services/Queue.js`)
- Product sync queue → Postgres data: persists sync state (evidence: `backend/config/services/Queue.js`)
- Keyword generation → Gemini API: requests keywords (evidence: `README.md`)
- Express API → Search service: sends indexed products (evidence: `README.md`)
- Search gateway → Search service: forwards searches (evidence: `README.md`)
- Search service → Search and indexing: dispatches search (evidence: `meilisearch/src/server.js`)
- Search service → Database reindexing: rebuilds index (evidence: `meilisearch/src/server.js`)
- Search service → Queue reprocessing: retries indexing (evidence: `meilisearch/src/server.js`)
- Search and indexing → Meilisearch index: searches index (evidence: `meilisearch/src/services/searchProducts.js`)
- Database reindexing → Meilisearch index: writes documents (evidence: `meilisearch/src/services/indexAll.js`)
- Database reindexing → Supabase Postgres: reads products (evidence: `meilisearch/src/services/indexAll.js`)
- Queue reprocessing → Meilisearch index: updates documents (evidence: `meilisearch/src/services/reQueue.js`)
- Queue reprocessing → Supabase Postgres: reads queued data (evidence: `meilisearch/src/services/reQueue.js`)
