How arieldiga/snake-game works
This is a small Snake-game web application with a Go HTTP server, static browser content, and a PostgreSQL-backed leaderboard. The visible server workflow serves the static files and routes score submissions and leaderboard reads to separate handlers; those handlers validate or retrieve score data and encode JSON responses. Startup configures the database and creates the leaderboard table. The static page’s contents were not sampled, so its interaction with the API is not asserted. The graph reflects the sampled Go source and file tree.
Main entry points: main.go HTTP server and router · database.go Database connection setup · score_handlers.go Save score handler · score.go Score model
Components 8
Web delivery
- HTTP server and router
main.go - Game static files
static/index.html
Leaderboard API
- Save score handler
handlers/score_handlers.go - Leaderboard handler
handlers/score_handlers.go - Score model
models/score.go
Persistence
- Database connection setup
database/database.go - PostgreSQL
Other components
- Player browser
Connections 10
- HTTP server and router → Game static files: serves
main.go - HTTP server and router → Save score handler: routes POST
main.go - HTTP server and router → Leaderboard handler: routes GET
main.go - Player browser → HTTP server and router: requests pages
- Save score handler → Score model: decodes
handlers/score_handlers.go - Leaderboard handler → Score model: scans and encodes
handlers/score_handlers.go - Save score handler → Database connection setup: inserts via DB
handlers/score_handlers.go - Leaderboard handler → Database connection setup: queries via DB
handlers/score_handlers.go - HTTP server and router → Database connection setup: connects at startup
main.go - Database connection setup → PostgreSQL: opens and initializes
database/database.go