A flexible REST API sandbox built with Go for testing and prototyping common backend operations including authentication, authorization, CRUD operations, and other API patterns.
- Authentication & Authorization: JWT-based auth, role-based access control
- CRUD Operations: Complete Create, Read, Update, Delete functionality
- Database Integration: Support for multiple database backends
- Middleware: Request logging, CORS, rate limiting
- Testing Environment: Perfect for API testing and development
- Docker Support: Easy containerization and deployment
- Go 1.24 or higher
- Database (PostgreSQL or MySQL)
- Docker
- Clone the repository:
git clone https://github.com/sudo-which-qp/sandbox_api
cd sandbox_api
- Install dependencies:
go mod download
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Run database migrations:
make migrate-up
There are two docker files available: Dockerfile
and Dockerfile.dev
.
On the docker-compose.yml you can change it there for dev or production.
But you can also run the server with the go command: go run cmd/api/main.go
.
if you don't have docker installed. I will recommend you to using Air
if you want to use docker.
As Air
is already installed in the project, you can run the server with the air
command.
# Development mode
docker-compose up --build
POST /v1/auth/register
- Register a new userPOST /v1/auth/login
- Login userPOST /v1/auth/verify-email
- Verify user emailPOST /v1/auth/forgot-password
- Forgot passwordPOST /v1/auth/reset-password
- Reset passwordPOST /v1/auth/resend-otp
- Resend OTP
# Register a new user
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"first_name":"Test",
"last_name":"User",
"username":"testuser",
"email":"test@example.com",
"password":"password123"
}'
# Login
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password123"}'
GET /v1/user/profile
- Get user profilePOST /v1/user/update-profile
- Update user profile
# Update user profile
curl -X POST http://localhost:8080/v1/user/update-profile \
-H "Content-Type: application/json, Authorization: Bearer <token>" \
-d '{
"first_name":"Test",
"last_name":"User",
}'
# Get user profile
curl -X GET http://localhost:8080/v1/user/profile \
-H "Content-Type: application/json, Authorization: Bearer <token>"
- Define the model in
internal/models/
- Create database repository
internal/store/
- Add HTTP handlers in
cmd/api/
- Register routes in the main server file
# Create new migration
make migration-create user_table
# Run migrations
make migrate-up
# Rollback migrations
make migrate-down
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the CC0 1.0 Universal License - see the LICENSE file for details.