Sea Catering Backend API is a backend application for a catering service built with Go using Clean Architecture. This application provides services for managing meal plans, subscriptions, user authentication, testimonials, and payment integration.
- Language: Go 1.23.2
- Web Framework: Fiber v2
- Database: PostgreSQL
- Cache: Redis
- ORM: GORM
- Authentication: JWT
- Payment Gateway: Midtrans
- File Storage: Supabase Storage
- Containerization: Docker & Docker Compose
- Documentation: Swagger
- π Authentication & Authorization: JWT-based auth with Google OAuth
- π€ User Management: Registration, login, profile management
- π½οΈ Meal Plan Management: CRUD operations for meal plans
- π Subscription System: Subscription management with payment integration
- π¬ Testimonials: User reviews and ratings
- π³ Payment Integration: Midtrans payment gateway
- π§ Email Service: Email notifications
- π File Upload: Image upload to Supabase storage
- π Analytics: Dashboard stats for admin
- π Caching: Redis for optimal performance
.
βββ .dockerignore # Docker ignore file
βββ .env # Environment variables (local)
βββ .env.example # Template environment variables
βββ .gitignore # Git ignore file
βββ docker-compose.yaml # Docker compose configuration
βββ Dockerfile # Docker build file
βββ go.mod # Go module file
βββ go.sum # Go module checksums
βββ Makefile # Build automation
βββ README.md # Project documentation
βββ cmd/ # Application entry points
β βββ api/
β βββ main.go # Main application entry point
βββ config/ # Configuration
β βββ config.go # Application configuration setup
βββ docs/ # API Documentation
β βββ docs.go # Swagger documentation generator
β βββ swagger.json # Swagger JSON specification
β βββ swagger.yaml # Swagger YAML specification
βββ internal/ # Internal application code
βββ app/ # Application domains
β βββ auth/ # Authentication domain
β β βββ interface/
β β β βββ rest/ # REST API handlers
β β βββ repository/ # Data access layer
β β βββ usecase/ # Business logic layer
β βββ meal_plan/ # Meal Plan domain
β β βββ interface/
β β β βββ rest/ # REST API handlers
β β βββ repository/ # Data access layer
β β βββ usecase/ # Business logic layer
β βββ subscription/ # Subscription domain
β β βββ interface/
β β β βββ rest/ # REST API handlers
β β βββ repository/ # Data access layer
β β βββ usecase/ # Business logic layer
β βββ testimonial/ # Testimonial domain
β β βββ interface/
β β β βββ rest/ # REST API handlers
β β βββ repository/ # Data access layer
β β βββ usecase/ # Business logic layer
β βββ user/ # User domain
β βββ interface/
β β βββ rest/ # REST API handlers
β βββ repository/ # Data access layer
β βββ usecase/ # Business logic layer
βββ bootstrap/ # Application initialization
β βββ bootstrap.go # Dependency injection & app setup
βββ domain/ # Domain models
β βββ dto/ # Data Transfer Objects
β β βββ auth.go # Authentication DTOs
β β βββ meal_plan.go # Meal Plan DTOs
β β βββ subscription.go# Subscription DTOs
β β βββ testimonial.go # Testimonial DTOs
β β βββ user.go # User DTOs
β βββ entity/ # Database entities
β βββ meal_plan.go # Meal Plan entity
β βββ subscription.go# Subscription entity
β βββ testimonial.go # Testimonial entity
β βββ user.go # User entity
βββ infra/ # Infrastructure layer
β βββ email/ # Email service implementation
β βββ fiber/ # Fiber web framework setup
β βββ jwt/ # JWT token implementation
β βββ midtrans/ # Midtrans payment gateway
β βββ oauth/ # OAuth implementation (Google)
β βββ postgresql/ # PostgreSQL database setup
β β βββ migration.go # Database migrations
β β βββ postgresql.go # Database connection
β β βββ seed.go # Database seeding
β βββ redis/ # Redis cache implementation
β βββ response/ # HTTP response utilities
β βββ supabase/ # Supabase storage integration
βββ middleware/ # HTTP middlewares
β βββ authentication.go # Authentication middleware
β βββ authorization.go # Authorization middleware
β βββ middleware.go # Middleware interface
βββ pkg/ # Shared packages
βββ helper/ # Helper utilities
βββ limiter/ # Rate limiting
βββ scheduler/ # Background job scheduler
Application entry point. Contains the main.go
file which initializes and runs the application.
Application configuration that reads environment variables and sets up global configuration.
API documentation generated by Swagger for endpoint documentation.
Domain-driven design where each domain has:
- interface/rest: HTTP handlers for the REST API
- repository: Data access layer for database operations
- usecase: Business logic layer
Dependency injection and application initialization. Manages all dependencies and routing.
- dto: Data Transfer Objects for requests/responses
- entity: Database models with GORM tags
Infrastructure layer containing implementations for:
- email: Service for sending emails
- fiber: Web framework setup
- jwt: JWT token management
- midtrans: Payment gateway integration
- oauth: Google OAuth implementation
- postgresql: Database connection and operations
- redis: Caching layer
- response: Standardized HTTP responses
- supabase: File storage integration
HTTP middlewares for authentication, authorization, and more.
Shared utilities and packages that can be used across the application.
- Go 1.23.2+
- Docker & Docker Compose
- PostgreSQL (if not using Docker)
- Redis (if not using Docker)
Copy the .env.example
file to .env
and fill it with the appropriate values:
cp .env.example .env
Fill in the required environment variables
# Clone the repository
git clone <repository-url>
cd sea-catering-be
# Run with Docker Compose
make run
# or
docker-compose up
# Rebuild containers
make build
# or
docker-compose up --build
# Install dependencies
go mod download
# Run the application
go run cmd/api/main.go
make run # Run the application with Docker
make build # Rebuild containers
make stop # Stop containers
make logs # View logs
make restart # Restart containers
make down-remove-volumes # Stop and remove volumes
Once the application is running, the Swagger API documentation can be accessed at:
http://localhost:8080/swagger/
POST /api/v1/auth/register
- Register a new userPOST /api/v1/auth/login
- Login userGET /api/v1/auth/google
- Google OAuth loginGET /api/v1/auth/google/callback
- Google OAuth callbackPOST /api/v1/auth/refresh
- Refresh tokenPOST /api/v1/auth/logout
- Logout user
GET /api/v1/meal-plans/
- Get all meal plansGET /api/v1/meal-plans/:id
- Get meal plan by ID
POST /api/v1/subscriptions/
- Create a new subscriptionGET /api/v1/subscriptions/
- Get user subscriptionsPUT /api/v1/subscriptions/:id/pause
- Pause a subscriptionDELETE /api/v1/subscriptions/:id
- Cancel a subscription
POST /api/v1/meal-plans/admin/
- Create a new meal planGET /api/v1/subscriptions/admin/stats/new
- New subscriptions statsGET /api/v1/subscriptions/admin/stats/mrr
- Monthly recurring revenueGET /api/v1/subscriptions/admin/stats/active-total
- Total active subscriptionsGET /api/v1/subscriptions/admin/stats/reactivations
- Reactivation stats
The application uses PostgreSQL with GORM as the ORM. The database will be automatically migrated and seeded when the application is first run.
The application will automatically add initial data:
- Users: Admin and sample users
- Meal Plans: Diet Plan, Protein Plan, Royal Plan, Vegan Plan
- Testimonials: Sample testimonials
This project is licensed under the MIT License.