Skip to content

Commit 02b29ed

Browse files
authored
Merge pull request #4 from KunalKumar-1/makefile
doc: added readme.md
2 parents 1e29b2f + 31a661d commit 02b29ed

File tree

1 file changed

+68
-12
lines changed

1 file changed

+68
-12
lines changed

README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,94 @@ A Go-based event management API built with Gin, SQLite, and JWT authentication.
1111
## Getting Started
1212

1313
### 1. Install Dependencies
14-
1514
```bash
16-
# Install Go dependencies
17-
go mod download
15+
# Using Makefile (recommended)
16+
make install
1817

19-
# Install Air (optional but recommended for development)
20-
go install github.com/cosmtrek/air@latest
18+
# Or manually
19+
go mod download
2120
```
2221

2322
### 2. Environment Setup
2423

2524
Create a `.env` file in the root directory:
26-
2725
```env
2826
PORT=8080
2927
JWT_SECRET=your-secret-key-here
3028
DATABASE_URL=./data.db
3129
```
3230

3331
### 3. Run Database Migrations
34-
3532
```bash
33+
# Using Makefile
34+
make migrate-up
35+
36+
# Or manually
3637
go run cmd/migrate/main.go up
3738
```
3839

3940
### 4. Run the Application
4041

4142
**Option A: Using Air (Recommended for Development)**
42-
4343
```bash
44+
# Using Makefile
45+
make dev
46+
47+
# Or manually
4448
air
4549
```
4650

4751
**Option B: Using Go directly**
48-
4952
```bash
53+
# Using Makefile
54+
make run
55+
56+
# Or manually
5057
go run cmd/api/main.go
5158
```
5259

5360
The API will be available at `http://localhost:8080`
5461

55-
## Project Structure
62+
## Makefile Commands
63+
64+
The project includes a Makefile for common tasks. Run `make help` to see all available commands:
65+
66+
| Command | Description |
67+
|---------|-------------|
68+
| `make help` | Show all available commands |
69+
| `make install` | Install Go dependencies |
70+
| `make deps` | Alias for install |
71+
| `make migrate-up` | Run database migrations |
72+
| `make migrate-down` | Rollback database migrations |
73+
| `make dev` | Start development server with Air |
74+
| `make run` | Run the application |
75+
| `make build` | Build the application binary |
76+
| `make clean` | Clean build artifacts and temp files |
77+
| `make test` | Run tests |
78+
79+
### Examples
80+
```bash
81+
# See all available commands
82+
make help
83+
84+
# Install dependencies and run migrations
85+
make install
86+
make migrate-up
87+
88+
# Start development server
89+
make dev
90+
91+
# Build production binary
92+
make build
93+
94+
# Run tests
95+
make test
96+
97+
# Clean up
98+
make clean
99+
```
56100

101+
## Project Structure
57102
```
58103
.
59104
├── cmd/
@@ -63,10 +108,10 @@ The API will be available at `http://localhost:8080`
63108
│ ├── database/ # Database models and queries
64109
│ └── env/ # Environment configuration
65110
├── server/ # Server configurations
111+
├── Makefile # Build automation
66112
├── data.db # SQLite database
67113
├── .air.toml # Air configuration
68114
└── go.mod # Go modules
69-
70115
```
71116

72117
## API Endpoints
@@ -78,6 +123,17 @@ The API will be available at `http://localhost:8080`
78123

79124
The project uses Air for live reload during development. Any changes to `.go` files will automatically rebuild and restart the server.
80125

126+
Use `make dev` to start the development server with live reload enabled.
127+
128+
## Building for Production
129+
```bash
130+
# Build the binary
131+
make build
132+
133+
# The binary will be created at bin/api
134+
./bin/api
135+
```
136+
81137
## License
82138

83-
MIT
139+
MIT

0 commit comments

Comments
 (0)