Skip to content

goserve Example API - PostgreSQL โ€‹

Production-Ready Go Backend Architecture

Build scalable REST APIs with PostgreSQL, Redis, JWT auth, and clean modular design.

Key Features โ€‹

๐Ÿ—๏ธ Modular Architecture โ€‹

Feature-based organization with clean separation of controllers, services, models, and DTOs for maintainable code.

๐Ÿ” Complete Authentication โ€‹

JWT-based authentication with RSA signing, refresh tokens, and role-based authorization (LEARNER, AUTHOR, EDITOR, ADMIN).

โšก High Performance โ€‹

Redis caching layer, PostgreSQL connection pooling, and optimized queries for blazing-fast API responses.

๐Ÿณ Docker Ready โ€‹

Complete Docker Compose setup with PostgreSQL, Redis, and application containers for easy development and deployment.

๐Ÿงช Comprehensive Testing โ€‹

Unit tests and integration tests included with helper utilities for testing authentication and authorization flows.

๐Ÿ“ API Key Protection โ€‹

All endpoints protected with API key middleware, ensuring secure access control at the infrastructure level.

๐Ÿ”„ Code Generation โ€‹

Built-in CLI tools to generate new API features with proper structure, saving development time and ensuring consistency.

๐ŸŽฏ Production Ready โ€‹

Best practices for error handling, validation, logging, and security built-in from day one.

Why goserve? โ€‹

The goserve framework provides a robust foundation for building production-ready REST APIs in Go. This example project demonstrates:

  • Clean Architecture: Feature-based modules that scale as your application grows
  • Security First: JWT authentication, API keys, role-based access control
  • Performance: Redis caching, database connection pooling, efficient queries
  • Developer Experience: Code generators, Docker setup, comprehensive tests

Quick Example โ€‹

go
// Create a new blog post
POST /blog/author
Authorization: Bearer <jwt_token>
x-api-key: your-api-key

{
  "title": "My First Blog",
  "description": "A great blog post",
  "draftText": "Full blog content here...",
  "slug": "my-first-blog",
  "imgUrl": "https://example.com/image.jpg",
  "tags": ["TECH", "GOLANG"]
}

Community โ€‹

Released under the Apache 2.0 License