Skip to content

goserve Example API - MongoDB โ€‹

Production-Ready Go Backend Architecture with MongoDB

Build scalable REST APIs with MongoDB, 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.

โšก High Performance โ€‹

Redis caching layer and optimized MongoDB queries for blazing-fast API responses.

๐Ÿณ Docker Ready โ€‹

Complete Docker Compose setup with MongoDB, 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 with MongoDB? โ€‹

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

  • Document-Based Storage: MongoDB's flexible document model for complex data structures
  • Clean Architecture: Feature-based modules that scale as your application grows
  • Security First: JWT authentication, API keys, role-based access control
  • Performance: Redis caching, optimized queries, efficient indexing
  • Developer Experience: Code generators, Docker setup, comprehensive tests

Quick Example โ€‹

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

{
  "field": "Sample blog content",
  "status": true
}

Community โ€‹

Released under the Apache 2.0 License