A modern user management system with Clerk authentication, built with Go, Gin, PostgreSQL, and clean architecture principles.
- Health Check: Basic health monitoring endpoint
- User Management: Complete user CRUD operations with Clerk integration
- Authentication: JWT-based authentication using Clerk
- Database: PostgreSQL with SQLC for type-safe database queries
- Migrations: Database schema management with Goose
- API Documentation: Auto-generated Swagger/OpenAPI documentation
- Clean Architecture: Well-structured codebase with separation of concerns
- Language: Go 1.24
- Web Framework: Gin
- Database: PostgreSQL
- ORM: SQLC (code generation)
- Migrations: Goose
- Authentication: Clerk
- Documentation: Swagger/OpenAPI
- Architecture: Clean Architecture (Handlers → Services → Repositories)
snapdeploy-core/
├── cmd/server/ # Application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── database/ # Database connection and generated code
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # HTTP middleware (auth, CORS)
│ ├── models/ # Domain models
│ ├── repositories/ # Data access layer
│ └── services/ # Business logic layer
├── migrations/ # Database migrations
├── sqlc/ # SQL queries for code generation
├── api/ # OpenAPI specifications
├── docs/ # Generated Swagger documentation
└── data/ # SQLite database file
- Go 1.24 or later
- Docker and Docker Compose
- Clerk account (for authentication)
- Clone the repository:
git clone <repository-url>
cd snapdeploy-core- Install development tools:
make install-tools- Install dependencies:
make deps- Start PostgreSQL with Docker Compose:
make docker-up- Set up environment variables:
cp env.example .env
# Edit .env with your Clerk configuration- Run database migrations:
make migrate-up- Generate code (SQLC, Swagger):
make generate- Build the application:
make build- Run the server:
make runCreate a .env file with the following variables:
# Server Configuration
SERVER_PORT=8080
SERVER_HOST=0.0.0.0
# Database Configuration
DB_DRIVER=postgres
DB_DSN=postgres://snapdeploy:snapdeploy123@localhost:5433/snapdeploy?sslmode=disable
# Clerk Configuration
CLERK_PUBLISHABLE_KEY=pk_test_your-publishable-key
CLERK_SECRET_KEY=sk_test_your-secret-key
CLERK_JWKS_URL=https://your-clerk-instance.clerk.accounts.dev/.well-known/jwks.json
CLERK_ISSUER=https://your-clerk-instance.clerk.accounts.devGET /health- Health check endpoint
GET /api/v1/auth/me- Get current user information (requires authentication)
GET /api/v1/users- List users (requires authentication)GET /api/v1/users/:id- Get user by ID (requires authentication)PUT /api/v1/users/:id- Update user (requires authentication)DELETE /api/v1/users/:id- Delete user (requires authentication)
GET /swagger/index.html- Swagger UI documentation
make help # Show available commands
make install-tools # Install development tools
make setup # Complete development setup
make build # Build the application
make run # Run the application
make test # Run tests
make clean # Clean build artifacts
make generate # Generate code (SQLC, Swagger)
make migrate-up # Run database migrations up
make migrate-down # Run database migrations down
make migrate-create # Create a new migration
make swagger # Generate Swagger documentation
make sqlc # Generate SQLC code
make deps # Download and tidy dependencies
make fmt # Format code
make lint # Lint code
make docker-up # Start PostgreSQL with Docker Compose
make docker-down # Stop Docker Compose services
make docker-build # Build Docker image- Database Changes: Create a new migration with
make migrate-create - SQL Queries: Add queries to
sqlc/queries/and runmake sqlc - API Endpoints: Add handlers in
internal/handlers/ - Business Logic: Add services in
internal/services/ - Data Access: Add repositories in
internal/repositories/
The project uses several code generation tools:
- SQLC: Generates type-safe database code from SQL queries
- Swagger: Generates API documentation from code annotations
Run make generate to regenerate all code.
The API uses Clerk for authentication. Include the JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
The application uses PostgreSQL for production-ready data storage. The database runs in a Docker container for easy development setup.
Database schema changes are managed through migrations:
# Create a new migration
make migrate-create
# Apply migrations
make migrate-up
# Rollback migrations
make migrate-down- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
make fmtandmake lint - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.