Project Structure
Component Overview
main.go
The entry point coordinates everything:internal/models
All data structures in one file for easy reference:models.go:5-17
internal/auth
Handles password hashing and session management:- auth.go
- middleware.go
auth/auth.go:12-20
internal/db
Each file handles one domain with plain SQL:internal/handlers
Thin request handlers that delegate todb/ packages:
handlers/posts.go (simplified)
Request Flow
Dependency Tree
oForum has minimal external dependencies:No ORM, no frontend framework, no complex abstractions. Just the essentials.
Embedded Resources
Migrations and templates are embedded into the binary at compile time:main.go:29-33
- ✅ Single binary contains everything
- ✅ No need to distribute separate files
- ✅ Migrations run automatically on startup
- ✅ Templates are always in sync with code
Adding New Features
Adding a New Page
Adding a Database Field
Next Steps
Database Layer
Learn query patterns and migrations
Templates
Work with Go html/template