diff --git a/README.md b/README.md index ccf9938..6258b15 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,23 @@ ## 🚀 Template Repository -This is a **template repository** for building production-ready and easily extendible REST APIs using Go. Click the "Use this template" button above to create your own repository based on this template. +This is a **template repository** for building REST APIs with Go. Click the "Use this template" button above to create your own repository based on this template. ## Overview -This template follows best practices and includes a standardized project structure with all necessary components for building scalable microservices. +This template includes everything you need to build a REST API with Go - logging, middleware, database setup, testing, and deployment configs. ## Features - Structured logging -- Middleware support (authentication, etc.) -- Configuration management -- API documentation with Swagger -- Docker support -- CI/CD pipeline with GitHub Actions +- Middleware (auth, CORS, etc.) +- Config management +- API docs with Swagger +- Docker setup +- GitHub Actions CI/CD - Database migrations -- End-to-end testing -- Makefile for common operations +- Tests +- Makefile for common tasks The main ones are: @@ -44,6 +44,7 @@ The main ones are: ## 🎯 Quick Start (Using Template) ### 1. Create Repository from Template + Click the **"Use this template"** button at the top of this repository, or use GitHub CLI: ```bash @@ -51,19 +52,23 @@ gh repo create my-go-api --template MitulShah1/golang-rest-api-template ``` ### 2. Clone Your New Repository + ```bash git clone https://github.com/YOUR_USERNAME/my-go-api.git cd my-go-api ``` ### 3. Update Project Details + After creating your repository, update these files: + - `go.mod` - Update module name - `README.md` - Update project name and description - `.github/workflows/go.yml` - Update repository references if needed - `docker-compose.yml` - Update service names if needed ### 4. Start Development + ```bash make help # See all available commands make env # Create .env file @@ -110,7 +115,7 @@ golang-microservice-template/ ### Prerequisites -- Go 1.21 or higher +- Go 1.21+ - Docker and Docker Compose - Make diff --git a/TEMPLATE_SETUP.md b/TEMPLATE_SETUP.md index 4055ba4..69eda26 100644 --- a/TEMPLATE_SETUP.md +++ b/TEMPLATE_SETUP.md @@ -5,7 +5,9 @@ This guide helps you set up your new repository after creating it from this temp ## 🚀 Initial Setup ### 1. Update Module Name + Edit `go.mod` and change the module name: + ```go // Change from: module github.com/MitulShah1/golang-rest-api-template @@ -15,39 +17,48 @@ module github.com/YOUR_USERNAME/YOUR_REPO_NAME ``` ### 2. Update Repository References + Search and replace these references in your codebase: + - `github.com/MitulShah1/golang-rest-api-template` → `github.com/YOUR_USERNAME/YOUR_REPO_NAME` - `MitulShah1/golang-rest-api-template` → `YOUR_USERNAME/YOUR_REPO_NAME` ### 3. Update README.md + - Change the project title - Update badges to point to your repository - Modify the description to match your project ### 4. Update GitHub Actions + In `.github/workflows/go.yml`, update the repository name in badges if needed. ### 5. Update Docker Configuration + In `docker-compose.yml`, consider updating service names to match your project. ## 🔧 Customization Options ### Database Configuration + - Update database connection settings in `config/config.go` - Modify migration files in `package/database/migrations/` - Update database driver if switching from MySQL ### API Endpoints + - Modify existing handlers in `internal/handlers/` - Add new endpoints following the established pattern - Update Swagger documentation for new endpoints ### Middleware + - Customize middleware in `package/middleware/` - Add authentication/authorization as needed - Configure CORS settings for your domain ### Environment Variables + - Update `.env.example` with your specific configuration - Add new environment variables as needed - Document all required environment variables @@ -55,21 +66,25 @@ In `docker-compose.yml`, consider updating service names to match your project. ## 📝 Best Practices for Template Usage ### 1. Keep the Structure + - Maintain the established project structure - Follow the existing patterns for handlers, services, and repositories - Use the provided middleware and utilities ### 2. Testing + - Write tests for all new functionality - Follow the existing test patterns - Maintain high test coverage ### 3. Documentation + - Update Swagger documentation for new endpoints - Keep README.md up to date - Document any new configuration options ### 4. CI/CD + - The GitHub Actions workflow is ready to use - Update repository secrets as needed - Configure deployment targets @@ -105,6 +120,7 @@ make build ## 🤝 Support If you encounter issues with the template: + 1. Check the existing issues in this repository 2. Create a new issue with detailed information 3. Consider contributing back improvements