01Overview
Endoudle powers a competitive quiz game set in the Inazuma Eleven universe, challenging players on teams, characters and hissatsu techniques across quiz modes. It is a Go backend built the boring-reliable way: handlers, services and repositories behind clean interfaces, with entities and view models keeping the layers honest.
The fun part is where the data comes from. There is no official
API, so the service scrapes the official zukan site with
colly — behind a scraper interface, so a different source can
be slotted in if the site ever goes down. Scraped data stages as JSON,
then populates PostgreSQL through versioned
golang-migrate migrations (characters, teams,
hissatsus and their relations). Everything is driven from one binary
with flags: --reset-db, --scrape=teams,characters,hissatsus,
--populate-db.
02Architecture
03Stack
| Language | Go 1.25, single binary driven by CLI flags |
|---|---|
| HTTP | gorilla/mux router, seven focused GET endpoints (random/list/info × characters, hissatsus, teams) |
| Scraping | colly + goquery against the zukan site, behind per-domain scraper interfaces |
| Storage | PostgreSQL via pgx; six golang-migrate migrations including join tables (character_teams, hissatsus2type) |
| Shape | Entities with hidden DB IDs, separate viewmodels with explicit mapping; uber zap logging, env config |
04Under the hood
- Swappable scraper behind an interface. The colly-based zukan scrapers implement a
scraperinterface per domain — if the source site dies, only a new implementation is needed, not a rewrite. - Entities never leak. Internal structs hide database IDs (
json:"-") while separate viewmodels shape exactly what the API returns, converted by explicit mapping functions. - Typed scrape targets. An orchestrator with a
Targetenum and forgiving parser turns--scrape=teams,characters,hissatsusinto staged JSON files before anything touches Postgres. - Quiz-ready routes. Seven focused GET endpoints — random/list/info across characters, hissatsus and teams — give quiz clients everything with no over-fetching.
- Rich domain capture. Characters carry twelve modeled attributes — element, position, role, school year, teams, description — and hissatsus link out to videos.