How starptech/go-web works
Project type and purpose
• This is a monolithic, full-stack web application written in Go, following the “project-layout” conventions.
• The backend is an HTTP server (Echo) exposing REST and server-side rendered pages; the frontend is a React UI bundled by Parcel and injected into Go templates.
• It uses CockroachDB for persistent storage, Redis for caching, and supports i18n.
File structure
• Top-level:
• main.go – entry point
• internal/ – all Go code, further split into controllers, core (middleware, router, server, error handling, templating), models, store, cache, context, i18n
• config/ – configuration loader
• scripts/ – DB bootstrap SQL
• docker-compose.yml – orchestrates CockroachDB & Redis
• web/ – frontend assets, React components, styles, Go templates
• Tests live alongside their controllers in internal/controller.
• CI/CD: .github/workflows (go.yml, goreleaser.yml), Makefile, goreleaser config.
Key insights from README
• Stack calls out Echo, GORM, validator, godotenv, gotext, Redis, CockroachDB, Parcel, React.
• Developer workflow: docker-compose to spin up infra, build web with Parcel, then run main.go.
• CI is GitHub Actions; releases via goreleaser.
a. Main components
• Client (Browser with React UI)
• HTTP Layer (Echo server + middleware)
• Controller Layer (healthcheck, user, user-list controllers)
• Business Layer / Core (error handler, validator, template engine, router, context injection)
• Data Layer (UserStore via GORM on CockroachDB, CacheStore on Redis)
• i18n subsystem (gotext, .po files under locales/)
• Build & Infra (Parcel bundler, Docker Compose for DB & Redis, CI/CD pipelines)
b. Relationships & interactions
– Client → HTTP Layer via REST or SSR endpoints
– HTTP Layer invokes Controller → Core services → Store layers → External data stores
– Stores talk to CockroachDB (SQL) or Redis (cache) over TCP
– Templating engine merges data + React bundles into HTML delivered to Client
– Docker Compose isolates DB and Redis; .env/config inject into server at startup
– CI/CD pipelines pull from GitHub, run tests/lints, build Go binaries (goreleaser), and can deploy to Heroku
c. Architectural patterns
– Layered (Transport → Controller → Service/Core → Repository)
– Dependency Injection via app_context
– Middleware chain for cross-cutting concerns (logging, error handling, request context)
– Monolith with clear separation of concerns, not microservices
d. Key technologies to annotate
– Echo (HTTP + middleware)
– validator, godotenv, env loader
– GORM for ORM
– Redis client
– Go templates + Parcel + React for frontend
– CockroachDB
– gotext for localization