# adaezeowunna21/hair-hub-backend-api-development architecture

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

- Interactive diagram: https://gitdiagram.com/adaezeowunna21/hair-hub-backend-api-development
- Repository: https://github.com/adaezeowunna21/hair-hub-backend-api-development

## Overview

Hair Hub is an Express API for hair-care users and catalog content. A client sends requests to the API entry point, which dispatches resource routes to controllers; controllers perform CRUD operations against Mongoose-backed collections. The product route is protected by JWT middleware, and user registration/login add password hashing and token issuance. Other documented API areas include categories, components, hairstyles, image metadata, and interactions. The graph reflects the shown entry-point wiring and module references; database connectivity details and some middleware behavior were not sampled.

Main entry points: [`index.js`](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/index.js) (Express app), [`controllers/user.controller.js`](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/user.controller.js) (User operations), [`middleware/errorHandler.js`](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/errorHandler.js) (Error handler), [`routes/user.route.js`](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/user.route.js) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["API platform"]
  node_entry["Express app<br/>[index.js]"]
  node_jwt["JWT guard<br/>[verifyJWT.js]"]
  node_errors["Error handler<br/>[errorHandler.js]"]
  node_logging["Error logging<br/>[logEvents.js]"]
end

subgraph group_identity["User identity"]
  node_userroute["User routes<br/>[user.route.js]"]
  node_userctrl["User operations<br/>[user.controller.js]"]
  node_users[("Users<br/>[users.model.js]")]
  node_authlibs["Hash and token libraries"]
end

subgraph group_catalog["Catalog resources"]
  node_productroute["Product routes<br/>[product.route.js]"]
  node_productctrl["Product operations"]
  node_products[("Products<br/>[products.model.js]")]
  node_categoryroute["Category routes<br/>[category.route.js]"]
  node_categoryctrl["Category operations"]
  node_categories[("Categories")]
  node_componentroute["Component routes<br/>[component.route.js]"]
  node_componentctrl["Component operations"]
  node_components[("Components")]
end

subgraph group_content["Hair content"]
  node_hairstyleroute["Hairstyle routes<br/>[hairstyle.route.js]"]
  node_hairstylectrl["Hairstyle operations"]
  node_hairstyles[("Hairstyles")]
  node_imageroute["Image routes"]
  node_imagectrl["Image metadata operations"]
  node_images[("Image metadata")]
end

subgraph group_engagement["Engagement"]
  node_interactionroute["Interaction routes"]
  node_interactionctrl["Interaction operations"]
  node_interactions[("Interactions")]
end

node_client(("API client"))

node_client -.->|"sends requests"| node_entry
node_entry -->|"mounts routes"| node_userroute
node_entry -->|"mounts routes"| node_productroute
node_entry -->|"mounts routes"| node_categoryroute
node_entry -->|"mounts routes"| node_componentroute
node_entry -->|"mounts routes"| node_hairstyleroute
node_entry -->|"mounts routes"| node_imageroute
node_entry -->|"mounts routes"| node_interactionroute
node_entry -->|"guards products"| node_jwt
node_entry -->|"handles errors"| node_errors
node_userroute -->|"dispatches to"| node_userctrl
node_userctrl -->|"reads and writes"| node_users
node_userctrl -->|"hashes and signs"| node_authlibs
node_productroute -->|"dispatches to"| node_productctrl
node_productctrl -->|"reads and writes"| node_products
node_categoryroute -->|"dispatches to"| node_categoryctrl
node_categoryctrl -->|"reads and writes"| node_categories
node_componentroute -->|"dispatches to"| node_componentctrl
node_componentctrl -->|"reads and writes"| node_components
node_hairstyleroute -->|"dispatches to"| node_hairstylectrl
node_hairstylectrl -->|"reads and writes"| node_hairstyles
node_imageroute -->|"dispatches to"| node_imagectrl
node_imagectrl -->|"reads and writes"| node_images
node_interactionroute -->|"dispatches to"| node_interactionctrl
node_interactionctrl -->|"reads and writes"| node_interactions
node_errors -->|"records errors"| node_logging

