# marioshehan22/ice-cream-api architecture

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

- Interactive diagram: https://gitdiagram.com/marioshehan22/ice-cream-api
- Repository: https://github.com/marioshehan22/ice-cream-api

## Overview

This is a Go/Fiber ice cream shop API. A client logs in to receive a JWT, then uses authenticated, role-gated routes for categories, inventory, and customer operations; handlers validate requests and access MySQL-backed records. Startup loads configuration, connects and migrates the database, optionally seeds data, and launches the server. The graph reflects the sampled startup, routing, authentication, and item code; unsampled handler internals are included as documented capabilities, with only their routing relationships shown.

Main entry points: [`internal/server/server.go`](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/server/server.go) (HTTP Routing), [`cmd/server/main.go`](https://github.com/marioshehan22/ice-cream-api/blob/master/cmd/server/main.go) (Server Startup), [`internal/handlers/auth.go`](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/auth.go) (Auth Endpoints), [`internal/handlers/items.go`](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/items.go) (Inventory Items)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup"]
  node_main["Server Startup<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
end

subgraph group_access["HTTP and Access"]
  node_server["HTTP Routing<br/>[server.go]"]
  node_response["API Responses<br/>[response.go]"]
end

subgraph group_auth["Authentication"]
  node_auth_handlers["Auth Endpoints<br/>[auth.go]"]
  node_jwt["JWT Tokens<br/>[jwt.go]"]
  node_middleware["Auth Middleware<br/>[auth.go]"]
end

subgraph group_shop["Shop Operations"]
  node_validation["Request Validation<br/>[validation.go]"]
  node_items["Inventory Items<br/>[items.go]"]
  node_customers["Customers<br/>[customers.go]"]
  node_categories["Categories<br/>[categories.go]"]
  node_handler_helpers["Handler Helpers<br/>[helpers.go]"]
end

subgraph group_data["Data Layer"]
  node_models["Domain Models<br/>[models.go]"]
  node_database["Database Setup<br/>[database.go]"]
  node_seed["Seed Data<br/>[seed.go]"]
end

node_client(("API Client"))
node_mysql[("MySQL")]

node_client -->|"sends requests"| node_server
node_main -->|"loads settings"| node_config
node_main -->|"connects and migrates"| node_database
node_main -->|"seeds optionally"| node_seed
node_main -->|"starts app"| node_server
node_main -->|"creates manager"| node_jwt
node_database -->|"opens connection"| node_mysql
node_database -->|"migrates tables"| node_models
node_server -->|"configures errors"| node_response
node_server -->|"registers authentication"| node_middleware
node_server -->|"routes auth requests"| node_auth_handlers
node_server -->|"routes item requests"| node_items
node_server -->|"routes customer requests"| node_customers
node_server -->|"routes category requests"| node_categories
node_auth_handlers -->|"generates tokens"| node_jwt
node_middleware -->|"parses tokens"| node_jwt
node_auth_handlers -->|"reads claims"| node_middleware
node_auth_handlers -->|"validates login"| node_validation
node_auth_handlers -->|"returns API responses"| node_response
node_middleware -->|"checks revocation and user"| node_mysql
node_items -->|"validates item data"| node_validation
node_items -->|"returns item results"| node_response
node_items -->|"uses request helpers"| node_handler_helpers
node_items -->|"reads and writes records"| node_mysql
node_customers -->|"manages customer records"| node_mysql
node_categories -->|"reads categories"| node_mysql

click node_main "https://github.com/marioshehan22/ice-cream-api/blob/master/cmd/server/main.go"
click node_config "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/config/config.go"
click node_server "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/server/server.go"
click node_response "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/response/response.go"
click node_auth_handlers "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/auth.go"
click node_jwt "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/auth/jwt.go"
click node_middleware "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/middleware/auth.go"
click node_validation "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/validation/validation.go"
click node_items "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/items.go"
click node_customers "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/customers.go"
click node_categories "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/categories.go"
click node_handler_helpers "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/helpers.go"
click node_models "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/models/models.go"
click node_database "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/database/database.go"
click node_seed "https://github.com/marioshehan22/ice-cream-api/blob/master/internal/database/seed.go"

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_main,node_config,node_client toneBlue
class node_server,node_response,node_mysql toneAmber
class node_auth_handlers,node_jwt,node_middleware toneMint
class node_validation,node_items,node_customers,node_categories,node_handler_helpers toneRose
class node_models,node_database,node_seed toneIndigo
```

## Components

### Startup

- [Server Startup](https://github.com/marioshehan22/ice-cream-api/blob/master/cmd/server/main.go): `cmd/server/main.go`
- [Configuration](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/config/config.go): `internal/config/config.go`

### HTTP and Access

- [HTTP Routing](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/server/server.go): `internal/server/server.go`
- [API Responses](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/response/response.go): `internal/response/response.go`

### Authentication

- [Auth Endpoints](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/auth.go): `internal/handlers/auth.go`
- [JWT Tokens](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/auth/jwt.go): `internal/auth/jwt.go`
- [Auth Middleware](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/middleware/auth.go): `internal/middleware/auth.go`

### Shop Operations

- [Request Validation](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/validation/validation.go): `internal/validation/validation.go`
- [Inventory Items](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/items.go): `internal/handlers/items.go`
- [Customers](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/customers.go): `internal/handlers/customers.go`
- [Categories](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/categories.go): `internal/handlers/categories.go`
- [Handler Helpers](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/handlers/helpers.go): `internal/handlers/helpers.go`

### Data Layer

- [Domain Models](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/models/models.go): `internal/models/models.go`
- [Database Setup](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/database/database.go): `internal/database/database.go`
- [Seed Data](https://github.com/marioshehan22/ice-cream-api/blob/master/internal/database/seed.go): `internal/database/seed.go`

### Other components

- **API Client**
- **MySQL**

## Connections

- API Client → HTTP Routing: sends requests (evidence: `README.md`)
- Server Startup → Configuration: loads settings (evidence: `cmd/server/main.go`)
- Server Startup → Database Setup: connects and migrates (evidence: `cmd/server/main.go`)
- Server Startup → Seed Data: seeds optionally (evidence: `cmd/server/main.go`)
- Server Startup → HTTP Routing: starts app (evidence: `cmd/server/main.go`)
- Server Startup → JWT Tokens: creates manager (evidence: `cmd/server/main.go`)
- Database Setup → MySQL: opens connection (evidence: `internal/database/database.go`)
- Database Setup → Domain Models: migrates tables (evidence: `internal/database/database.go`)
- HTTP Routing → API Responses: configures errors (evidence: `internal/server/server.go`)
- HTTP Routing → Auth Middleware: registers authentication (evidence: `internal/server/server.go`)
- HTTP Routing → Auth Endpoints: routes auth requests (evidence: `internal/server/server.go`)
- HTTP Routing → Inventory Items: routes item requests (evidence: `internal/server/server.go`)
- HTTP Routing → Customers: routes customer requests (evidence: `internal/server/server.go`)
- HTTP Routing → Categories: routes category requests (evidence: `internal/server/server.go`)
- Auth Endpoints → JWT Tokens: generates tokens (evidence: `internal/handlers/auth.go`)
- Auth Middleware → JWT Tokens: parses tokens (evidence: `internal/middleware/auth.go`)
- Auth Endpoints → Auth Middleware: reads claims (evidence: `internal/handlers/auth.go`)
- Auth Endpoints → Request Validation: validates login (evidence: `internal/handlers/auth.go`)
- Auth Endpoints → API Responses: returns API responses (evidence: `internal/handlers/auth.go`)
- Auth Middleware → MySQL: checks revocation and user (evidence: `internal/middleware/auth.go`)
- Inventory Items → Request Validation: validates item data (evidence: `internal/handlers/items.go`)
- Inventory Items → API Responses: returns item results (evidence: `internal/handlers/items.go`)
- Inventory Items → Handler Helpers: uses request helpers (evidence: `internal/handlers/items.go`)
- Inventory Items → MySQL: reads and writes records (evidence: `internal/handlers/items.go`)
- Customers → MySQL: manages customer records (evidence: `README.md`)
- Categories → MySQL: reads categories (evidence: `README.md`)
