# nasstyfox/pastimes_api architecture

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

- Interactive diagram: https://gitdiagram.com/nasstyfox/pastimes_api
- Repository: https://github.com/nasstyfox/pastimes_api

## Overview

Pastimes API is an Express backend for user accounts and a product marketplace. Clients enter through the server, which dispatches requests to account, product, cart, or admin routes; those handlers return JSON and, where needed, read or update MySQL. The domain spans registration/login, product browsing and creation, cart updates, and admin seller verification. Authentication middleware verifies JWTs, while admin middleware checks roles. The controller files are empty in the supplied excerpts; the route modules contain the visible behavior. No README was provided, so coverage reflects the tree and source excerpts.

Main entry points: [`server.js`](https://github.com/nasstyfox/pastimes_api/blob/main/server.js) (Express server), [`config/database.js`](https://github.com/nasstyfox/pastimes_api/blob/main/config/database.js) (MySQL connection pool), [`middleware/authMiddleware.js`](https://github.com/nasstyfox/pastimes_api/blob/main/middleware/authMiddleware.js) (JWT authentication), [`routes/admin.js`](https://github.com/nasstyfox/pastimes_api/blob/main/routes/admin.js) (Seller verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_commerce["Marketplace"]
  node_product_routes["Product routes<br/>[products.js]"]
  node_cart_routes["Cart routes<br/>[cart.js]"]
  node_admin_routes["Seller verification<br/>[admin.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Account routes<br/>[auth.js]"]
  node_auth_middleware["JWT authentication<br/>[authMiddleware.js]"]
  node_admin_middleware["Admin authorization<br/>[adminMiddleware.js]"]
end

subgraph group_persistence["Persistence"]
  node_pool["MySQL connection pool<br/>[database.js]"]
  node_mysql[("MySQL database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts auth"| node_auth_routes
node_server -->|"mounts products"| node_product_routes
node_server -->|"mounts cart"| node_cart_routes
node_server -->|"mounts admin"| node_admin_routes
node_server -->|"protects test route"| node_auth_middleware
node_auth_routes -->|"queries users"| node_pool
node_product_routes -->|"reads and writes"| node_pool
node_cart_routes -->|"reads and updates"| node_pool
node_admin_routes -->|"verifies sellers"| node_pool
node_auth_routes -.->|"issues JWTs"| node_auth_middleware
node_product_routes -->|"protects creation"| node_auth_middleware
node_cart_routes -->|"protects cart"| node_auth_middleware
node_admin_routes -->|"authenticates request"| node_auth_middleware
node_admin_routes -->|"checks admin role"| node_admin_middleware
node_pool -->|"connects to"| node_mysql

click node_server "https://github.com/nasstyfox/pastimes_api/blob/main/server.js"
click node_auth_routes "https://github.com/nasstyfox/pastimes_api/blob/main/routes/auth.js"
click node_auth_middleware "https://github.com/nasstyfox/pastimes_api/blob/main/middleware/authMiddleware.js"
click node_admin_middleware "https://github.com/nasstyfox/pastimes_api/blob/main/middleware/adminMiddleware.js"
click node_product_routes "https://github.com/nasstyfox/pastimes_api/blob/main/routes/products.js"
click node_cart_routes "https://github.com/nasstyfox/pastimes_api/blob/main/routes/cart.js"
click node_admin_routes "https://github.com/nasstyfox/pastimes_api/blob/main/routes/admin.js"
click node_pool "https://github.com/nasstyfox/pastimes_api/blob/main/config/database.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_client toneBlue
class node_product_routes,node_cart_routes,node_admin_routes toneAmber
class node_auth_routes,node_auth_middleware,node_admin_middleware toneMint
class node_pool,node_mysql toneRose
```

## Components

### API entry

- [Express server](https://github.com/nasstyfox/pastimes_api/blob/main/server.js): `server.js`

### Marketplace

- [Product routes](https://github.com/nasstyfox/pastimes_api/blob/main/routes/products.js): `routes/products.js`
- [Cart routes](https://github.com/nasstyfox/pastimes_api/blob/main/routes/cart.js): `routes/cart.js`
- [Seller verification](https://github.com/nasstyfox/pastimes_api/blob/main/routes/admin.js): `routes/admin.js`

### Identity and access

- [Account routes](https://github.com/nasstyfox/pastimes_api/blob/main/routes/auth.js): `routes/auth.js`
- [JWT authentication](https://github.com/nasstyfox/pastimes_api/blob/main/middleware/authMiddleware.js): `middleware/authMiddleware.js`
- [Admin authorization](https://github.com/nasstyfox/pastimes_api/blob/main/middleware/adminMiddleware.js): `middleware/adminMiddleware.js`

### Persistence

- [MySQL connection pool](https://github.com/nasstyfox/pastimes_api/blob/main/config/database.js): `config/database.js`
- **MySQL database**

### Other components

- **API client**

## Connections

- API client → Express server: sends requests
- Express server → Account routes: mounts auth (evidence: `server.js`)
- Express server → Product routes: mounts products (evidence: `server.js`)
- Express server → Cart routes: mounts cart (evidence: `server.js`)
- Express server → Seller verification: mounts admin (evidence: `server.js`)
- Express server → JWT authentication: protects test route (evidence: `server.js`)
- Account routes → MySQL connection pool: queries users (evidence: `routes/auth.js`)
- Product routes → MySQL connection pool: reads and writes (evidence: `routes/products.js`)
- Cart routes → MySQL connection pool: reads and updates (evidence: `routes/cart.js`)
- Seller verification → MySQL connection pool: verifies sellers (evidence: `routes/admin.js`)
- Account routes → JWT authentication: issues JWTs
- Product routes → JWT authentication: protects creation (evidence: `routes/products.js`)
- Cart routes → JWT authentication: protects cart (evidence: `routes/cart.js`)
- Seller verification → JWT authentication: authenticates request (evidence: `routes/admin.js`)
- Seller verification → Admin authorization: checks admin role (evidence: `routes/admin.js`)
- MySQL connection pool → MySQL database: connects to (evidence: `config/database.js`)
