This repository contains a full-stack web application:
/backend — Go API server/frontend — Svelte frontend applicationCurrently the backend is the primary focus.
Backend follows a domain-based modular structure.
Root folder:
/backend
Important directories:
backend/
│
├── cmd/
│ └── api/
│ ├── main.go # application entrypoint
│ └── api.go # server setup and bootstrapping
│
├── internal/
│ ├── adapters/ # external integrations
│ │ └── postgresql/
│ │ └── sqlc/
│ │ ├── migrations/ # database migrations
│ │ ├── queries.sql # SQL queries used by sqlc
│ │ └── out/ # generated sqlc code
│ │
│ ├── auth/ # authentication logic
│ │
│ ├── env/ # environment variable helpers
│ │
│ ├── tasks/ # tasks domain module
│ │ ├── tasks.handler.go
│ │ ├── tasks.routes.go
│ │ └── tasks.service.go
│ │
│ ├── users/ # users domain module
│ │ ├── users.handler.go
│ │ ├── users.routes.go
│ │ └── users.service.go
Each domain (tasks, users, etc.) contains:
<domain>.handler.go -> HTTP handlers
<domain>.routes.go -> route registration
<domain>.service.go -> business logic
Handlers should remain thin and delegate logic to services.
Services contain the core business logic and interact with repositories.
Repositories are generated using sqlc.
Database access uses:
Location:
internal/adapters/postgresql/sqlc/
Structure:
migrations/ -> schema migrations
queries.sql -> SQL queries
out/ -> generated Go code
Services should call the generated sqlc repository interfaces.
Application entry point:
cmd/api/main.go
Server configuration and wiring:
cmd/api/api.go
These files are responsible for:
Frontend is located in:
/frontend
Technology:
The frontend communicates with the Go API via HTTP.
Domain files follow this naming pattern:
tasks.handler.go
tasks.routes.go
tasks.service.go
handlers → services → repositories (sqlc)
Handlers must not directly access the database.
When generating code:
<domain>.routes.goqueries.sql and generated using sqlcmigrations/Avoid placing application logic in cmd/api.