Skip to content

Commit 47c37a2

Browse files
committed
Enhance template repository with better documentation and setup guide
- Add template repository section to README.md - Create TEMPLATE_SETUP.md with detailed setup instructions - Add .env.example file with all required environment variables - Update README to mention GitHub Actions instead of Jenkins - Add quick start guide for template usage - Include customization options and best practices
1 parent 39a2690 commit 47c37a2

File tree

3 files changed

+167
-30
lines changed

3 files changed

+167
-30
lines changed

.env.example

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
1-
# ───────────────────────────────────────────────
2-
# 🌟 Application Configuration
3-
# ───────────────────────────────────────────────
4-
SERVER_PORT=8080
5-
DEBUG=true
6-
DISABLE_LOGS=false
7-
LOG_FORMAT=json
8-
LOG_CALLER=true
9-
LOG_STACKTRACE=false
10-
11-
# ───────────────────────────────────────────────
12-
# 🌟 Database Configuration
13-
# ───────────────────────────────────────────────
14-
DB_HOST=db
1+
# Database Configuration
2+
DB_HOST=localhost
153
DB_PORT=3306
16-
DB_USER=myuser
17-
DB_PASSWORD=mypassword
4+
DB_USER=user
5+
DB_PASSWORD=password
186
DB_NAME=mydatabase
197

20-
# ───────────────────────────────────────────────
21-
# 🌟 Golang Tools Versions
22-
# ───────────────────────────────────────────────
23-
SWAG_VERSION=v1.16.4
24-
MIGRATE_VERSION=v4.16.2
25-
LINT_VERSION=v1.59.1
26-
IMPORTS_VERSION=v0.24.0
27-
VULN_VERSION=v1.1.3
8+
# Server Configuration
9+
SERVER_ADDR=
10+
SERVER_PORT=8080
2811

