# rohmanahmad/api-core architecture

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

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

## Overview

Salesapp is a Fastify API for marketplace-style sales workflows, with client, partner and admin zones. Requests enter through registered v1 routes, are dispatched to controllers, and (where shown) invoke domain services before returning JSON. Product discovery, categories, reviews, authentication and Google sign-in are distinct API stages; PostgreSQL-backed models provide persistence. The repository also exposes Swagger documentation and UI. Several routes, services and models are indexed but not excerpted, so their internal call paths are left unspecified rather than inferred.

Main entry points: [`modules/v1.0/models/index.js`](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/index.js) (SQL model base), [`modules/v1.0/routes/index.js`](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/index.js) (v1 route registry), [`modules/v1.0/controllers/CallbacksController.js`](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/CallbacksController.js) (Google callback), [`bootstrap.js`](https://github.com/rohmanahmad/api-core/blob/master/bootstrap.js) (Fastify server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_server["Fastify server<br/>[bootstrap.js]"]
  node_routes["v1 route registry<br/>[index.js]"]
  node_product_routes["Product routes<br/>[ProductsRoutes.js]"]
  node_category_routes["Category routes"]
  node_review_routes["Review routes<br/>[ReviewsRoutes.js]"]
  node_auth_routes["Authentication routes"]
  node_callback_routes["Callback routes<br/>[CallbacksRoutes.js]"]
  node_user_routes["Account routes"]
  node_webview_routes["Webview routes<br/>[WebviewRoutes.js]"]
end

subgraph group_market["Marketplace domains"]
  node_product_controller["Product controller"]
  node_category_controller["Category controller"]
  node_review_controller["Review controller"]
  node_product_service["Product service<br/>[ProductsService.js]"]
  node_category_service["Category service"]
  node_review_service["Review service<br/>[ReviewsService.js]"]
end

subgraph group_identity["Identity"]
  node_auth_controller["Authentication controller"]
  node_auth_service["Authentication service"]
  node_callback_controller["Google callback"]
  node_google_helper["Google auth helper"]
  node_user_controller["User controller<br/>[UserController.js]"]
  node_account_service["Account service"]
  node_token_service["Token service"]
  node_auth_middleware["Authentication middleware"]
end

subgraph group_persistence["Persistence"]
  node_product_model[("Product records<br/>[ProductsModel.js]")]
  node_category_model[("Category records<br/>[CategoriesModel.js]")]
  node_review_model[("Review records<br/>[ReviewsModel.js]")]
  node_account_model[("Account records")]
  node_otp_model[("OTP records<br/>[OTPCodeModel.js]")]
  node_token_model[("User token records<br/>[UserTokensModel.js]")]
  node_model_base["SQL model base<br/>[index.js]"]
end

subgraph group_docs["API documentation"]
  node_swagger_plugin["Swagger plugin<br/>[index.js]"]
  node_swagger_dynamic["Dynamic spec<br/>[dynamic.js]"]
  node_swagger_routes["Spec and UI routes<br/>[routes.js]"]
end

node_client(("API clients"))

node_client -->|"sends request"| node_server
node_server -->|"registers routes"| node_routes
node_routes -.->|"includes"| node_product_routes
node_routes -.->|"includes"| node_category_routes
node_routes -.->|"includes"| node_review_routes
node_product_routes -->|"dispatches to"| node_product_controller
node_category_routes -->|"dispatches to"| node_category_controller
node_review_routes -->|"dispatches to"| node_review_controller
node_auth_routes -.->|"dispatches to"| node_auth_controller
node_callback_routes -.->|"dispatches to"| node_callback_controller
node_user_routes -.->|"dispatches to"| node_user_controller
node_product_controller -->|"calls"| node_product_service
node_category_controller -.->|"calls"| node_category_service
node_review_controller -->|"calls"| node_review_service
node_auth_controller -.->|"calls"| node_auth_service
node_callback_controller -->|"validates token"| node_google_helper
node_callback_controller -->|"gets account"| node_account_service
node_callback_controller -->|"gets token"| node_token_service
node_auth_service -->|"looks up login"| node_account_model
node_auth_service -->|"checks OTP"| node_otp_model
node_server -->|"registers docs"| node_swagger_plugin
node_swagger_plugin -->|"loads spec"| node_swagger_dynamic
node_swagger_dynamic -->|"uses routes"| node_swagger_routes
node_swagger_routes -->|"serves spec and UI"| node_client
node_product_model -.->|"extends"| node_model_base
node_category_model -.->|"extends"| node_model_base
node_review_model -->|"extends"| node_model_base
node_account_model -.->|"extends"| node_model_base
node_otp_model -.->|"extends"| node_model_base
node_token_model -.->|"extends"| node_model_base

click node_server "https://github.com/rohmanahmad/api-core/blob/master/bootstrap.js"
click node_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/index.js"
click node_product_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/ProductsRoutes.js"
click node_category_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/CategoriesRoutes.js"
click node_review_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/ReviewsRoutes.js"
click node_auth_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/AuthenticationRoutes.js"
click node_callback_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/CallbacksRoutes.js"
click node_user_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/UserAccountsRoutes.js"
click node_webview_routes "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/WebviewRoutes.js"
click node_product_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/ProductsController.js"
click node_category_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/CategoriesController.js"
click node_review_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/ReviewsController.js"
click node_product_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/ProductsService.js"
click node_category_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/CategoriesService.js"
click node_review_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/ReviewsService.js"
click node_auth_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/AuthenticationController.js"
click node_auth_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/AuthenticationService.js"
click node_callback_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/CallbacksController.js"
click node_google_helper "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/helpers/GoogleAuthHelper.js"
click node_user_controller "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/UserController.js"
click node_account_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/UserAccountsService.js"
click node_token_service "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/UserTokensService.js"
click node_auth_middleware "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/middlewares/AuthenticationMiddleware.js"
click node_product_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/ProductsModel.js"
click node_category_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/CategoriesModel.js"
click node_review_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/ReviewsModel.js"
click node_account_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/UserAccountsModel.js"
click node_otp_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/OTPCodeModel.js"
click node_token_model "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/UserTokensModel.js"
click node_model_base "https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/index.js"
click node_swagger_plugin "https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/index.js"
click node_swagger_dynamic "https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/dynamic.js"
click node_swagger_routes "https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/routes.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,node_routes,node_product_routes,node_category_routes,node_review_routes,node_auth_routes,node_callback_routes,node_user_routes,node_webview_routes,node_client toneBlue
class node_product_controller,node_category_controller,node_review_controller,node_product_service,node_category_service,node_review_service toneAmber
class node_auth_controller,node_auth_service,node_callback_controller,node_google_helper,node_user_controller,node_account_service,node_token_service,node_auth_middleware toneMint
class node_product_model,node_category_model,node_review_model,node_account_model,node_otp_model,node_token_model,node_model_base toneRose
class node_swagger_plugin,node_swagger_dynamic,node_swagger_routes toneIndigo
```

## Components

### API runtime

- [Fastify server](https://github.com/rohmanahmad/api-core/blob/master/bootstrap.js): `bootstrap.js`
- [v1 route registry](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/index.js): `modules/v1.0/routes/index.js`
- [Product routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/ProductsRoutes.js): `modules/v1.0/routes/components/ProductsRoutes.js`
- [Category routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/CategoriesRoutes.js): `modules/v1.0/routes/components/CategoriesRoutes.js`
- [Review routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/ReviewsRoutes.js): `modules/v1.0/routes/components/ReviewsRoutes.js`
- [Authentication routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/AuthenticationRoutes.js): `modules/v1.0/routes/components/AuthenticationRoutes.js`
- [Callback routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/CallbacksRoutes.js): `modules/v1.0/routes/components/CallbacksRoutes.js`
- [Account routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/UserAccountsRoutes.js): `modules/v1.0/routes/components/UserAccountsRoutes.js`
- [Webview routes](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/routes/components/WebviewRoutes.js): `modules/v1.0/routes/components/WebviewRoutes.js`

### Marketplace domains

- [Product controller](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/ProductsController.js): `modules/v1.0/controllers/ProductsController.js`
- [Category controller](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/CategoriesController.js): `modules/v1.0/controllers/CategoriesController.js`
- [Review controller](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/ReviewsController.js): `modules/v1.0/controllers/ReviewsController.js`
- [Product service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/ProductsService.js): `modules/v1.0/services/ProductsService.js`
- [Category service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/CategoriesService.js): `modules/v1.0/services/CategoriesService.js`
- [Review service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/ReviewsService.js): `modules/v1.0/services/ReviewsService.js`

### Identity

- [Authentication controller](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/AuthenticationController.js): `modules/v1.0/controllers/AuthenticationController.js`
- [Authentication service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/AuthenticationService.js): `modules/v1.0/services/AuthenticationService.js`
- [Google callback](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/CallbacksController.js): `modules/v1.0/controllers/CallbacksController.js`
- [Google auth helper](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/helpers/GoogleAuthHelper.js): `modules/v1.0/helpers/GoogleAuthHelper.js`
- [User controller](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/controllers/UserController.js): `modules/v1.0/controllers/UserController.js`
- [Account service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/UserAccountsService.js): `modules/v1.0/services/UserAccountsService.js`
- [Token service](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/services/UserTokensService.js): `modules/v1.0/services/UserTokensService.js`
- [Authentication middleware](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/middlewares/AuthenticationMiddleware.js): `modules/v1.0/middlewares/AuthenticationMiddleware.js`

### Persistence

- [Product records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/ProductsModel.js): `modules/v1.0/models/components/ProductsModel.js`
- [Category records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/CategoriesModel.js): `modules/v1.0/models/components/CategoriesModel.js`
- [Review records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/ReviewsModel.js): `modules/v1.0/models/components/ReviewsModel.js`
- [Account records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/UserAccountsModel.js): `modules/v1.0/models/components/UserAccountsModel.js`
- [OTP records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/OTPCodeModel.js): `modules/v1.0/models/components/OTPCodeModel.js`
- [User token records](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/components/UserTokensModel.js): `modules/v1.0/models/components/UserTokensModel.js`
- [SQL model base](https://github.com/rohmanahmad/api-core/blob/master/modules/v1.0/models/index.js): `modules/v1.0/models/index.js`

### API documentation

- [Swagger plugin](https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/index.js): `customize/fastify-swagger/index.js`
- [Dynamic spec](https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/dynamic.js): `customize/fastify-swagger/dynamic.js`
- [Spec and UI routes](https://github.com/rohmanahmad/api-core/blob/master/customize/fastify-swagger/routes.js): `customize/fastify-swagger/routes.js`

### Other components

- **API clients**

## Connections

- API clients → Fastify server: sends request (evidence: `bootstrap.js`)
- Fastify server → v1 route registry: registers routes (evidence: `bootstrap.js`)
- v1 route registry → Product routes: includes
- v1 route registry → Category routes: includes
- v1 route registry → Review routes: includes
- Product routes → Product controller: dispatches to (evidence: `modules/v1.0/routes/components/ProductsRoutes.js`)
- Category routes → Category controller: dispatches to (evidence: `modules/v1.0/routes/components/CategoriesRoutes.js`)
- Review routes → Review controller: dispatches to (evidence: `modules/v1.0/routes/components/ReviewsRoutes.js`)
- Authentication routes → Authentication controller: dispatches to
- Callback routes → Google callback: dispatches to
- Account routes → User controller: dispatches to
- Product controller → Product service: calls (evidence: `modules/v1.0/controllers/ProductsController.js`)
- Category controller → Category service: calls
- Review controller → Review service: calls (evidence: `modules/v1.0/controllers/ReviewsController.js`)
- Authentication controller → Authentication service: calls
- Google callback → Google auth helper: validates token (evidence: `modules/v1.0/controllers/CallbacksController.js`)
- Google callback → Account service: gets account (evidence: `modules/v1.0/controllers/CallbacksController.js`)
- Google callback → Token service: gets token (evidence: `modules/v1.0/controllers/CallbacksController.js`)
- Authentication service → Account records: looks up login (evidence: `modules/v1.0/services/AuthenticationService.js`)
- Authentication service → OTP records: checks OTP (evidence: `modules/v1.0/services/AuthenticationService.js`)
- Fastify server → Swagger plugin: registers docs (evidence: `bootstrap.js`)
- Swagger plugin → Dynamic spec: loads spec (evidence: `customize/fastify-swagger/index.js`)
- Dynamic spec → Spec and UI routes: uses routes (evidence: `customize/fastify-swagger/dynamic.js`)
- Spec and UI routes → API clients: serves spec and UI (evidence: `customize/fastify-swagger/routes.js`)
- Product records → SQL model base: extends
- Category records → SQL model base: extends (evidence: `modules/v1.0/models/components/CategoriesModel.js`)
- Review records → SQL model base: extends (evidence: `modules/v1.0/models/components/ReviewsModel.js`)
- Account records → SQL model base: extends
- OTP records → SQL model base: extends
- User token records → SQL model base: extends
