RESTful API backend for DuckParty - where ducks come to party and show off their style.
A robust, scalable backend service powering the DuckParty platform. Handles duck creation, customization, user authentication, leaderboards, and interactions with a modern tech stack.
This backend powers the DuckParty frontend application. For frontend setup and documentation, visit:
- User Authentication - JWT-based auth with email OTP verification
- Duck Management - Create, customize, and manage duck collections
- Leaderboard System - Ranking based on reactions
- Reaction System - Like/dislike ducks with rate limiting
- Image Storage - Cloudflare R2 integration for duck image hosting
- Email Service - Resend for OTP delivery
- API Documentation - Swagger/OpenAPI documentation
- Scheduled Tasks - Cron jobs for automated operations
- Go - High-performance backend language
- Gin - Fast HTTP web framework
- GORM - ORM for database operations
- PostgreSQL - Relational database
- Redis - Caching and rate limiting
- Cloudflare R2 - Object storage for images
- Resend - Email delivery service
- JWT - Token-based authentication
- Swagger - API documentation
- Go 1.24.4 or higher
- PostgreSQL 16 or higher
- Redis 7 or higher
- Cloudflare account with an R2 bucket configured
- Docker and Docker Compose (optional, for containerized setup)
# Clone the repository
git clone https://github.com/omidnikrah/duckparty-backend.git
cd duckparty-backend
# Install dependencies
go mod download
# Set up environment variables (see Environment Variables section)
cp .env.example .env
# Edit .env with your configuration
# Start the server
airCreate a .env file in the root directory with the following variables:
APP_PORT=4030
API_PREFIX=/api
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=duckparty
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password
# Cloudflare R2
R2_ACCOUNT_ID=your_cloudflare_account_id
R2_ACCESS_KEY_ID=your_r2_access_key
R2_SECRET_ACCESS_KEY=your_r2_secret_key
R2_BUCKET=your_r2_bucket
R2_BASE_URL=your_r2_public_base_url
# JWT
JWT_SECRET=your_jwt_secret_key
# Email
AUTH_SENDER_EMAIL=your_verified_resend_email
RESEND_API_KEY=your_resend_api_key# Start all services (PostgreSQL, Redis, and App)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downOnce the server is running, access the interactive API documentation at:
http://localhost:4030/swagger/index.html
duckparty-backend/
βββ cmd/
β βββ server/ # Server setup and initialization
βββ internal/
β βββ client/ # External service clients (Redis, SES, Cron)
β βββ config/ # Configuration management
β βββ database/ # Database connection and migrations
β βββ dto/ # Data transfer objects
β βββ handler/ # HTTP request handlers
β βββ middleware/ # HTTP middleware (auth, rate limiting, validation)
β βββ model/ # Database models
β βββ routes/ # API route definitions
β βββ service/ # Business logic layer
β βββ storage/ # Storage abstractions (Cloudflare R2)
β βββ templates/ # Email templates
β βββ types/ # Type definitions
β βββ utils/ # Utility functions
βββ docs/ # Swagger documentation
βββ docker-compose.yml # Docker services configuration
βββ Dockerfile # Container build configuration
βββ main.go # Application entry point
This project is deployed using Coolify.
Made with β€οΈβπ₯ for the duck community