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
GOAT API is a production-ready, secure, and scalable backend application built with Go, following Clean Architecture principles. It provides a robust foundation for modern web applications with:
π Secure authentication with JWT and refresh tokens
β‘ High-performance session management with Redis
π‘οΈ Fine-grained permission system with role-based access control
β Advanced Rate Limiting with Sliding Window Log algorithm
π Comprehensive observability with Prometheus metrics
π§ͺ Testable architecture with dependency injection
β¨ Features
Core Architecture
Clean Architecture: Strict separation of concerns with testable layers
Domain-Driven Design: Rich domain model with value objects and entities
Repository Pattern: Abstract data access with caching layer
Dependency Injection: Compile-time DI with Google Wire
Rate Limiting
Redis Sliding Window Strategy: Prevent brute-force attacks and resource abuse.
Auth Limits: Tight constraints on login/signup endpoints
Global Limits: Configurable per-IP or per-User throttling via middleware
Delivery: Entry points for the application (Gin HTTP, Middleware).
Pkg: Shared, domain-agnostic utilities (Logger interfaces, ID generators).
π Prerequisites
Go 1.25+
PostgreSQL 12+
Redis 6+
Docker
π API Endpoints
Authentication
Method
Endpoint
Description
POST
/api/v1/auth/login
User login with email/password
POST
/api/v1/auth/signup
User registration
POST
/api/v1/auth/refresh
Refresh access token
POST
/api/v1/auth/logout
Revoke current session
User Management
Method
Endpoint
Description
Permissions
GET
/api/v1/user
Get current user profile
Authenticated
GET
/api/v1/user/:id
Get user by ID
user:read
GET
/api/v1/user/list
List users with filtering
user:read
POST
/api/v1/user
Create new user
user:write
PUT
/api/v1/user/:id
Update user
user:update
PATCH
/api/v1/user/change-email
Update own email
Authenticated
PATCH
/api/v1/user/change-password
Update own password
Authenticated
PATCH
/api/v1/user/:id/change-role
Update user role
user:change_role
PATCH
/api/v1/user/:id/change-status
Update user status
user:change_status
DELETE
/api/v1/user
Delete own account
Authenticated
DELETE
/api/v1/user/:id
Delete user
user:delete
Session Management
Method
Endpoint
Description
GET
/api/v1/sessions
List all active sessions
DELETE
/api/v1/sessions
Revoke sessions
Permission Management
Method
Endpoint
Description
Permissions
GET
/api/v1/permission
List all permissions
full_access
GET
/api/v1/permission/:role
Get permissions by role
full_access
POST
/api/v1/permission
Create new permission
full_access
DELETE
/api/v1/permission/:id
Delete permission
full_access
Infrastructure Endpoints
Method
Endpoint
Description
GET
api/health
Health check endpoint
GET
api/metrics
Prometheus metrics endpoint
π οΈ Development
Project Structure
βββ cmd/app/ # Entry point & Wire DI configuration
βββ internal/
β βββ config/ # Environment-based configuration (envconfig)
β βββ delivery/http/ # Handlers, Middleware, and Gin Routes
β βββ domain/ # Entities, Value Objects, and Repository Interfaces
β βββ usecase/ # Application business logic (Auth, User, Permission)
β βββ infra/ # Implementation of DB, Redis, and External Services
β βββ pkg/ # Cross-cutting concerns (Logger, IDGen, Redis Helpers)
β βββ di/ # Google Wire Provider Sets
βββ build/bin/ # Compiled binaries
Quick Start
# 1. Clone the repository
git clone https://github.com/motixo/goat-api.git
cd goat-api
# 2. Copy and configure environment
cp .env.example .env
# Edit .env with your configuration# 3. Build and run
make run
# 4. Run tests
make test# 5. Build Docker image
make docker-build
Available Make Commands
make build # Build the application
make run # Build and run with .env
make test# Run all tests
make wire # Generate Wire bindings
make clean # Clean build artifacts
make docker-build # Build Docker image
make help# Show all commands