29-
# ───────────────────────────────────────────────
30-
# 🌟 Jaeger Configruation
31-
# ───────────────────────────────────────────────
12+
# Jaeger Tracing Configuration
3213
JAEGER_AGENT_HOST=localhost
3314
JAEGER_AGENT_PORT=6831
15+
16+
# Optional: Override default values for your specific environment
17+
# DB_HOST=your-database-host
18+
# DB_PORT=3306
19+
# DB_USER=your-database-user
20+
# DB_PASSWORD=your-database-password
21+
# DB_NAME=your-database-name
22+
# SERVER_PORT=8080

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
[![codecov](https://codecov.io/github/MitulShah1/golang-rest-api-template/graph/badge.svg?token=88JSRODXSS)](https://codecov.io/github/MitulShah1/golang-rest-api-template)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/MitulShah1/golang-rest-api-template)](https://goreportcard.com/report/github.com/MitulShah1/golang-rest-api-template)
77

8+
## 🚀 Template Repository
9+
10+
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.
11+
812
## Overview
913

10-
This is a template for building production-ready and easily extendible REST API using Go. It follows best practices and includes a standardized project structure with all necessary components for building scalable microservices.
14+
This template follows best practices and includes a standardized project structure with all necessary components for building scalable microservices.
1115

1216
## Features
1317

@@ -16,7 +20,7 @@ This is a template for building production-ready and easily extendible REST API
1620
- Configuration management
1721
- API documentation with Swagger
1822
- Docker support
19-
- CI/CD pipeline with Jenkins
23+
- CI/CD pipeline with GitHub Actions
2024
- Database migrations
2125
- End-to-end testing
2226
- Makefile for common operations
@@ -37,6 +41,36 @@ The main ones are:
3741
- [otel](https://opentelemetry.io/) for observability
3842
- [jaeger](https://www.jaegertracing.io/) for distributed tracing
3943

44+
## 🎯 Quick Start (Using Template)
45+
46+
### 1. Create Repository from Template
47+
Click the **"Use this template"** button at the top of this repository, or use GitHub CLI:
48+
49+
```bash
50+
gh repo create my-go-api --template MitulShah1/golang-rest-api-template
51+
```
52+
53+
### 2. Clone Your New Repository
54+
```bash
55+
git clone https://github.com/YOUR_USERNAME/my-go-api.git
56+
cd my-go-api
57+
```
58+
59+
### 3. Update Project Details
60+
After creating your repository, update these files:
61+
- `go.mod` - Update module name
62+
- `README.md` - Update project name and description
63+
- `.github/workflows/go.yml` - Update repository references if needed
64+
- `docker-compose.yml` - Update service names if needed
65+
66+
### 4. Start Development
67+
```bash
68+
make help # See all available commands
69+
make env # Create .env file
70+
make docker_up # Start with Docker
71+
make test # Run tests
72+
```
73+
4074
## Project Structure
4175

4276
```sh
@@ -174,7 +208,7 @@ The project includes:
174208

175209
- Dockerfile for containerization
176210
- docker-compose.yml for local development
177-
- Jenkinsfile for CI/CD pipeline
211+
- GitHub Actions for CI/CD pipeline
178212

179213
## Contributing
180214

TEMPLATE_SETUP.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Template Setup Guide
2+
3+
This guide helps you set up your new repository after creating it from this template.
4+
5+
## 🚀 Initial Setup
6+
7+
### 1. Update Module Name
8+
Edit `go.mod` and change the module name:
9+
```go
10+
// Change from:
11+
module github.com/MitulShah1/golang-rest-api-template
12+
13+
// To your module name:
14+
module github.com/YOUR_USERNAME/YOUR_REPO_NAME
15+
```
16+
17+
### 2. Update Repository References
18+
Search and replace these references in your codebase:
19+
- `github.com/MitulShah1/golang-rest-api-template``github.com/YOUR_USERNAME/YOUR_REPO_NAME`
20+
- `MitulShah1/golang-rest-api-template``YOUR_USERNAME/YOUR_REPO_NAME`
21+
22+
### 3. Update README.md
23+
- Change the project title
24+
- Update badges to point to your repository
25+
- Modify the description to match your project
26+
27+
### 4. Update GitHub Actions
28+
In `.github/workflows/go.yml`, update the repository name in badges if needed.
29+
30+
### 5. Update Docker Configuration
31+
In `docker-compose.yml`, consider updating service names to match your project.
32+
33+
## 🔧 Customization Options
34+
35+
### Database Configuration
36+
- Update database connection settings in `config/config.go`
37+
- Modify migration files in `package/database/migrations/`
38+
- Update database driver if switching from MySQL
39+
40+
### API Endpoints
41+
- Modify existing handlers in `internal/handlers/`
42+
- Add new endpoints following the established pattern
43+
- Update Swagger documentation for new endpoints
44+
45+
### Middleware
46+
- Customize middleware in `package/middleware/`
47+
- Add authentication/authorization as needed
48+
- Configure CORS settings for your domain
49+
50+
### Environment Variables
51+
- Update `.env.example` with your specific configuration
52+
- Add new environment variables as needed
53+
- Document all required environment variables
54+
55+
## 📝 Best Practices for Template Usage
56+
57+
### 1. Keep the Structure
58+
- Maintain the established project structure
59+
- Follow the existing patterns for handlers, services, and repositories
60+
- Use the provided middleware and utilities
61+
62+
### 2. Testing
63+
- Write tests for all new functionality
64+
- Follow the existing test patterns
65+
- Maintain high test coverage
66+
67+
### 3. Documentation
68+
- Update Swagger documentation for new endpoints
69+
- Keep README.md up to date
70+
- Document any new configuration options
71+
72+
### 4. CI/CD
73+
- The GitHub Actions workflow is ready to use
74+
- Update repository secrets as needed
75+
- Configure deployment targets
76+
77+
## 🎯 Quick Commands
78+
79+
After setup, use these commands to get started:
80+
81+
```bash
82+
# Install dependencies
83+
go mod tidy
84+
85+
# Run tests
86+
make test
87+
88+
# Start development environment
89+
make docker_up
90+
91+
# Generate API documentation
92+
make generate_docs
93+
94+
# Build the application
95+
make build
96+
```
97+
98+
## 📚 Additional Resources
99+
100+
- [Go Documentation](https://golang.org/doc/)
101+
- [Gorilla Mux](https://github.com/gorilla/mux)
102+
- [Swagger Documentation](https://swagger.io/docs/)
103+
- [Docker Documentation](https://docs.docker.com/)
104+
105+
## 🤝 Support
106+
107+
If you encounter issues with the template:
108+
1. Check the existing issues in this repository
109+
2. Create a new issue with detailed information
110+
3. Consider contributing back improvements
111+
112+
---
113+
114+
**Happy Coding! 🚀**

0 commit comments

Comments
 (0)