A comprehensive boilerplate for building modern SaaS applications with authentication, authorization, project management, and billing capabilities.
- JWT-based authentication with secure token management
- Role-based access control with granular permissions
- User profile management with automatic profile and account creation
- Stripe integration for payment processing
- Multiple subscription plans (Free, Pro, Enterprise)
- Feature-based plan limitations
- Automatic subscription management
- Webhook handling for subscription events
- Multi-tenant architecture with account isolation
- Project management with user-based access control
- Account-level billing and subscription management
- User profiles with customizable settings
- Hot reloading with Air for rapid development
- Comprehensive Go client SDK for API integration
- Database migrations and seeding
- Docker support for containerized development
- Makefile for streamlined development workflow
- Go 1.23+ with Gin web framework
- PostgreSQL/SQLite database with GORM ORM
- Stripe for payment processing
- JWT for authentication
- Air for hot reloading during development
- Render for cloud deployment
- Docker for containerization
- Make for build automation
goiter/
├── core/ # Core application logic
│ ├── handlers/ # HTTP request handlers
│ │ ├── account_handler.go # Account management endpoints
│ │ ├── auth_handler.go # Authentication endpoints
│ │ ├── billing_handler.go # Billing and subscription endpoints
│ │ ├── handler.go # Base handler utilities
│ │ ├── plan_handler.go # Plan management endpoints
│ │ ├── profile_handler.go # User profile endpoints
│ │ └── project_handler.go # Project management endpoints
│ ├── middleware/ # Authentication & authorization middleware
│ │ ├── authentication_middleware.go # JWT authentication
│ │ ├── authorisation_middleware.go # Role-based authorization
│ │ └── middleware.go # Base middleware utilities
│ ├── models/ # Database models and business logic
│ │ ├── account.go # Account model
│ │ ├── authorisation.go # Authorization model
│ │ ├── base_model.go # Base model structure
│ │ ├── db.go # Database connection
│ │ ├── plan.go # Subscription plan model
│ │ ├── profile.go # User profile model
│ │ ├── project.go # Project model
│ │ ├── seed.go # Database seeding
│ │ └── user.go # User model
│ ├── services/ # External service integrations
│ │ └── stripe_service.go # Stripe payment integration
│ └── server.go # Server configuration
├── config/ # Configuration management
│ └── config.go # Application configuration
├── data/ # Seed data and migrations
│ └── seed.json # Initial data seeding
├── testsuite/ # Test suite
│ ├── run/ # Test runner
│ │ └── run.go # Test execution
│ ├── account.go # Account tests
│ ├── profile.go # Profile tests
│ ├── project.go # Project tests
│ ├── server.go # Test server setup
│ ├── testsuite.go # Test suite utilities
│ ├── user.go # User tests
│ └── README.md # Test documentation
├── main.go # Application entry point
├── Makefile # Development workflow commands
├── render.yaml # Deployment configuration
├── go.mod # Go module definition
├── go.sum # Go dependency checksums
└── gorm.db # SQLite database file (development)
- Go 1.23 or higher
- PostgreSQL 13 or higher (or SQLite for development)
- Stripe account (for billing features)
git clone https://github.com/gsarmaonline/goiter.git
cd goiter# Create PostgreSQL database
createdb goiter
# Or using psql
psql -U postgres -c "CREATE DATABASE goiter;"Create a .env file in the root directory:
# Database Configuration (PostgreSQL)
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=goiter
# Or use SQLite for development (comment out PostgreSQL config above)
# DB_NAME=gorm.db
# Server Configuration
PORT=8080
MODE=dev
GIN_MODE=debug
# JWT Configuration
JWT_SECRET=your_jwt_secret
# Stripe Configuration
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secretgo mod download# Start with hot reloading (recommended for development)
make start-backend
# Or start without hot reloading
make start-backend-no-air# Test server connectivity
curl http://localhost:8080/ping
# Run the test suite
make test# Start backend with hot reloading
make start-backend
# Start backend without hot reloading
make start-backend-no-air
# Stop backend server
make stop-backend
# Clean up processes and ports
make clean-air
# Database operations
make db # Connect to database
make clean # Reset database
# Testing
make test # Run test suite# Connect to database
make db
# Reset database (drops and recreates)
make clean
# The application automatically:
# - Runs migrations on startup
# - Seeds initial data (plans, role permissions)
# - Creates user profiles and accountsPOST /login- User login with credentialsPOST /register- User registrationGET /me- Get current user informationPOST /logout- Logout current user
GET /me- Get current user profileGET /profile- Get detailed user profilePUT /profile- Update user profile
GET /projects- List user's projectsPOST /projects- Create new projectGET /projects/:id- Get project detailsPUT /projects/:id- Update projectDELETE /projects/:id- Delete project
GET /account- Get account informationPUT /account- Update account settingsGET /plans- List available subscription plansPOST /billing/subscribe- Create subscriptionPOST /billing/portal- Access billing portal
GET /ping- Health checkGET /plans- List available plans
The project includes a render.yaml file for easy deployment to Render:
- Push to GitHub: Ensure your code is in a GitHub repository
- Create Render Account: Sign up at render.com
- Create New Web Service: Connect your GitHub repository
- Configure Environment Variables:
JWT_SECRETSTRIPE_PUBLISHABLE_KEY,STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET- Database credentials (auto-configured by Render)
# Build the application
go build -o main
# Run in production
./mainThe boilerplate includes a flexible plan system:
- 1 project limit
- Basic features
- No billing required
- 10 project limit
- Advanced features
- $10/month
Easily add new plans by modifying data/seed.json:
{
"plans": [
{
"name": "Enterprise",
"price": 50,
"description": "Enterprise plan with unlimited projects",
"features": [
{
"name": "Projects",
"limit": -1
}
]
}
]
}- JWT-based authentication with secure token settings
- CORS configuration for cross-origin requests
- Input validation and sanitization
- SQL injection protection via GORM
- Rate limiting ready (middleware available)
- HTTPS enforcement in production
# Run the test suite
make test
# Run tests manually
go run testsuite/run/run.go
# Run individual test files
go run testsuite/user.go
go run testsuite/project.go
go run testsuite/account.goThe application includes structured logging and is ready for monitoring integration:
- Structured JSON logging for production
- Request/response logging middleware
- Error tracking with detailed stack traces
- Performance metrics ready for integration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Go best practices and conventions
- Add tests for new features
- Update documentation for API changes
- Use meaningful commit messages
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs and request features via GitHub Issues
- Discussions: Join the community in GitHub Discussions
- Documentation: Visit our Wiki for detailed guides
- Gin Framework for the excellent web framework
- GORM for the powerful ORM
- Stripe for payment processing
- JWT for authentication
- Render for deployment platform
Happy coding! 🚀
Goiter provides everything you need to build a modern SaaS application. Focus on your unique business logic while we handle the boilerplate.