How bisket77/project-ramdom works
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: HomePage.jsx Wheel page · routes.go API routes · spin_controller.go Spin handlers · api.js API client
Components 18
User interface
- React app
frontend/src/App.jsx - Wheel page
frontend/src/pages/HomePage.jsx - Prize entries
frontend/src/components/PrizeList/EntriesPanel.jsx - Wheel display
frontend/src/components/Wheel/WheelCanvas.jsx - Winner dialog
frontend/src/components/Modal/WinnerModal.jsx - History table
frontend/src/components/History/SpinHistoryTable.jsx - Spin button
frontend/src/components/Wheel/SpinButton.jsx - Spin hook
frontend/src/hooks/useWheelSpin.js
API layer
- API client
frontend/src/services/api.js
Backend logic
- Go server
backend/cmd/main.go - API routes
backend/internal/routes/routes.go - Prize handlers
backend/internal/controllers/prize_controller.go - Spin handlers
backend/internal/controllers/spin_controller.go - Visit analytics
backend/internal/controllers/analytics_controller.go - DB config
backend/internal/config/db.go
Persistent data
- Data models
backend/internal/models - PostgreSQL
Other components
- Wheel user
Connections 24
- 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