ref-app

Reference Application Template - A production-ready Go web application foundation with complete authentication, security, and internationalization. Clone this template to quickly start new projects with a solid foundation.
π― What is ref-app?
ref-app is a template, not a framework. It's a complete, working web application that you clone and customize for your specific needs. Unlike starting from scratch, you get:
- β
Complete authentication system - Login, registration, 2FA, password reset
- β
Admin panel - User management, role-based access control
- β
Internationalization - 4 languages (German default: DE, EN, NL, AF)
- β
Security - CSRF protection, rate limiting, encryption
- β
Modern UI - htmx + Alpine.js + Tailwind CSS
- β
Production-ready - Logging, migrations, health checks
Don't rebuild what already works. Clone ref-app, build your features on top.
π Quick Start: Clone a New Project
Step 1: Clone ref-app for your project
cd /path/to/ref-app/clone
./clone_ref_app.sh myproject "My awesome project description"
Step 2: Set up your new project
cd myproject
cp .env.example .env
# Edit .env - set database credentials, generate encryption keys
createdb myproject
make migrate-up
go build -o bin/myproject cmd/api/main.go
./bin/myproject
Step 3: Start building features
The foundation is ready - now build your project-specific features!
π Documentation
β¨ What's Included
Authentication & Security
Admin Panel
-
User Management
- List, search, filter users
- Create, edit, deactivate users
- Role management (super_admin, admin, moderator, customer)
- Session monitoring
- View user activity history
-
System Configuration
- Email server settings (SMTP)
- Site branding (name, colors, logo)
- Feature flags
- Health monitoring
Internationalization (i18n)
-
4 Languages Supported
- π©πͺ German (default)
- π¬π§ English
- π³π± Dutch
- πΏπ¦ Afrikaans
-
544 translation keys per language
-
Language switcher component
-
User-specific language preferences
-
URL/cookie/database preference support
Developer Experience
-
Database
- PostgreSQL with migrations (golang-migrate)
- Connection pooling
- Prepared statements
- GORM-free (uses database/sql)
-
Testing
- Unit tests
- Integration tests with testcontainers
- Handler tests
- Code coverage reporting
-
Development Tools
- Hot reload with
air
- Makefile for common tasks
- Database migrations up/down
- Seed data scripts
-
CI/CD
- GitHub Actions workflow
- Automated testing
- Security scanning (gosec, govulncheck)
- Multi-platform builds
Tech Stack
- Backend: Go 1.21+ with PostgreSQL 15+
- Frontend: HTML templates + htmx 2.0 + Alpine.js 3.14 + Tailwind CSS
- Auth: Session-based (not JWT)
- Email: SMTP with templates
- Logging: Structured logging with zerolog
π οΈ Development
Prerequisites
- Go 1.21 or higher
- PostgreSQL 15 or higher
- make (optional, for Makefile commands)
Local Development
# Clone the repository (for development on ref-app itself)
git clone https://github.com/namaqua/ref-app.git
cd ref-app
# Set up environment
cp .env.example .env
# Edit .env with your settings
# Create database
createdb ref_app
make migrate-up
# Run with hot reload
air
# Or build and run
go build -o bin/ref-app cmd/api/main.go
./bin/ref-app
Running Tests
# All tests
go test ./...
# With coverage
go test -cover ./...
# Specific package
go test ./internal/auth -v
# Integration tests (requires Docker)
go test -tags=integration ./tests/integration/...
Database Migrations
# Create new migration
make migrate-create name=add_users_table
# Run migrations
make migrate-up
# Rollback
make migrate-down
# Check status
make migrate-status
π¨ UI/UX Design
ref-app follows modern web design principles:
- Clean & Minimal - Focused, uncluttered interfaces
- Responsive - Works on mobile, tablet, desktop
- Accessible - WCAG 2.1 AA compliant
- Modern Stack - htmx for interactivity, Alpine.js for reactivity, Tailwind for styling
Design System: See notes/engine-ui.md for colors, typography, and component guidelines
π Project Structure
ref-app/
βββ cmd/
β βββ api/ # Application entry point
βββ internal/ # Private application code
β βββ auth/ # Authentication & authorization
β βββ twofa/ # Two-factor authentication
β βββ admin/ # Admin panel handlers
β βββ customer/ # Customer dashboard
β βββ settings/ # User settings
β βββ i18n/ # Internationalization
β βββ templates/ # Template system
β βββ email/ # Email service
β βββ encryption/ # Data encryption
β βββ ratelimit/ # Rate limiting
β βββ logging/ # Structured logging
β βββ audit/ # Activity auditing
β βββ middleware/ # HTTP middleware
βββ migrations/ # Database migrations
βββ internal/templates/ # HTML templates
βββ static/ # Static assets (CSS, JS, fonts)
βββ tests/ # Integration tests
βββ clone/ # π¦ Cloning tools
β βββ clone_ref_app.sh
β βββ README.md
β βββ USAGE.md
βββ .claude/ # AI assistant agents
βββ notes/ # Documentation & scripts
π Security
ref-app takes security seriously:
- β
Secure by default - CSRF, secure headers, HTTPS redirect
- β
No SQL injection - Prepared statements everywhere
- β
No XSS - Template auto-escaping
- β
Rate limiting - Protect against brute force
- β
Encryption - AES-256-GCM for sensitive data
- β
Audit logging - Track all security-relevant events
- β
Regular scanning - gosec and govulncheck in CI
Security Scanning
# Run security scanner
make security-scan
# Check for vulnerabilities
make vuln-check
π Internationalization
Adding new languages:
- Copy an existing TOML file:
internal/i18n/locales/en.toml
- Translate all keys to your language
- Add language code to
IsValidLanguage() in middleware.go
- Test with
?lang=xx URL parameter
π¦ Cloning for New Projects
This is the recommended way to use ref-app:
cd ref-app/clone
./clone_ref_app.sh mynewapp "My new application description"
The script will:
- Copy the entire ref-app directory
- Update all references (go.mod, README, etc.)
- Create fresh documentation
- Initialize a clean git repository
- Commit with descriptive message
See clone/README.md for full documentation.
π€ Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linters
- Submit a pull request
Code Standards
- Go code formatted with
gofmt
- Run
go vet and fix issues
- Test coverage > 70%
- All public functions documented
- Commit messages follow conventional commits
π License
MIT License - see LICENSE file for details.
π Acknowledgments
ref-app builds on excellent open-source projects:
π Support
Remember: ref-app is a template, not a framework. Clone it, customize it, make it yours!
π Ready to start? cd clone && ./clone_ref_app.sh myproject "My project"