# kbdevs12/go_backend architecture

> Architecture diagram of the GitHub repository kbdevs12/go_backend, 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/kbdevs12/go_backend
- Repository: https://github.com/kbdevs12/go_backend

## Overview

This is a Go/Gin backend for futsal-field booking, customer payments, and admin operations. Customers authenticate through Firebase, check field availability, create and manage bookings, then obtain a QR code and upload payment proof for admin verification. Admins manage bookings, payments, fields and date-specific schedules, users, notifications, reports, and admin accounts. The graph follows documented routes and sampled calls; several admin capabilities are documented but their implementation details were not sampled.

Main entry points: [`cmd/server/router.go`](https://github.com/kbdevs12/go_backend/blob/main/cmd/server/router.go) (API router), [`internal/database/db.go`](https://github.com/kbdevs12/go_backend/blob/main/internal/database/db.go) (PostgreSQL), [`internal/payment/handler.go`](https://github.com/kbdevs12/go_backend/blob/main/internal/payment/handler.go) (Payment workflow), [`internal/auth/handler.go`](https://github.com/kbdevs12/go_backend/blob/main/internal/auth/handler.go) (Login and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP and identity"]
  node_server["Server entry<br/>[main.go]"]
  node_router["API router<br/>[router.go]"]
  node_middleware["Auth middleware<br/>[middleware.go]"]
  node_auth["Login and sessions<br/>[handler.go]"]
  node_jwt["JWT handling<br/>[jwt.go]"]
  node_user["Customer profile<br/>[handler.go]"]
end

subgraph group_booking["Booking and payment"]
  node_booking["Booking and availability<br/>[handler.go]"]
  node_availability["Schedule availability<br/>[availability.go]"]
  node_payment["Payment workflow<br/>[handler.go]"]
  node_qris["QRIS generation<br/>[qris.go]"]
end

subgraph group_admin["Admin operations"]
  node_adminbooking["Admin booking and reports<br/>[handler.go]"]
  node_adminextra["Admin users and payments<br/>[extra_handler.go]"]
  node_fields["Fields and schedules<br/>[field_handler.go]"]
  node_dashboard["Admin dashboard"]
  node_adminaccounts["Admin accounts<br/>[admin_handler.go]"]
end

subgraph group_services["Storage and messaging"]
  node_firebaseauth["Firebase Auth<br/>[firebase.go]"]
  node_notifications["Notification service<br/>[service.go]"]
  node_storage["Proof storage<br/>[supabase_s3.go]"]
  node_fcm["Firebase messaging<br/>[firebase.go]"]
  node_database[("PostgreSQL<br/>[db.go]")]
  node_config["Runtime config<br/>[config.go]"]
end

node_customers(("Customers"))
node_admins(("Admins"))

node_customers -->|"send requests"| node_router
node_admins -->|"send requests"| node_router
node_server -->|"loads config"| node_config
node_server -->|"connects"| node_database
node_server -->|"starts"| node_router
node_router -->|"dispatches login"| node_auth
node_router -->|"dispatches bookings"| node_booking
node_router -->|"dispatches availability"| node_availability
node_router -->|"dispatches payments"| node_payment
node_router -->|"dispatches profile"| node_user
node_router -->|"protects routes"| node_middleware
node_router -->|"dispatches admin routes"| node_adminbooking
node_router -->|"dispatches admin routes"| node_adminextra
node_router -->|"dispatches field routes"| node_fields
node_router -->|"dispatches dashboard"| node_dashboard
node_router -->|"dispatches superadmin routes"| node_adminaccounts
node_auth -->|"verifies identity"| node_firebaseauth
node_auth -->|"reads and writes users"| node_database
node_auth -->|"creates sessions"| node_jwt
node_middleware -->|"validates tokens"| node_jwt
node_user -->|"reads and writes profile"| node_database
node_booking -->|"reads and writes bookings"| node_database
node_booking -->|"notifies admins"| node_notifications
node_availability -->|"reads fields and schedules"| node_database
node_payment -->|"reads and writes payments"| node_database
node_payment -->|"generates QR"| node_qris
node_payment -->|"uploads proof"| node_storage
node_payment -->|"notifies customer"| node_notifications
node_adminbooking -->|"reads booking reports"| node_database
node_adminextra -->|"reads and writes records"| node_database
node_adminextra -->|"creates Firebase user"| node_firebaseauth
node_fields -->|"reads and writes fields"| node_database
node_dashboard -->|"reads dashboard data"| node_database
node_adminaccounts -->|"reads and writes admins"| node_database
node_notifications -->|"stores and reads notifications"| node_database
node_notifications -->|"sends push"| node_fcm
node_storage -.-> node_database
node_fcm -.-> node_firebaseauth

click node_server "https://github.com/kbdevs12/go_backend/blob/main/cmd/server/main.go"
click node_router "https://github.com/kbdevs12/go_backend/blob/main/cmd/server/router.go"
click node_middleware "https://github.com/kbdevs12/go_backend/blob/main/internal/middleware/middleware.go"
click node_auth "https://github.com/kbdevs12/go_backend/blob/main/internal/auth/handler.go"
click node_jwt "https://github.com/kbdevs12/go_backend/blob/main/internal/auth/jwt.go"
click node_firebaseauth "https://github.com/kbdevs12/go_backend/blob/main/pkg/firebase/firebase.go"
click node_user "https://github.com/kbdevs12/go_backend/blob/main/internal/user/handler.go"
click node_booking "https://github.com/kbdevs12/go_backend/blob/main/internal/booking/handler.go"
click node_availability "https://github.com/kbdevs12/go_backend/blob/main/internal/booking/availability.go"
click node_payment "https://github.com/kbdevs12/go_backend/blob/main/internal/payment/handler.go"
click node_qris "https://github.com/kbdevs12/go_backend/blob/main/pkg/qris/qris.go"
click node_adminbooking "https://github.com/kbdevs12/go_backend/blob/main/internal/admin/handler.go"
click node_adminextra "https://github.com/kbdevs12/go_backend/blob/main/internal/admin/extra_handler.go"
click node_fields "https://github.com/kbdevs12/go_backend/blob/main/internal/admin/field_handler.go"
click node_dashboard "https://github.com/kbdevs12/go_backend/blob/main/internal/admin/dashboard_handler.go"
click node_adminaccounts "https://github.com/kbdevs12/go_backend/blob/main/internal/admin/admin_handler.go"
click node_notifications "https://github.com/kbdevs12/go_backend/blob/main/internal/notification/service.go"
click node_storage "https://github.com/kbdevs12/go_backend/blob/main/internal/storage/supabase_s3.go"
click node_fcm "https://github.com/kbdevs12/go_backend/blob/main/pkg/firebase/firebase.go"
click node_database "https://github.com/kbdevs12/go_backend/blob/main/internal/database/db.go"
click node_config "https://github.com/kbdevs12/go_backend/blob/main/internal/config/config.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_router,node_middleware,node_auth,node_jwt,node_user toneBlue
class node_booking,node_availability,node_payment,node_qris toneAmber
class node_adminbooking,node_adminextra,node_fields,node_dashboard,node_adminaccounts toneMint
class node_firebaseauth,node_notifications,node_storage,node_fcm,node_database,node_config toneRose
class node_customers,node_admins toneIndigo
```

## Components

### HTTP and identity

- [Server entry](https://github.com/kbdevs12/go_backend/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [API router](https://github.com/kbdevs12/go_backend/blob/main/cmd/server/router.go): `cmd/server/router.go`
- [Auth middleware](https://github.com/kbdevs12/go_backend/blob/main/internal/middleware/middleware.go): `internal/middleware/middleware.go`
- [Login and sessions](https://github.com/kbdevs12/go_backend/blob/main/internal/auth/handler.go): `internal/auth/handler.go`
- [JWT handling](https://github.com/kbdevs12/go_backend/blob/main/internal/auth/jwt.go): `internal/auth/jwt.go`
- [Customer profile](https://github.com/kbdevs12/go_backend/blob/main/internal/user/handler.go): `internal/user/handler.go`

### Booking and payment

- [Booking and availability](https://github.com/kbdevs12/go_backend/blob/main/internal/booking/handler.go): `internal/booking/handler.go`
- [Schedule availability](https://github.com/kbdevs12/go_backend/blob/main/internal/booking/availability.go): `internal/booking/availability.go`
- [Payment workflow](https://github.com/kbdevs12/go_backend/blob/main/internal/payment/handler.go): `internal/payment/handler.go`
- [QRIS generation](https://github.com/kbdevs12/go_backend/blob/main/pkg/qris/qris.go): `pkg/qris/qris.go`

### Admin operations

- [Admin booking and reports](https://github.com/kbdevs12/go_backend/blob/main/internal/admin/handler.go): `internal/admin/handler.go`
- [Admin users and payments](https://github.com/kbdevs12/go_backend/blob/main/internal/admin/extra_handler.go): `internal/admin/extra_handler.go`
- [Fields and schedules](https://github.com/kbdevs12/go_backend/blob/main/internal/admin/field_handler.go): `internal/admin/field_handler.go`
- [Admin dashboard](https://github.com/kbdevs12/go_backend/blob/main/internal/admin/dashboard_handler.go): `internal/admin/dashboard_handler.go`
- [Admin accounts](https://github.com/kbdevs12/go_backend/blob/main/internal/admin/admin_handler.go): `internal/admin/admin_handler.go`

### Storage and messaging

- [Firebase Auth](https://github.com/kbdevs12/go_backend/blob/main/pkg/firebase/firebase.go): `pkg/firebase/firebase.go`
- [Notification service](https://github.com/kbdevs12/go_backend/blob/main/internal/notification/service.go): `internal/notification/service.go`
- [Proof storage](https://github.com/kbdevs12/go_backend/blob/main/internal/storage/supabase_s3.go): `internal/storage/supabase_s3.go`
- [Firebase messaging](https://github.com/kbdevs12/go_backend/blob/main/pkg/firebase/firebase.go): `pkg/firebase/firebase.go`
- [PostgreSQL](https://github.com/kbdevs12/go_backend/blob/main/internal/database/db.go): `internal/database/db.go`
- [Runtime config](https://github.com/kbdevs12/go_backend/blob/main/internal/config/config.go): `internal/config/config.go`

### Other components

- **Customers**
- **Admins**

## Connections

- Customers → API router: send requests
- Admins → API router: send requests
- Server entry → Runtime config: loads config
- Server entry → PostgreSQL: connects
- Server entry → API router: starts
- API router → Login and sessions: dispatches login
- API router → Booking and availability: dispatches bookings
- API router → Schedule availability: dispatches availability
- API router → Payment workflow: dispatches payments
- API router → Customer profile: dispatches profile
- API router → Auth middleware: protects routes
- API router → Admin booking and reports: dispatches admin routes
- API router → Admin users and payments: dispatches admin routes
- API router → Fields and schedules: dispatches field routes
- API router → Admin dashboard: dispatches dashboard
- API router → Admin accounts: dispatches superadmin routes
- Login and sessions → Firebase Auth: verifies identity
- Login and sessions → PostgreSQL: reads and writes users
- Login and sessions → JWT handling: creates sessions
- Auth middleware → JWT handling: validates tokens
- Customer profile → PostgreSQL: reads and writes profile
- Booking and availability → PostgreSQL: reads and writes bookings
- Booking and availability → Notification service: notifies admins
- Schedule availability → PostgreSQL: reads fields and schedules
- Payment workflow → PostgreSQL: reads and writes payments
- Payment workflow → QRIS generation: generates QR
- Payment workflow → Proof storage: uploads proof
- Payment workflow → Notification service: notifies customer
- Admin booking and reports → PostgreSQL: reads booking reports
- Admin users and payments → PostgreSQL: reads and writes records
- Admin users and payments → Firebase Auth: creates Firebase user
- Fields and schedules → PostgreSQL: reads and writes fields
- Admin dashboard → PostgreSQL: reads dashboard data
- Admin accounts → PostgreSQL: reads and writes admins
- Notification service → PostgreSQL: stores and reads notifications
- Notification service → Firebase messaging: sends push
- Proof storage → PostgreSQL
- Firebase messaging → Firebase Auth
