# nitesh3449/shopping-hunt architecture

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

- Interactive diagram: https://gitdiagram.com/nitesh3449/shopping-hunt
- Repository: https://github.com/nitesh3449/shopping-hunt

## Overview

ShoppingHunt is an Express REST API for user accounts and shopping-catalog management. Clients call routes for registration/login, profile operations, products and images, wishlist actions, and catalog/reference data; protected routes pass through JWT validation before reaching controllers. Controllers query Mongoose models and return JSON responses, while product and profile image operations also write files under public/. The README is empty, so capabilities are taken from the route declarations and sampled controller code; some model connections are supported only by the SOURCE INDEX.

Main entry points: [`controller/HomeController.js`](https://github.com/nitesh3449/shopping-hunt/blob/master/controller/HomeController.js) (Catalog controller), [`routes/index.js`](https://github.com/nitesh3449/shopping-hunt/blob/master/routes/index.js) (API routes), [`controller/ProductController.js`](https://github.com/nitesh3449/shopping-hunt/blob/master/controller/ProductController.js) (Product controller), [`server.js`](https://github.com/nitesh3449/shopping-hunt/blob/master/server.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_express["Express server<br/>[server.js]"]
  node_api_routes["API routes<br/>[index.js]"]
  node_mongo_config["Mongo connection<br/>[database.js]"]
end

subgraph group_identity["Accounts and auth"]
  node_jwt_check["JWT validation<br/>[auth.js]"]
  node_registration["Registration controller"]
  node_users[("User records<br/>[userModel.js]")]
end

subgraph group_shopping["Shopping catalog"]
  node_products_controller["Product controller"]
  node_products[("Product records<br/>[productModel.js]")]
  node_product_images[("Product image records")]
  node_wishlist[("Wishlist records<br/>[WishlistModel.js]")]
  node_public_files["Public image files"]
end

subgraph group_reference["Reference data"]
  node_home_controller["Catalog controller<br/>[HomeController.js]"]
  node_categories[("Categories<br/>[CategoriesModel.js]")]
  node_brands[("Brands<br/>[BrandModel.js]")]
  node_countries[("Countries<br/>[CountryModel.js]")]
  node_states[("States<br/>[StateModel.js]")]
  node_cities[("Cities<br/>[CityModel.js]")]
  node_colors[("Colors<br/>[ColorModel.js]")]
  node_sizes[("Sizes<br/>[SizeModel.js]")]
end

node_client(("API client"))
node_mongo[("MongoDB")]

node_client -.->|"sends requests"| node_express
node_express -->|"loads connection"| node_mongo_config
node_mongo_config -->|"connects"| node_mongo
node_express -->|"mounts routes"| node_api_routes
node_api_routes -->|"guards routes"| node_jwt_check
node_api_routes -->|"dispatches account"| node_registration
node_api_routes -->|"dispatches products"| node_products_controller
node_api_routes -->|"dispatches catalog"| node_home_controller
node_registration -->|"queries users"| node_users
node_products_controller -->|"queries products"| node_products
node_products_controller -->|"queries images"| node_product_images
node_products_controller -->|"reads category"| node_categories
node_products_controller -->|"writes images"| node_public_files
node_home_controller -->|"queries categories"| node_categories
node_home_controller -->|"queries brands"| node_brands
node_home_controller -->|"queries countries"| node_countries
node_home_controller -->|"queries states"| node_states
node_home_controller -->|"queries cities"| node_cities
node_home_controller -->|"queries colors"| node_colors
node_home_controller -->|"queries sizes"| node_sizes
node_home_controller -->|"reads products"| node_products
node_home_controller -->|"queries wishlist"| node_wishlist
node_home_controller -->|"reads images"| node_product_images
node_express -->|"serves static files"| node_public_files

click node_express "https://github.com/nitesh3449/shopping-hunt/blob/master/server.js"
click node_api_routes "https://github.com/nitesh3449/shopping-hunt/blob/master/routes/index.js"
click node_mongo_config "https://github.com/nitesh3449/shopping-hunt/blob/master/config/database.js"
click node_jwt_check "https://github.com/nitesh3449/shopping-hunt/blob/master/auth/auth.js"
click node_registration "https://github.com/nitesh3449/shopping-hunt/blob/master/controller/RegistrationController.js"
click node_users "https://github.com/nitesh3449/shopping-hunt/blob/master/models/userModel.js"
click node_products_controller "https://github.com/nitesh3449/shopping-hunt/blob/master/controller/ProductController.js"
click node_products "https://github.com/nitesh3449/shopping-hunt/blob/master/models/productModel.js"
click node_product_images "https://github.com/nitesh3449/shopping-hunt/blob/master/models/productImageModel.js"
click node_wishlist "https://github.com/nitesh3449/shopping-hunt/blob/master/models/WishlistModel.js"
click node_public_files "https://github.com/nitesh3449/shopping-hunt/tree/master/public/product"
click node_home_controller "https://github.com/nitesh3449/shopping-hunt/blob/master/controller/HomeController.js"
click node_categories "https://github.com/nitesh3449/shopping-hunt/blob/master/models/CategoriesModel.js"
click node_brands "https://github.com/nitesh3449/shopping-hunt/blob/master/models/BrandModel.js"
click node_countries "https://github.com/nitesh3449/shopping-hunt/blob/master/models/CountryModel.js"
click node_states "https://github.com/nitesh3449/shopping-hunt/blob/master/models/StateModel.js"
click node_cities "https://github.com/nitesh3449/shopping-hunt/blob/master/models/CityModel.js"
click node_colors "https://github.com/nitesh3449/shopping-hunt/blob/master/models/ColorModel.js"
click node_sizes "https://github.com/nitesh3449/shopping-hunt/blob/master/models/SizeModel.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_express,node_api_routes,node_mongo_config,node_client toneBlue
class node_jwt_check,node_registration,node_users,node_mongo toneAmber
class node_products_controller,node_products,node_product_images,node_wishlist,node_public_files toneMint
class node_home_controller,node_categories,node_brands,node_countries,node_states,node_cities,node_colors,node_sizes toneRose
```

## Components

### API runtime

- [Express server](https://github.com/nitesh3449/shopping-hunt/blob/master/server.js): `server.js`
- [API routes](https://github.com/nitesh3449/shopping-hunt/blob/master/routes/index.js): `routes/index.js`
- [Mongo connection](https://github.com/nitesh3449/shopping-hunt/blob/master/config/database.js): `config/database.js`

### Accounts and auth

- [JWT validation](https://github.com/nitesh3449/shopping-hunt/blob/master/auth/auth.js): `auth/auth.js`
- [Registration controller](https://github.com/nitesh3449/shopping-hunt/blob/master/controller/RegistrationController.js): `controller/RegistrationController.js`
- [User records](https://github.com/nitesh3449/shopping-hunt/blob/master/models/userModel.js): `models/userModel.js`

### Shopping catalog

- [Product controller](https://github.com/nitesh3449/shopping-hunt/blob/master/controller/ProductController.js): `controller/ProductController.js`
- [Product records](https://github.com/nitesh3449/shopping-hunt/blob/master/models/productModel.js): `models/productModel.js`
- [Product image records](https://github.com/nitesh3449/shopping-hunt/blob/master/models/productImageModel.js): `models/productImageModel.js`
- [Wishlist records](https://github.com/nitesh3449/shopping-hunt/blob/master/models/WishlistModel.js): `models/WishlistModel.js`
- [Public image files](https://github.com/nitesh3449/shopping-hunt/tree/master/public/product): `public/product`

### Reference data

- [Catalog controller](https://github.com/nitesh3449/shopping-hunt/blob/master/controller/HomeController.js): `controller/HomeController.js`
- [Categories](https://github.com/nitesh3449/shopping-hunt/blob/master/models/CategoriesModel.js): `models/CategoriesModel.js`
- [Brands](https://github.com/nitesh3449/shopping-hunt/blob/master/models/BrandModel.js): `models/BrandModel.js`
- [Countries](https://github.com/nitesh3449/shopping-hunt/blob/master/models/CountryModel.js): `models/CountryModel.js`
- [States](https://github.com/nitesh3449/shopping-hunt/blob/master/models/StateModel.js): `models/StateModel.js`
- [Cities](https://github.com/nitesh3449/shopping-hunt/blob/master/models/CityModel.js): `models/CityModel.js`
- [Colors](https://github.com/nitesh3449/shopping-hunt/blob/master/models/ColorModel.js): `models/ColorModel.js`
- [Sizes](https://github.com/nitesh3449/shopping-hunt/blob/master/models/SizeModel.js): `models/SizeModel.js`

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Express server: sends requests
- Express server → Mongo connection: loads connection (evidence: `server.js`)
- Mongo connection → MongoDB: connects (evidence: `config/database.js`)
- Express server → API routes: mounts routes (evidence: `server.js`)
- API routes → JWT validation: guards routes (evidence: `routes/index.js`)
- API routes → Registration controller: dispatches account (evidence: `routes/index.js`)
- API routes → Product controller: dispatches products (evidence: `routes/index.js`)
- API routes → Catalog controller: dispatches catalog (evidence: `routes/index.js`)
- Registration controller → User records: queries users (evidence: `controller/RegistrationController.js`)
- Product controller → Product records: queries products (evidence: `controller/ProductController.js`)
- Product controller → Product image records: queries images (evidence: `controller/ProductController.js`)
- Product controller → Categories: reads category (evidence: `controller/ProductController.js`)
- Product controller → Public image files: writes images (evidence: `controller/ProductController.js`)
- Catalog controller → Categories: queries categories (evidence: `controller/HomeController.js`)
- Catalog controller → Brands: queries brands (evidence: `controller/HomeController.js`)
- Catalog controller → Countries: queries countries (evidence: `controller/HomeController.js`)
- Catalog controller → States: queries states (evidence: `controller/HomeController.js`)
- Catalog controller → Cities: queries cities (evidence: `controller/HomeController.js`)
- Catalog controller → Colors: queries colors (evidence: `controller/HomeController.js`)
- Catalog controller → Sizes: queries sizes (evidence: `controller/HomeController.js`)
- Catalog controller → Product records: reads products (evidence: `controller/HomeController.js`)
- Catalog controller → Wishlist records: queries wishlist (evidence: `controller/HomeController.js`)
- Catalog controller → Product image records: reads images (evidence: `controller/HomeController.js`)
- Express server → Public image files: serves static files (evidence: `server.js`)