click node_entry "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/index.js"
click node_jwt "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/verifyJWT.js"
click node_errors "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/errorHandler.js"
click node_logging "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/logEvents.js"
click node_userroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/user.route.js"
click node_userctrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/user.controller.js"
click node_users "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/users.model.js"
click node_productroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/product.route.js"
click node_productctrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/product.controller.js"
click node_products "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/products.model.js"
click node_categoryroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/category.route.js"
click node_categoryctrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/category.controller.js"
click node_categories "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/categories.model.js"
click node_componentroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/component.route.js"
click node_componentctrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/component.controller.js"
click node_components "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/components.model.js"
click node_hairstyleroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/hairstyle.route.js"
click node_hairstylectrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/hairstyle.controller.js"
click node_hairstyles "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/hairstyles.model.js"
click node_imageroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/imagemetadata.route.js"
click node_imagectrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/imagemetadata.controller.js"
click node_images "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/images_metadata.model.js"
click node_interactionroute "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/interaction.route.js"
click node_interactionctrl "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/interaction.controller.js"
click node_interactions "https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/interactions.model.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_entry,node_jwt,node_errors,node_logging,node_client toneBlue
class node_userroute,node_userctrl,node_users,node_authlibs toneAmber
class node_productroute,node_productctrl,node_products,node_categoryroute,node_categoryctrl,node_categories,node_componentroute,node_componentctrl,node_components toneMint
class node_hairstyleroute,node_hairstylectrl,node_hairstyles,node_imageroute,node_imagectrl,node_images toneRose
class node_interactionroute,node_interactionctrl,node_interactions toneIndigo
```

## Components

### API platform

- [Express app](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/index.js): `index.js`
- [JWT guard](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/verifyJWT.js): `middleware/verifyJWT.js`
- [Error handler](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/errorHandler.js): `middleware/errorHandler.js`
- [Error logging](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/middleware/logEvents.js): `middleware/logEvents.js`

### User identity

- [User routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/user.route.js): `routes/user.route.js`
- [User operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/user.controller.js): `controllers/user.controller.js`
- [Users](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/users.model.js): `models/users.model.js`
- **Hash and token libraries**

### Catalog resources

- [Product routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/product.route.js): `routes/product.route.js`
- [Product operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/product.controller.js): `controllers/product.controller.js`
- [Products](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/products.model.js): `models/products.model.js`
- [Category routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/category.route.js): `routes/category.route.js`
- [Category operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/category.controller.js): `controllers/category.controller.js`
- [Categories](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/categories.model.js): `models/categories.model.js`
- [Component routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/component.route.js): `routes/component.route.js`
- [Component operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/component.controller.js): `controllers/component.controller.js`
- [Components](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/components.model.js): `models/components.model.js`

### Hair content

- [Hairstyle routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/hairstyle.route.js): `routes/hairstyle.route.js`
- [Hairstyle operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/hairstyle.controller.js): `controllers/hairstyle.controller.js`
- [Hairstyles](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/hairstyles.model.js): `models/hairstyles.model.js`
- [Image routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/imagemetadata.route.js): `routes/imagemetadata.route.js`
- [Image metadata operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/imagemetadata.controller.js): `controllers/imagemetadata.controller.js`
- [Image metadata](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/images_metadata.model.js): `models/images_metadata.model.js`

### Engagement

- [Interaction routes](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/routes/interaction.route.js): `routes/interaction.route.js`
- [Interaction operations](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/controllers/interaction.controller.js): `controllers/interaction.controller.js`
- [Interactions](https://github.com/adaezeowunna21/hair-hub-backend-api-development/blob/main/models/interactions.model.js): `models/interactions.model.js`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Express app → User routes: mounts routes (evidence: `index.js`)
- Express app → Product routes: mounts routes (evidence: `index.js`)
- Express app → Category routes: mounts routes (evidence: `index.js`)
- Express app → Component routes: mounts routes (evidence: `index.js`)
- Express app → Hairstyle routes: mounts routes (evidence: `index.js`)
- Express app → Image routes: mounts routes (evidence: `index.js`)
- Express app → Interaction routes: mounts routes (evidence: `index.js`)
- Express app → JWT guard: guards products (evidence: `index.js`)
- Express app → Error handler: handles errors (evidence: `index.js`)
- User routes → User operations: dispatches to (evidence: `routes/user.route.js`)
- User operations → Users: reads and writes (evidence: `controllers/user.controller.js`)
- User operations → Hash and token libraries: hashes and signs (evidence: `controllers/user.controller.js`)
- Product routes → Product operations: dispatches to (evidence: `routes/product.route.js`)
- Product operations → Products: reads and writes (evidence: `controllers/product.controller.js`)
- Category routes → Category operations: dispatches to (evidence: `routes/category.route.js`)
- Category operations → Categories: reads and writes (evidence: `controllers/category.controller.js`)
- Component routes → Component operations: dispatches to (evidence: `routes/component.route.js`)
- Component operations → Components: reads and writes (evidence: `controllers/component.controller.js`)
- Hairstyle routes → Hairstyle operations: dispatches to (evidence: `routes/hairstyle.route.js`)
- Hairstyle operations → Hairstyles: reads and writes (evidence: `controllers/hairstyle.controller.js`)
- Image routes → Image metadata operations: dispatches to (evidence: `routes/imagemetadata.route.js`)
- Image metadata operations → Image metadata: reads and writes (evidence: `controllers/imagemetadata.controller.js`)
- Interaction routes → Interaction operations: dispatches to (evidence: `routes/interaction.route.js`)
- Interaction operations → Interactions: reads and writes (evidence: `controllers/interaction.controller.js`)
- Error handler → Error logging: records errors (evidence: `middleware/errorHandler.js`)
