A Go-based event management API built with Gin, SQLite, and JWT authentication.
- Go 1.24.5 or higher
- Air (for live reload during development)
- SQLite3
# Using Makefile (recommended)
make install
# Or manually
go mod downloadCreate a .env file in the root directory:
PORT=8080
JWT_SECRET=your-secret-key-here
DATABASE_URL=./data.db# Using Makefile
make migrate-up
# Or manually
go run cmd/migrate/main.go upOption A: Using Air (Recommended for Development)
# Using Makefile
make dev
# Or manually
airOption B: Using Go directly
# Using Makefile
make run
# Or manually
go run cmd/api/main.goThe API will be available at http://localhost:8080
The project includes a Makefile for common tasks. Run make help to see all available commands:
| Command | Description |
|---|---|
make help |
Show all available commands |
make install |
Install Go dependencies |
make deps |
Alias for install |
make migrate-up |
Run database migrations |
make migrate-down |
Rollback database migrations |
make dev |
Start development server with Air |
make run |
Run the application |
make build |
Build the application binary |
make clean |
Clean build artifacts and temp files |
make test |
Run tests |
# See all available commands
make help
# Install dependencies and run migrations
make install
make migrate-up
# Start development server
make dev
# Build production binary
make build
# Run tests
make test
# Clean up
make clean├── cmd/
│ ├── api/ # Main API application (Gin server)
│ │ ├── auth.go # Authentication handlers (login, register)
│ │ ├── contex.go # Helper functions to get user from context
│ │ ├── events.go # Event CRUD handlers
│ │ ├── main.go # Entry point for API server
│ │ ├── middleware.go # Authentication & logging middleware
│ │ ├── routes.go # Route definitions
│ │ └── server.go # Server configuration & startup
│ └── migrate/ # Database migrations
│ └── migrations/
│ ├── 000001_create_user_table.up.sql
│ ├── 000001_create_user_table.down.sql
│ ├── 000002_create_events_table.up.sql
│ ├── 000002_create_events_table.down.sql
│ ├── 000003_create_attendance_table.up.sql
│ ├── 000003_create_attendance_table.down.sql
│ └── main.go
│
├── internals/
│ ├── database/ # Database models and queries
│ │ ├── models.go # Model registry
│ │ ├── users.go # User model & queries
│ │ ├── event.go # Event model & queries
│ │ └── attendee.go # Attendance model & queries
│ └── env/ # Environment configuration (env variables)
│ └── env.go
│
├── server/ # Server-related files (local data, configs)
│ └── data.db # Local SQLite database
│
├── tmp/ # Temporary build and runtime files
│ ├── main # Compiled binary (generated by Air)
│ └── build-errors.log # Logs from failed builds
│
├── Makefile # Build & run automation commands
├── go.mod # Go module definition
├── go.sum # Dependency checksums
├── data.db # Development SQLite database
├── .air.toml # Air live-reload configuration
└── README.md # Project documentation
- Authentication endpoints
- Event management endpoints
The project uses Air for live reload during development. Any changes to .go files will automatically rebuild and restart the server.
Use make dev to start the development server with live reload enabled.
# Build the binary
make build
# The binary will be created at bin/api
./bin/apiMIT