You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. Copy the example environment file and configure it:
44
-
```bash
45
-
cp .env.example .env
46
-
```
46
+
```bash
47
+
cp .env.example .env
48
+
```
49
+
4. Install dependencies:
50
+
```bash
51
+
make dep
52
+
```
47
53
48
54
## Available Make Commands 🚀
49
55
The project includes a comprehensive Makefile with the following commands:
@@ -53,7 +59,37 @@ The project includes a comprehensive Makefile with the following commands:
53
59
make dep # Install and tidy dependencies
54
60
make run # Run the application locally
55
61
make build # Build the application binary
56
-
make test# Run tests
62
+
make run-build # Build and run the application
63
+
```
64
+
65
+
### Module Generation Commands
66
+
```bash
67
+
make module name=<module_name># Generate a new module with all necessary files
68
+
```
69
+
70
+
**Example:**
71
+
```bash
72
+
make module name=product
73
+
```
74
+
75
+
This command will automatically create a complete module structure including:
76
+
- Controller (`product_controller.go`)
77
+
- Service (`product_service.go`)
78
+
- Repository (`product_repository.go`)
79
+
- DTO (`product_dto.go`)
80
+
- Validation (`product_validation.go`)
81
+
- Routes (`routes.go`)
82
+
- Test files for all components
83
+
- Query directory (for custom queries)
84
+
85
+
The generated module follows Clean Architecture principles and is ready to use with proper dependency injection setup.
86
+
87
+
### Testing Commands
88
+
```bash
89
+
make test-auth # Run auth module tests only
90
+
make test-user # Run user module tests only
91
+
make test-all # Run tests for all modules
92
+
make test-coverage # Run tests with coverage report
57
93
```
58
94
59
95
### Local Database Commands (without Docker)
@@ -80,95 +116,147 @@ make container-go # Access Go container shell
80
116
make container-postgres # Access PostgreSQL container
81
117
```
82
118
83
-
There are 2 ways to run the application:
84
-
### With Docker
119
+
## Running the Application 🏃♂️
120
+
121
+
There are two ways to run the application:
122
+
123
+
### Option 1: With Docker
85
124
1. Build and start Docker containers:
86
-
```bash
87
-
make init-docker
88
-
```
89
-
2. Run Initial UUID V4 for Auto Generate UUID:
90
-
```bash
91
-
make init-uuid
92
-
```
93
-
3. Run Migration and Seeder:
94
-
```bash
95
-
make migrate-seed
96
-
```
97
-
98
-
### Without Docker
125
+
```bash
126
+
make init-docker
127
+
```
128
+
2. Initialize UUID V4 extension for auto-generated UUIDs:
129
+
```bash
130
+
make init-uuid
131
+
```
132
+
3. Run migrations and seeders:
133
+
```bash
134
+
make migrate-seed
135
+
```
136
+
4. The application will be available at `http://localhost:8080`
137
+
138
+
### Option 2: Without Docker
99
139
1. Configure `.env` with your PostgreSQL credentials:
100
-
```bash
101
-
DB_HOST=localhost
102
-
DB_USER=postgres
103
-
DB_PASS=
104
-
DB_NAME=
105
-
DB_PORT=5432
106
-
```
107
-
2. Open the terminal and set up PostgreSQL:
108
-
- If you haven't downloaded PostgreSQL, download it first.
109
-
- Run:
110
-
```bash
111
-
psql -U postgres
112
-
```
113
-
- Create the database according to what you put in`.env`:
114
-
```bash
115
-
CREATE DATABASE your_database;
116
-
\c your_database
117
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
118
-
\q
119
-
```
120
-
3. Install dependencies and run the application:
121
-
```bash
122
-
make dep # Install dependencies
123
-
make migrate-local # Run migrations
124
-
make seed-local # Run seeders (optional)
125
-
make run # Start the application
126
-
```
127
-
128
-
## Run Migrations, Seeder, and Script
129
-
To run migrations, seed the database, and execute a script while keeping the application running, use the following command:
140
+
```bash
141
+
DB_HOST=localhost
142
+
DB_USER=postgres
143
+
DB_PASS=your_password
144
+
DB_NAME=your_database
145
+
DB_PORT=5432
146
+
```
147
+
2. Set up PostgreSQL:
148
+
- Download and install PostgreSQL if you haven't already
149
+
- Create a database:
150
+
```bash
151
+
psql -U postgres
152
+
CREATE DATABASE your_database;
153
+
\c your_database
154
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
155
+
\q
156
+
```
157
+
3. Run the application:
158
+
```bash
159
+
make migrate-local # Run migrations
160
+
make seed-local # Run seeders (optional)
161
+
make run # Start the application
162
+
```
163
+
164
+
## Advanced Usage 🔧
165
+
166
+
### Running Migrations, Seeders, and Scripts
167
+
You can run migrations, seed the database, and execute scripts while keeping the application running:
130
168
131
169
```bash
132
170
go run cmd/main.go --migrate --seed --run --script:example_script
133
171
```
134
172
135
-
- ``--migrate`` will apply all pending migrations.
136
-
- ``--seed`` will seed the database with initial data.
137
-
- ``--script:example_script`` will run the specified script (replace ``example_script`` with your script name).
138
-
- ``--run`` will ensure the application continues running after executing the commands above.
173
+
**Available flags:**
174
+
- `--migrate`: Apply all pending migrations
175
+
- `--seed`: Seed the database with initial data
176
+
- `--script:example_script`: Run the specified script (replace `example_script` with your script name)
177
+
- `--run`: Keep the application running after executing the commands above
139
178
140
-
#### Migrate Database
141
-
To migrate the database schema
179
+
### Individual Commands
180
+
181
+
#### Database Migration
142
182
```bash
143
183
go run cmd/main.go --migrate
144
184
```
145
185
This command will apply all pending migrations to your PostgreSQL database specified in`.env`
146
186
147
-
#### Seeder Database
148
-
To seed the database with initial data:
187
+
#### Database Seeding
149
188
```bash
150
189
go run cmd/main.go --seed
151
190
```
152
191
This command will populate the database with initial data using the seeders defined in your application.
153
192
154
-
#### Script Run
155
-
To run a specific script:
193
+
#### Script Execution
156
194
```bash
157
195
go run cmd/main.go --script:example_script
158
196
```
159
-
Replace ``example_script`` with the actual script name in**script.go** at script folder
197
+
Replace `example_script` with the actual script name in**script.go** at the script folder.
198
+
199
+
>**Note:** If you need the application to continue running after performing migrations, seeding, or executing a script, always append the `--run` option.
200
+
201
+
## What You Get 🎁
202
+
203
+
By using this template, you get a production-ready architecture with:
204
+
205
+
### 🏗️ Clean Architecture Implementation
206
+
- **Controller-Service-Repository pattern** with clear separation of concerns
207
+
- **Dependency injection** using samber/do
208
+
- **Modular structure**for easy maintenance and testing
209
+
- **Consistent code organization** across all modules
210
+
211
+
### 🚀 Pre-configured Features
212
+
- **Authentication system** with JWT tokens
213
+
- **User management** with email verification
214
+
- **Password reset** functionality
215
+
- **Database migrations** and seeders
216
+
- **Comprehensive logging** system with web interface
217
+
- **CORS middleware**for cross-origin requests
218
+
- **Input validation** with go-playground/validator
219
+
220
+
### 📚 Documentation & Testing
221
+
- **Postman collection**for API testing
222
+
- **Comprehensive test suite**for all modules
223
+
- **Code coverage** reporting
224
+
- **Issue and PR templates**for better collaboration
225
+
226
+
### 🔧 Developer Experience
227
+
- **Hot reload** with Air for development
228
+
- **Docker support**for easy deployment
229
+
- **Make commands**for common tasks
230
+
- **Module generator**for rapid development
231
+
- **Structured logging** with query tracking
232
+
233
+
## 📖 Documentation
234
+
235
+
### API Documentation
236
+
Explore the available endpoints and their usage in the [Postman Documentation](https://documenter.getpostman.com/view/29665461/2s9YJaZQCG). This documentation provides a comprehensive overview of the API endpoints, including request and response examples.
237
+
238
+
### Contributing
239
+
We welcome contributions! The repository includes templates for issues and pull requests to standardize contributions and improve the quality of discussions and code reviews.
240
+
241
+
- **Issue Template**: Helps in reporting bugs or suggesting features by providing a structured format
242
+
- **Pull Request Template**: Guides contributors to provide clear descriptions of changes and testing steps
160
243
161
-
If you need the application to continue running after performing migrations, seeding, or executing a script, always append the ``--run`` option.
244
+
## 🤝 Contributing
162
245
163
-
## What did you get?
164
-
By using this template, you get a ready-to-go architecture with pre-configured endpoints. The template provides a structured foundation for building your application using Golang with Clean Architecture principles.
246
+
1. Fork the repository
247
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
248
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
249
+
4. Push to the branch (`git push origin feature/amazing-feature`)
250
+
5. Open a Pull Request
165
251
166
-
### Postman Documentation
167
-
You can explore the available endpoints and their usage in the [Postman Documentation](https://documenter.getpostman.com/view/29665461/2s9YJaZQCG). This documentation provides a comprehensive overview of the API endpoints, including request and response examples, making it easier to understand how to interact with the API.
252
+
## 📄 License
168
253
169
-
### Issue / Pull Request Template
254
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
170
255
171
-
The repository includes templates for issues and pull requests to standardize contributions and improve the quality of discussions and code reviews.
256
+
## 🙏 Acknowledgments
172
257
173
-
- **Issue Template**: Helps in reporting bugs or suggesting features by providing a structured format to capture all necessary information.
174
-
- **Pull Request Template**: Guides contributors to provide a clear description of changes, related issues, and testing steps, ensuring smooth and efficient code reviews.
258
+
- [Gin Web Framework](https://gin-gonic.com/)
259
+
- [GORM](https://gorm.io/)
260
+
- [Samber/do](https://github.com/samber/do) for dependency injection
0 commit comments