# bisket77/project-ramdom architecture

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

## Overview

Lucky Spin is a React-and-Go prize wheel with PostgreSQL-backed prize management, weighted draws, spin history, and visit analytics. A user edits the entry list, the page saves it through the API, and a spin request is decided by the backend; the frontend then animates to the returned winning segment and presents the result. The graph also includes documented history and analytics branches. Backend routing, prize and spin handlers, and the frontend API/hook are supported by sampled source; wiring for analytics and some UI components is based on the README and tree.

Main entry points: [`frontend/src/pages/HomePage.jsx`](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/pages/HomePage.jsx) (Wheel page), [`backend/internal/routes/routes.go`](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/routes/routes.go) (API routes), [`backend/internal/controllers/spin_controller.go`](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/spin_controller.go) (Spin handlers), [`frontend/src/services/api.js`](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_app["React app<br/>[App.jsx]"]
  node_home["Wheel page<br/>[HomePage.jsx]"]
  node_entries["Prize entries<br/>[EntriesPanel.jsx]"]
  node_wheel["Wheel display<br/>[WheelCanvas.jsx]"]
  node_winner["Winner dialog<br/>[WinnerModal.jsx]"]
  node_historyui["History table"]
  node_spinbutton["Spin button<br/>[SpinButton.jsx]"]
  node_hook["Spin hook<br/>[useWheelSpin.js]"]
end

subgraph group_api["API layer"]
  node_service["API client<br/>[api.js]"]
end

subgraph group_backend["Backend logic"]
  node_server["Go server<br/>[main.go]"]
  node_routes["API routes<br/>[routes.go]"]
  node_prizes["Prize handlers"]
  node_spins["Spin handlers<br/>[spin_controller.go]"]
  node_analytics["Visit analytics"]
  node_config["DB config<br/>[db.go]"]
end

subgraph group_storage["Persistent data"]
  node_models["Data models"]
  node_postgres[("PostgreSQL")]
end

node_user(("Wheel user"))

node_user -->|"opens"| node_app
node_app -->|"renders"| node_home
node_home -->|"renders"| node_entries
node_home -->|"renders"| node_wheel
node_home -->|"renders"| node_spinbutton
node_home -->|"renders"| node_historyui
node_home -->|"shows"| node_winner
node_entries -->|"entry changes"| node_home
node_spinbutton -->|"starts spin"| node_home
node_home -->|"loads and spins"| node_hook
node_hook -->|"requests prizes and draws"| node_service
node_home -->|"manages entries and history"| node_service
node_service -->|"HTTP requests"| node_routes
node_server -->|"connects database"| node_config
node_server -->|"registers routes"| node_routes
node_routes -->|"dispatches prize requests"| node_prizes
node_routes -->|"dispatches wheel requests"| node_spins
node_routes -->|"dispatches visit requests"| node_analytics
node_prizes -->|"reads and writes prizes"| node_postgres
node_spins -->|"reads prizes; writes history"| node_postgres
node_spins -->|"increments spin stats"| node_analytics
node_analytics -->|"reads and writes visit stats"| node_postgres
node_config -->|"opens connection"| node_postgres
node_models -->|"defines stored records"| node_postgres

click node_app "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/pages/HomePage.jsx"
click node_entries "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/PrizeList/EntriesPanel.jsx"
click node_wheel "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Wheel/WheelCanvas.jsx"
click node_winner "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Modal/WinnerModal.jsx"
click node_historyui "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/History/SpinHistoryTable.jsx"
click node_spinbutton "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Wheel/SpinButton.jsx"
click node_hook "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/hooks/useWheelSpin.js"
click node_service "https://github.com/bisket77/project-ramdom/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/bisket77/project-ramdom/blob/main/backend/cmd/main.go"
click node_routes "https://github.com/bisket77/project-ramdom/blob/main/backend/internal/routes/routes.go"
click node_prizes "https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/prize_controller.go"
click node_spins "https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/spin_controller.go"
click node_analytics "https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/analytics_controller.go"
click node_config "https://github.com/bisket77/project-ramdom/blob/main/backend/internal/config/db.go"
click node_models "https://github.com/bisket77/project-ramdom/tree/main/backend/internal/models"

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_app,node_home,node_entries,node_wheel,node_winner,node_historyui,node_spinbutton,node_hook,node_user toneBlue
class node_service toneAmber
class node_server,node_routes,node_prizes,node_spins,node_analytics,node_config toneMint
class node_models,node_postgres toneRose
```

## Components

### User interface

- [React app](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Wheel page](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Prize entries](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/PrizeList/EntriesPanel.jsx): `frontend/src/components/PrizeList/EntriesPanel.jsx`
- [Wheel display](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Wheel/WheelCanvas.jsx): `frontend/src/components/Wheel/WheelCanvas.jsx`
- [Winner dialog](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Modal/WinnerModal.jsx): `frontend/src/components/Modal/WinnerModal.jsx`
- [History table](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/History/SpinHistoryTable.jsx): `frontend/src/components/History/SpinHistoryTable.jsx`
- [Spin button](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/components/Wheel/SpinButton.jsx): `frontend/src/components/Wheel/SpinButton.jsx`
- [Spin hook](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/hooks/useWheelSpin.js): `frontend/src/hooks/useWheelSpin.js`

### API layer

- [API client](https://github.com/bisket77/project-ramdom/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Backend logic

- [Go server](https://github.com/bisket77/project-ramdom/blob/main/backend/cmd/main.go): `backend/cmd/main.go`
- [API routes](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/routes/routes.go): `backend/internal/routes/routes.go`
- [Prize handlers](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/prize_controller.go): `backend/internal/controllers/prize_controller.go`
- [Spin handlers](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/spin_controller.go): `backend/internal/controllers/spin_controller.go`
- [Visit analytics](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/controllers/analytics_controller.go): `backend/internal/controllers/analytics_controller.go`
- [DB config](https://github.com/bisket77/project-ramdom/blob/main/backend/internal/config/db.go): `backend/internal/config/db.go`

### Persistent data

- [Data models](https://github.com/bisket77/project-ramdom/tree/main/backend/internal/models): `backend/internal/models`
- **PostgreSQL**

### Other components

- **Wheel user**

## Connections

- Wheel user → React app: opens
- React app → Wheel page: renders
- Wheel page → Prize entries: renders
- Wheel page → Wheel display: renders
- Wheel page → Spin button: renders
- Wheel page → History table: renders
- Wheel page → Winner dialog: shows
- Prize entries → Wheel page: entry changes
- Spin button → Wheel page: starts spin
- Wheel page → Spin hook: loads and spins
- Spin hook → API client: requests prizes and draws
- Wheel page → API client: manages entries and history
- API client → API routes: HTTP requests
- Go server → DB config: connects database
- Go server → API routes: registers routes
- API routes → Prize handlers: dispatches prize requests
- API routes → Spin handlers: dispatches wheel requests
- API routes → Visit analytics: dispatches visit requests
- Prize handlers → PostgreSQL: reads and writes prizes
- Spin handlers → PostgreSQL: reads prizes; writes history
- Spin handlers → Visit analytics: increments spin stats
- Visit analytics → PostgreSQL: reads and writes visit stats
- DB config → PostgreSQL: opens connection
- Data models → PostgreSQL: defines stored records
