https://github.com/ninjadiego/go-rest-api
🚀 RESTful API built with Go, Gin, JWT authentication and MySQL — clean architecture, ready for production
https://github.com/ninjadiego/go-rest-api
gin golang jwt mysql rest-api
Last synced: 2 months ago
JSON representation
🚀 RESTful API built with Go, Gin, JWT authentication and MySQL — clean architecture, ready for production
- Host: GitHub
- URL: https://github.com/ninjadiego/go-rest-api
- Owner: ninjadiego
- License: mit
- Created: 2026-04-20T18:28:46.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-20T18:39:40.000Z (2 months ago)
- Last Synced: 2026-04-20T20:32:49.536Z (2 months ago)
- Topics: gin, golang, jwt, mysql, rest-api
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 go-rest-api
A production-ready RESTful API built with **Go**, **Gin**, **JWT authentication**, and **MySQL**. Follows clean architecture principles with a clear separation of concerns.
## 🛠️ Tech Stack





## ✨ Features
- ✅ User registration and login
- - ✅ JWT-based authentication & authorization
- - ✅ CRUD operations for resources
- - ✅ MySQL database with GORM ORM
- - ✅ Middleware for route protection
- - ✅ Environment-based configuration
- - ✅ Clean Architecture (handlers, services, repositories)
- - ✅ Docker & Docker Compose support
- ## 📁 Project Structure
- ```
go-rest-api/
├── cmd/
│ └── main.go # Entry point
├── internal/
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # JWT middleware
│ ├── models/ # Data models
│ ├── repository/ # Database layer
│ └── services/ # Business logic
├── config/
│ └── config.go # App configuration
├── docker-compose.yml
├── .env.example
├── go.mod
└── README.md
```
## 🔌 API Endpoints
### Auth
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/v1/auth/register` | Register a new user |
| POST | `/api/v1/auth/login` | Login and get JWT token |
### Users (Protected)
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/v1/users` | Get all users |
| GET | `/api/v1/users/:id` | Get user by ID |
| PUT | `/api/v1/users/:id` | Update user |
| DELETE | `/api/v1/users/:id` | Delete user |
## 🚀 Getting Started
### Prerequisites
- Go 1.21+
- - MySQL 8.0+
- - Docker (optional)
- ### Run with Docker
- ```bash
git clone https://github.com/ninjadiego/go-rest-api.git
cd go-rest-api
cp .env.example .env
docker-compose up --build
```
### Run locally
```bash
git clone https://github.com/ninjadiego/go-rest-api.git
cd go-rest-api
cp .env.example .env
# Edit .env with your database credentials
go mod tidy
go run cmd/main.go
```
## 🔧 Environment Variables
```env
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=go_rest_api
JWT_SECRET=your_jwt_secret_key
PORT=8080
```
## 📄 License
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
---
Made with ❤️ by [ninjadiego](https://github.com/ninjadiego)