# markandeshwaragoudapatil/api architecture

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

- Interactive diagram: https://gitdiagram.com/markandeshwaragoudapatil/api
- Repository: https://github.com/markandeshwaragoudapatil/api

## Overview

This is an Express/Mongoose user and product API. Clients register or log in to receive a JWT cookie; authenticated requests pass through route middleware to profile or product handlers, which call services and, for products and profiles, persist through models. Admin authorization protects product mutations. The README is empty, so the map reflects the source index and excerpts; the session-related modules are included, but their runtime wiring is not established by the shown code.

Main entry points: [`app.js`](https://github.com/markandeshwaragoudapatil/api/blob/main/app.js) (Express app), [`routes/productRoutes.js`](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/productRoutes.js) (Product routes), [`middleware/jwtAuthMiddleware.js`](https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/jwtAuthMiddleware.js) (JWT authentication), [`services/profileService.js`](https://github.com/markandeshwaragoudapatil/api/blob/main/services/profileService.js) (Profile service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_app["Express app<br/>[app.js]"]
  node_login_routes["Login routes<br/>[loginRoutes.js]"]
  node_register_routes["Registration routes<br/>[registerRoutes.js]"]
  node_logout_routes["Logout routes<br/>[logoutRoutes.js]"]
  node_profile_routes["Profile routes<br/>[profileRoutes.js]"]
  node_product_routes["Product routes<br/>[productRoutes.js]"]
  node_async_handler["Async wrapper<br/>[asyncHandler.js]"]
  node_app_error["Application error<br/>[AppError.js]"]
end

subgraph group_identity["Identity and access"]
  node_login_controller["Login handler<br/>[loginController.js]"]
  node_register_controller["Registration handler"]
  node_logout_controller["Logout handler"]
  node_profile_controller["Profile handler"]
  node_jwt_middleware["JWT authentication"]
  node_user_middleware["Admin authorization"]
  node_auth_middleware["Auth middleware<br/>[authMiddleware.js]"]
  node_jwt_util["JWT utility<br/>[jwt.js]"]
  node_login_service["Session service<br/>[loginService.js]"]
  node_logout_service["Logout service<br/>[logoutService.js]"]
  node_profile_service["Profile service<br/>[profileService.js]"]
end

subgraph group_catalog["Product catalog"]
  node_product_controller["Product handler"]
  node_product_service["Product service<br/>[productService.js]"]
end

subgraph group_persistence["Data models"]
  node_session_model[("Session records<br/>[Session.js]")]
  node_user_model[("User records<br/>[User.js]")]
  node_product_model[("Product records<br/>[productModel.js]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_login_routes
node_app -->|"mounts routes"| node_register_routes
node_app -->|"mounts routes"| node_logout_routes
node_app -->|"mounts routes"| node_profile_routes
node_app -->|"mounts routes"| node_product_routes
node_login_routes -->|"routes to"| node_login_controller
node_register_routes -->|"routes to"| node_register_controller
node_logout_routes -->|"routes to"| node_logout_controller
node_profile_routes -->|"routes to"| node_profile_controller
node_product_routes -->|"routes to"| node_product_controller
node_product_routes -->|"wraps handlers"| node_async_handler
node_product_routes -->|"authenticates with"| node_jwt_middleware
node_product_routes -->|"authorizes with"| node_user_middleware
node_profile_routes -->|"authenticates with"| node_jwt_middleware
node_logout_routes -->|"authenticates with"| node_jwt_middleware
node_login_controller -->|"checks credentials"| node_profile_service
node_login_controller -->|"creates token"| node_jwt_util
node_register_controller -->|"creates user"| node_profile_service
node_register_controller -->|"creates token"| node_jwt_util
node_profile_controller -->|"gets profile"| node_profile_service
node_product_controller -->|"calls operations"| node_product_service
node_product_service -->|"reads and writes"| node_product_model
node_product_service -->|"raises errors"| node_app_error
node_profile_service -->|"reads and writes"| node_user_model
node_jwt_middleware -->|"raises errors"| node_app_error
node_login_service -->|"reads and creates"| node_session_model
node_logout_service -->|"uses sessions"| node_session_model

click node_app "https://github.com/markandeshwaragoudapatil/api/blob/main/app.js"
click node_login_routes "https://github.com/markandeshwaragoudapatil/api/blob/main/routes/loginRoutes.js"
click node_register_routes "https://github.com/markandeshwaragoudapatil/api/blob/main/routes/registerRoutes.js"
click node_logout_routes "https://github.com/markandeshwaragoudapatil/api/blob/main/routes/logoutRoutes.js"
click node_profile_routes "https://github.com/markandeshwaragoudapatil/api/blob/main/routes/profileRoutes.js"
click node_product_routes "https://github.com/markandeshwaragoudapatil/api/blob/main/routes/productRoutes.js"
click node_login_controller "https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/loginController.js"
click node_register_controller "https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/registerController.js"
click node_logout_controller "https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/logoutController.js"
click node_profile_controller "https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/profileController.js"
click node_jwt_middleware "https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/jwtAuthMiddleware.js"
click node_user_middleware "https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/userAuthMiddleware.js"
click node_auth_middleware "https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/authMiddleware.js"
click node_jwt_util "https://github.com/markandeshwaragoudapatil/api/blob/main/utils/jwt.js"
click node_login_service "https://github.com/markandeshwaragoudapatil/api/blob/main/services/loginService.js"
click node_logout_service "https://github.com/markandeshwaragoudapatil/api/blob/main/services/logoutService.js"
click node_profile_service "https://github.com/markandeshwaragoudapatil/api/blob/main/services/profileService.js"
click node_product_controller "https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/productController.js"
click node_product_service "https://github.com/markandeshwaragoudapatil/api/blob/main/services/productService.js"
click node_async_handler "https://github.com/markandeshwaragoudapatil/api/blob/main/utils/asyncHandler.js"
click node_app_error "https://github.com/markandeshwaragoudapatil/api/blob/main/utils/AppError.js"
click node_session_model "https://github.com/markandeshwaragoudapatil/api/blob/main/models/Session.js"
click node_user_model "https://github.com/markandeshwaragoudapatil/api/blob/main/models/User.js"
click node_product_model "https://github.com/markandeshwaragoudapatil/api/blob/main/models/productModel.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_app,node_login_routes,node_register_routes,node_logout_routes,node_profile_routes,node_product_routes,node_async_handler,node_app_error,node_client toneBlue
class node_login_controller,node_register_controller,node_logout_controller,node_profile_controller,node_jwt_middleware,node_user_middleware,node_auth_middleware,node_jwt_util,node_login_service,node_logout_service,node_profile_service toneAmber
class node_product_controller,node_product_service toneMint
class node_session_model,node_user_model,node_product_model toneRose
```

## Components

### API routing

- [Express app](https://github.com/markandeshwaragoudapatil/api/blob/main/app.js): `app.js`
- [Login routes](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/loginRoutes.js): `routes/loginRoutes.js`
- [Registration routes](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/registerRoutes.js): `routes/registerRoutes.js`
- [Logout routes](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/logoutRoutes.js): `routes/logoutRoutes.js`
- [Profile routes](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/profileRoutes.js): `routes/profileRoutes.js`
- [Product routes](https://github.com/markandeshwaragoudapatil/api/blob/main/routes/productRoutes.js): `routes/productRoutes.js`
- [Async wrapper](https://github.com/markandeshwaragoudapatil/api/blob/main/utils/asyncHandler.js): `utils/asyncHandler.js`
- [Application error](https://github.com/markandeshwaragoudapatil/api/blob/main/utils/AppError.js): `utils/AppError.js`

### Identity and access

- [Login handler](https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/loginController.js): `controllers/loginController.js`
- [Registration handler](https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/registerController.js): `controllers/registerController.js`
- [Logout handler](https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/logoutController.js): `controllers/logoutController.js`
- [Profile handler](https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/profileController.js): `controllers/profileController.js`
- [JWT authentication](https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/jwtAuthMiddleware.js): `middleware/jwtAuthMiddleware.js`
- [Admin authorization](https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/userAuthMiddleware.js): `middleware/userAuthMiddleware.js`
- [Auth middleware](https://github.com/markandeshwaragoudapatil/api/blob/main/middleware/authMiddleware.js): `middleware/authMiddleware.js`
- [JWT utility](https://github.com/markandeshwaragoudapatil/api/blob/main/utils/jwt.js): `utils/jwt.js`
- [Session service](https://github.com/markandeshwaragoudapatil/api/blob/main/services/loginService.js): `services/loginService.js`
- [Logout service](https://github.com/markandeshwaragoudapatil/api/blob/main/services/logoutService.js): `services/logoutService.js`
- [Profile service](https://github.com/markandeshwaragoudapatil/api/blob/main/services/profileService.js): `services/profileService.js`

### Product catalog

- [Product handler](https://github.com/markandeshwaragoudapatil/api/blob/main/controllers/productController.js): `controllers/productController.js`
- [Product service](https://github.com/markandeshwaragoudapatil/api/blob/main/services/productService.js): `services/productService.js`

### Data models

- [Session records](https://github.com/markandeshwaragoudapatil/api/blob/main/models/Session.js): `models/Session.js`
- [User records](https://github.com/markandeshwaragoudapatil/api/blob/main/models/User.js): `models/User.js`
- [Product records](https://github.com/markandeshwaragoudapatil/api/blob/main/models/productModel.js): `models/productModel.js`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Express app → Login routes: mounts routes (evidence: `app.js`)
- Express app → Registration routes: mounts routes (evidence: `app.js`)
- Express app → Logout routes: mounts routes (evidence: `app.js`)
- Express app → Profile routes: mounts routes (evidence: `app.js`)
- Express app → Product routes: mounts routes (evidence: `app.js`)
- Login routes → Login handler: routes to (evidence: `routes/loginRoutes.js`)
- Registration routes → Registration handler: routes to (evidence: `routes/registerRoutes.js`)
- Logout routes → Logout handler: routes to (evidence: `routes/logoutRoutes.js`)
- Profile routes → Profile handler: routes to (evidence: `routes/profileRoutes.js`)
- Product routes → Product handler: routes to (evidence: `routes/productRoutes.js`)
- Product routes → Async wrapper: wraps handlers (evidence: `routes/productRoutes.js`)
- Product routes → JWT authentication: authenticates with (evidence: `routes/productRoutes.js`)
- Product routes → Admin authorization: authorizes with (evidence: `routes/productRoutes.js`)
- Profile routes → JWT authentication: authenticates with (evidence: `routes/profileRoutes.js`)
- Logout routes → JWT authentication: authenticates with (evidence: `routes/logoutRoutes.js`)
- Login handler → Profile service: checks credentials (evidence: `controllers/loginController.js`)
- Login handler → JWT utility: creates token (evidence: `controllers/loginController.js`)
- Registration handler → Profile service: creates user (evidence: `controllers/registerController.js`)
- Registration handler → JWT utility: creates token (evidence: `controllers/registerController.js`)
- Profile handler → Profile service: gets profile (evidence: `controllers/profileController.js`)
- Product handler → Product service: calls operations (evidence: `controllers/productController.js`)
- Product service → Product records: reads and writes (evidence: `services/productService.js`)
- Product service → Application error: raises errors (evidence: `services/productService.js`)
- Profile service → User records: reads and writes (evidence: `services/profileService.js`)
- JWT authentication → Application error: raises errors (evidence: `middleware/jwtAuthMiddleware.js`)
- Session service → Session records: reads and creates (evidence: `services/loginService.js`)
- Logout service → Session records: uses sessions (evidence: `services/logoutService.js`)
