A tour booking web application with separate public and admin interfaces, built with Go and server-side rendering.
- Backend: Go 1.22+, Gin Web Framework
- Database: PostgreSQL 16, GORM
- Auth: bcrypt, OAuth2 (goth)
- Templating: Go html/template (SSR)
- UI: Bootstrap 5
- Container: Docker, Docker Compose
- Browse tours and categories
- User registration and authentication (email + OAuth2)
- Tour booking with schedule selection
- User profile and bank account management
- Tour ratings and reviews with comments
- User management
- Tour and category management
- Booking and payment tracking
- Review moderation
- Docker and Docker Compose
- Go 1.22+ (for local development)
- Clone the repository:
git clone <repository-url>
cd sun-booking-tours- Copy environment file:
cp .env.example .env- Start services:
make up- Run migrations:
make migrate-up- Access the application:
- Public site: http://localhost:8080
- Admin site: http://localhost:8080/admin
# Start containers
make up
# View logs (follow mode)
make logs
# Stop containers
make down
# Restart containers
make restart
# Rebuild and start
make docker-build# Run migrations (inside Docker)
make migrate-up
# Rollback migration
make migrate-down
# Seed database
make seedFor automatic code reloading during development (run locally, not in Docker):
# 1. Install Air (one-time setup)
go install github.com/air-verse/air@latest
# 2. Make sure .env has GIN_MODE=debug
cp .env.example .env
# Edit .env: GIN_MODE=debug
# 3. Start database only (not the app)
make db
# 4. Run dev server with hot reload
make dev
# or
make run
# Now edit any .go, .html, .css file → auto-reload! ⚡Hot reload features:
- ✅ Go code changes auto-rebuild (~1-2s)
- ✅ Template (.html) changes refresh immediately (no rebuild needed)
- ✅ Static files (.css, .js) auto-reload
Important:
- Hot reload only works when running locally with
make dev - If running in Docker (
make up), templates are cached and won't hot reload - For production,
GIN_MODE=releasecaches templates for performance
# Run tests
make test
# Format code
make fmt
# Tidy dependencies
make tidy├── cmd/app/ # Application entry point
├── internal/
│ ├── config/ # Configuration
│ ├── models/ # GORM models
│ ├── repository/ # Data access layer
│ ├── services/ # Business logic
│ ├── handlers/ # HTTP handlers (admin & public)
│ └── middleware/ # Auth, CSRF, etc.
├── templates/ # Go html templates
├── static/ # CSS, JS, images
├── migrations/ # Database migrations
└── specs/ # Task specifications
The application follows a layered architecture:
Handler → Service → Repository → GORM Model
- Handler: Parse requests, render templates
- Service: Business logic and validation
- Repository: Database queries
- Model: GORM entity definitions
MIT