# bintangstilllerning/crud-api-sprint architecture

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

- Interactive diagram: https://gitdiagram.com/bintangstilllerning/crud-api-sprint
- Repository: https://github.com/bintangstilllerning/crud-api-sprint

## Overview

This is a Go HTTP API for product catalog management and order creation/listing. Requests enter through the router in main.go, reach resource controllers, and are handled by services that coordinate repositories and MySQL transactions. Product operations include create, list, update, and delete in the code, though main.go only registers create, list, and delete routes. Order creation saves an order and its items after looking up referenced products. The README is empty; the graph reflects sampled source, and does not infer uninspected behavior.

Main entry points: [`controller/product_controller.go`](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/product_controller.go) (Product Controller), [`service/order_service.go`](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/service/order_service.go) (Order Service), [`main.go`](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/main.go) (HTTP Router), [`controller/order_controller.go`](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/order_controller.go) (Order Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["HTTP Router<br/>[main.go]"]
  node_product_controller["Product Controller"]
  node_order_controller["Order Controller"]
  node_product_contracts["Product Web Models"]
  node_order_contracts["Order Web Models"]
  node_web_response["Web Response<br/>[web_response.go]"]
end

subgraph group_app["Application Logic"]
  node_product_service["Product Service<br/>[product_service.go]"]
  node_order_service["Order Service<br/>[order_service.go]"]
  node_product_domain["Product Model<br/>[product.go]"]
  node_order_domain["Order Model<br/>[order.go]"]
end

subgraph group_data["Persistence"]
  node_product_repository["Product Repository"]
  node_order_repository["Order Repository"]
end

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

node_client -->|"sends HTTP"| node_server
node_server -->|"routes product requests"| node_product_controller
node_server -->|"routes order requests"| node_order_controller
node_product_controller -->|"decodes and encodes"| node_product_contracts
node_order_controller -->|"decodes and encodes"| node_order_contracts
node_product_controller -->|"builds responses"| node_web_response
node_product_controller -->|"calls operations"| node_product_service
node_order_controller -->|"calls operations"| node_order_service
node_product_service -->|"calls operations"| node_product_repository
node_order_service -->|"saves and lists"| node_order_repository
node_order_service -->|"looks up products"| node_product_repository
node_product_service -->|"manages transactions"| node_mysql
node_order_service -->|"manages transactions"| node_mysql
node_product_repository -->|"queries products"| node_mysql
node_order_repository -->|"queries orders"| node_mysql

click node_server "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/main.go"
click node_product_controller "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/product_controller.go"
click node_order_controller "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/order_controller.go"
click node_product_contracts "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/product_create_request.go"
click node_order_contracts "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/order_create_request.go"
click node_web_response "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/web_response.go"
click node_product_service "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/service/product_service.go"
click node_order_service "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/service/order_service.go"
click node_product_domain "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/product.go"
click node_order_domain "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/order.go"
click node_product_repository "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/repository/product_repository.go"
click node_order_repository "https://github.com/bintangstilllerning/crud-api-sprint/blob/master/repository/order_repository.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_server,node_product_controller,node_order_controller,node_product_contracts,node_order_contracts,node_web_response,node_client toneBlue
class node_product_service,node_order_service,node_product_domain,node_order_domain,node_mysql toneAmber
class node_product_repository,node_order_repository toneMint
```

## Components

### HTTP API

- [HTTP Router](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/main.go): `main.go`
- [Product Controller](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/product_controller.go): `controller/product_controller.go`
- [Order Controller](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/controller/order_controller.go): `controller/order_controller.go`
- [Product Web Models](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/product_create_request.go): `domain/web/product_create_request.go`
- [Order Web Models](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/order_create_request.go): `domain/web/order_create_request.go`
- [Web Response](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/web/web_response.go): `domain/web/web_response.go`

### Application Logic

- [Product Service](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/service/product_service.go): `service/product_service.go`
- [Order Service](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/service/order_service.go): `service/order_service.go`
- [Product Model](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/product.go): `domain/product.go`
- [Order Model](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/domain/order.go): `domain/order.go`

### Persistence

- [Product Repository](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/repository/product_repository.go): `repository/product_repository.go`
- [Order Repository](https://github.com/bintangstilllerning/crud-api-sprint/blob/master/repository/order_repository.go): `repository/order_repository.go`

### Other components

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

## Connections

- API Client → HTTP Router: sends HTTP
- HTTP Router → Product Controller: routes product requests
- HTTP Router → Order Controller: routes order requests
- Product Controller → Product Web Models: decodes and encodes
- Order Controller → Order Web Models: decodes and encodes
- Product Controller → Web Response: builds responses
- Product Controller → Product Service: calls operations
- Order Controller → Order Service: calls operations
- Product Service → Product Repository: calls operations
- Order Service → Order Repository: saves and lists
- Order Service → Product Repository: looks up products
- Product Service → MySQL Database: manages transactions
- Order Service → MySQL Database: manages transactions
- Product Repository → MySQL Database: queries products
- Order Repository → MySQL Database: queries orders
