# tupitsin88/stillgood-backend architecture

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

- Interactive diagram: https://gitdiagram.com/tupitsin88/stillgood-backend
- Repository: https://github.com/tupitsin88/stillgood-backend

## Overview

StillGood Backend is a REST backend for discounted surplus-food discovery and pickup booking. The primary flow is client or partner requests routed to domain handlers, through services and repositories to PostgreSQL; the order lifecycle includes booking, mock payment, cancellation or partner completion, and reviews. Separate capabilities include partner inventory and analytics, authentication, notifications, moderation, and media uploads. The README and sampled wiring support the domain-level map; detailed worker internals and some unsampled cross-domain calls are not expanded.

Main entry points: [`internal/app/router.go`](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/app/router.go) (Router and routes), [`internal/adminui/handler.go`](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/adminui/handler.go) (Admin web panel), [`internal/auth/handler.go`](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/auth/handler.go) (Auth handler/service), [`internal/restaurants/handler.go`](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/restaurants/handler.go) (Restaurant discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP entry"]
  node_router["Router and routes<br/>[router.go]"]
end

subgraph group_identity["Identity and admin"]
  node_auth["Auth handler/service<br/>[handler.go]"]
  node_authrepo["Auth repository<br/>[repository.go]"]
  node_adminui["Admin web panel<br/>[handler.go]"]
end

subgraph group_market["Food marketplace"]
  node_categories["Category management<br/>[handler.go]"]
  node_catrepo["Category repository<br/>[repository.go]"]
  node_restaurants["Restaurant discovery<br/>[handler.go]"]
  node_restrepo["Restaurant repository<br/>[repository.go]"]
  node_offers["Offer management<br/>[handler.go]"]
  node_offerrepo["Offer repository<br/>[repository.go]"]
end

subgraph group_orders["Booking and insight"]
  node_orders["Order lifecycle<br/>[handler.go]"]
  node_orderrepo["Order repository<br/>[repository.go]"]
  node_analytics["Partner analytics<br/>[handler.go]"]
  node_analyticsrepo["Analytics repository<br/>[repository.go]"]
  node_notifications["Notification service/API<br/>[service.go]"]
  node_notificationrepo["Notification repository<br/>[repository.go]"]
end

subgraph group_integrations["Storage and delivery"]
  node_postgres[("PostgreSQL")]
  node_filestorage["S3-compatible media<br/>[minio.go]"]
  node_minio[("MinIO / S3")]
  node_email["Email delivery<br/>[sender.go]"]
  node_emailprovider["Resend or log"]
  node_push["FCM provider<br/>[fcm_provider.go]"]
  node_firebase["Firebase Cloud Messaging"]
end

node_clients(("Mobile/API clients"))

node_clients -->|"send requests"| node_router
node_router -->|"dispatches auth"| node_auth
node_router -->|"dispatches admin UI"| node_adminui
node_router -->|"dispatches category"| node_categories
node_router -->|"dispatches restaurant"| node_restaurants
node_router -->|"dispatches offer"| node_offers
node_router -->|"dispatches order"| node_orders
node_router -->|"dispatches analytics"| node_analytics
node_router -->|"dispatches notification"| node_notifications
node_auth -->|"uses repository"| node_authrepo
node_authrepo -->|"reads and writes"| node_postgres
node_auth -->|"sends email"| node_email
node_email -.->|"delivers via"| node_emailprovider
node_adminui -->|"uses service"| node_auth
node_adminui -->|"uses service"| node_categories
node_adminui -->|"uses service"| node_restaurants
node_categories -->|"uses repository"| node_catrepo
node_catrepo -->|"reads and writes"| node_postgres
node_restaurants -->|"uses repository"| node_restrepo
node_restaurants -->|"stores images"| node_filestorage
node_restrepo -->|"reads and writes"| node_postgres
node_offers -->|"uses repository"| node_offerrepo
node_offers -->|"stores images"| node_filestorage
node_offerrepo -->|"reads and writes"| node_postgres
node_orders -->|"uses repository"| node_orderrepo
node_orderrepo -->|"reads and writes"| node_postgres
node_orders -->|"requests notifications"| node_notifications
node_notifications -->|"uses repository"| node_notificationrepo
node_notificationrepo -->|"reads and writes"| node_postgres
node_notifications -->|"dispatches push"| node_push
node_push -.->|"sends push"| node_firebase
node_analytics -->|"uses repository"| node_analyticsrepo
node_analyticsrepo -->|"reads analytics"| node_postgres
node_filestorage -->|"uploads media"| node_minio

click node_router "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/app/router.go"
click node_auth "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/auth/handler.go"
click node_authrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/auth/repository.go"
click node_adminui "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/adminui/handler.go"
click node_categories "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/categories/handler.go"
click node_catrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/categories/repository.go"
click node_restaurants "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/restaurants/handler.go"
click node_restrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/restaurants/repository.go"
click node_offers "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/offers/handler.go"
click node_offerrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/offers/repository.go"
click node_orders "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/orders/handler.go"
click node_orderrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/orders/repository.go"
click node_analytics "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/analytics/handler.go"
click node_analyticsrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/analytics/repository.go"
click node_notifications "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/service.go"
click node_notificationrepo "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/repository.go"
click node_filestorage "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/pkg/filestorage/minio.go"
click node_email "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/email/sender.go"
click node_push "https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/fcm_provider.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_router,node_clients toneBlue
class node_auth,node_authrepo,node_adminui toneAmber
class node_categories,node_catrepo,node_restaurants,node_restrepo,node_offers,node_offerrepo toneMint
class node_orders,node_orderrepo,node_analytics,node_analyticsrepo,node_notifications,node_notificationrepo toneRose
class node_postgres,node_filestorage,node_minio,node_email,node_emailprovider,node_push,node_firebase toneIndigo
```

## Components

### HTTP entry

- [Router and routes](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/app/router.go): `internal/app/router.go`

### Identity and admin

- [Auth handler/service](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/auth/handler.go): `internal/auth/handler.go`
- [Auth repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/auth/repository.go): `internal/auth/repository.go`
- [Admin web panel](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/adminui/handler.go): `internal/adminui/handler.go`

### Food marketplace

- [Category management](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/categories/handler.go): `internal/categories/handler.go`
- [Category repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/categories/repository.go): `internal/categories/repository.go`
- [Restaurant discovery](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/restaurants/handler.go): `internal/restaurants/handler.go`
- [Restaurant repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/restaurants/repository.go): `internal/restaurants/repository.go`
- [Offer management](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/offers/handler.go): `internal/offers/handler.go`
- [Offer repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/offers/repository.go): `internal/offers/repository.go`

### Booking and insight

- [Order lifecycle](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/orders/handler.go): `internal/orders/handler.go`
- [Order repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/orders/repository.go): `internal/orders/repository.go`
- [Partner analytics](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/analytics/handler.go): `internal/analytics/handler.go`
- [Analytics repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/analytics/repository.go): `internal/analytics/repository.go`
- [Notification service/API](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/service.go): `internal/notifications/service.go`
- [Notification repository](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/repository.go): `internal/notifications/repository.go`

### Storage and delivery

- **PostgreSQL**
- [S3-compatible media](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/pkg/filestorage/minio.go): `internal/pkg/filestorage/minio.go`
- **MinIO / S3**
- [Email delivery](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/email/sender.go): `internal/email/sender.go`
- **Resend or log**
- [FCM provider](https://github.com/tupitsin88/stillgood-backend/blob/main/internal/notifications/fcm_provider.go): `internal/notifications/fcm_provider.go`
- **Firebase Cloud Messaging**

### Other components

- **Mobile/API clients**

## Connections

- Mobile/API clients → Router and routes: send requests
- Router and routes → Auth handler/service: dispatches auth
- Router and routes → Admin web panel: dispatches admin UI
- Router and routes → Category management: dispatches category
- Router and routes → Restaurant discovery: dispatches restaurant
- Router and routes → Offer management: dispatches offer
- Router and routes → Order lifecycle: dispatches order
- Router and routes → Partner analytics: dispatches analytics
- Router and routes → Notification service/API: dispatches notification
- Auth handler/service → Auth repository: uses repository
- Auth repository → PostgreSQL: reads and writes
- Auth handler/service → Email delivery: sends email
- Email delivery → Resend or log: delivers via
- Admin web panel → Auth handler/service: uses service
- Admin web panel → Category management: uses service
- Admin web panel → Restaurant discovery: uses service
- Category management → Category repository: uses repository
- Category repository → PostgreSQL: reads and writes
- Restaurant discovery → Restaurant repository: uses repository
- Restaurant discovery → S3-compatible media: stores images
- Restaurant repository → PostgreSQL: reads and writes
- Offer management → Offer repository: uses repository
- Offer management → S3-compatible media: stores images
- Offer repository → PostgreSQL: reads and writes
- Order lifecycle → Order repository: uses repository
- Order repository → PostgreSQL: reads and writes
- Order lifecycle → Notification service/API: requests notifications
- Notification service/API → Notification repository: uses repository
- Notification repository → PostgreSQL: reads and writes
- Notification service/API → FCM provider: dispatches push
- FCM provider → Firebase Cloud Messaging: sends push
- Partner analytics → Analytics repository: uses repository
- Analytics repository → PostgreSQL: reads analytics
- S3-compatible media → MinIO / S3: uploads media
