How jolav/codetabs works
Project type and purpose
• This is a monolithic, full-stack Go web application (“codetabs.com”) that exposes multiple small REST-style API services (count-loc, CORS proxy, GitHub/GitLab stars, IP geolocation, Alexa ranking, HTTP headers, weather, random data) and serves a static single-page UI for each service from the “www” directory.
a. Client (Browser)
• Static UI pages (HTML/CSS/JS) under www/…
• One SPA per tool that issues AJAX/JSON or JSONP calls
b. API Server (Go Application)
• main.go: HTTP router, handler registration, static fileserver
• Service modules (each in its own directory: loc, proxy, stars, geolocation, alexa, headers, weather, random)
• Shared utils in _utils/ (JSON marshaling, HTTP clients, stats, random, networking helpers)
• Data layer:
– _data/… CSV and text files (Alexa top-1m, IP geolocation data, random surnames)
– store/… in-memory cache or persistence for rate-limiting or reuse (store/store.go, store/loc.go, store/stars.go)
c. External Dependencies
• GitHub and GitLab REST APIs
• Alexa CSV download
• IP2Location geolocation data
• Public weather API (via IP geolocation)
• Boyter/scc CLI invoked for LOC counting
d. Development tooling
• Air (live reloading via .air.toml)
• go.mod/go.sum for dependency management
Interactions and data flow
• Browser → HTTP GET “/count-loc” or “/api/count-loc?…”
• Router dispatches to the LocService handler
• LocService calls:
• store/loc.go (cache lookup)
• if miss, launches scc, processes its JSON output
• Response marshaled via utils.responses → JSON sent back
• Similar flows for stars, geolocation, Alexa (reads CSV), headers (follows redirects via utils.network), weather (combines geolocation + weather API), random (reads surnames.txt or generates ints)
• CORS proxy simply streams external URLs back to client
Architectural patterns and design principles
• Layered approach:
• HTTP layer (router + handlers)
• Service/business logic layer (one module per endpoint)
• Data access / caching layer
• Shared cross-cutting utilities (logging/stats/utils)
• Modularization by feature (each service in its own package)
• Single monolith process—no microservices or separate deployments
• Static assets served from embedded file server