A modern, scalable, and feature-rich real-time auction platform built with Go
π Quick Start β’ π Documentation β’ ποΈ Architecture β’ π€ Contributing
- π Features
- ποΈ Architecture
- π Quick Start
- βοΈ Configuration
- π³ Docker Deployment
- π API Documentation
- π§ͺ Testing
- π Production Deployment
- π§ Development
- π€ Contributing
- π License
- Real-time Bidding: WebSocket-powered live bidding with instant updates
- User Authentication: Secure JWT-based authentication with Google OAuth integration
- Advanced Search: Category-based filtering and advanced auction discovery
- File Upload: S3-compatible image upload for auction items
- Email Notifications: Automated email alerts for auction events
- Robust Database: PostgreSQL with optimized indexing and triggers
- Rate Limiting: Built-in protection against API abuse
- Graceful Shutdown: Proper cleanup of resources and connections
- JWT Authentication: Secure token-based authentication
- Password Hashing: bcrypt password encryption
- CORS Protection: Configurable cross-origin resource sharing
- Rate Limiting: Redis-based rate limiting middleware
- Database Migrations: Version-controlled database schema management
- Connection Pooling: Optimized database connection management
- Live Bid Updates: Instant bid notifications via WebSockets
- Auction Status Tracking: Real-time auction state management
- User Activity Monitoring: Live user engagement tracking
- Automated Scheduling: Cron-based auction lifecycle management
BidZy follows a clean, modular architecture with clear separation of concerns:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Load Balancer β β Monitoring β
β (Web/Mobile) βββββΊβ (Nginx/ALB) βββββΊβ (Metrics) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββ
β BidZy Server β
β (Go Application) β
βββββββββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β PostgreSQL β β Redis β β AWS S3 β
β (Database) β β (Cache) β β (Storage) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
BidZy/
βββ cmd/ # Application entry points
β βββ server/ # Main server application
β βββ seed/ # Database seeding utility
βββ internal/ # Private application code
β βββ handler/ # HTTP handlers and routing
β βββ middleware/ # HTTP middleware (auth, CORS, rate limiting)
β βββ migrations/ # Database migrations
β βββ scheduler/ # Background job scheduling
β βββ service/ # Business logic layer
β β βββ auction/ # Auction management & WebSocket
β β βββ auth/ # Authentication & authorization
β β βββ bid/ # Bidding logic
β β βββ category/ # Category management
β β βββ mail/ # Email services
β β βββ user/ # User management
β βββ store/ # Data access layer
βββ pkg/ # Public packages
β βββ types/ # Shared data types
β βββ utils/ # Utility functions
βββ database/ # Database files (development)
- Authentication Service: JWT token management, OAuth integration
- Auction Service: Core auction logic, WebSocket management
- Bidding Service: Bid validation, real-time updates
- User Service: Profile management, statistics
- Category Service: Category-based organization
- Mail Service: Notification system, email templates
- File Service: S3 integration for media uploads
- Go 1.24.2+
- PostgreSQL 15+
- Redis 7.2+
- Docker & Docker Compose (recommended)
- Clone the repository
git clone https://github.com/LikhithMar14/BidZy.git
cd BidZy- Start services with Docker Compose
docker-compose up -d- Set up environment variables
cp .env.example .env
# Edit .env with your configuration- Run the application
go run cmd/server/main.go- Install dependencies
go mod tidy- Set up PostgreSQL
# Create database
createdb auction-db
# Set environment variables
export DB_ADDR="postgres://user:password@localhost:5460/auction-db?sslmode=disable"- Set up Redis
# Start Redis server
redis-server
# Or use Docker
docker run -d -p 6379:6379 redis:7.2-alpine- Configure environment
export JWT_SECRET="your-super-secret-jwt-key"
export GOOGLE_CLIENT_ID="your-google-oauth-client-id"
export GOOGLE_CLIENT_SECRET="your-google-oauth-secret"
export S3_BUCKET_NAME="your-s3-bucket"
export SMTP_HOST="smtp.gmail.com"
export SMTP_PORT="587"
export SMTP_USER="your-email@gmail.com"
export SMTP_PASS="your-app-password"- Run migrations and start server
go run cmd/server/main.goThe server will start on http://localhost:8080 π
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 8080 |
No |
DB_ADDR |
PostgreSQL connection string | - | Yes |
JWT_SECRET |
JWT signing secret | - | Yes |
GOOGLE_CLIENT_ID |
Google OAuth client ID | - | Yes |
GOOGLE_CLIENT_SECRET |
Google OAuth secret | - | Yes |
GOOGLE_REDIRECT_URL |
OAuth redirect URL | - | Yes |
S3_BUCKET_NAME |
AWS S3 bucket name | - | Yes |
AWS_REGION |
AWS region | us-east-1 |
No |
SMTP_HOST |
SMTP server host | - | Yes |
SMTP_PORT |
SMTP server port | 587 |
No |
SMTP_USER |
SMTP username | - | Yes |
SMTP_PASS |
SMTP password | - | Yes |
The application uses PostgreSQL with the following optimizations:
- Connection pooling for better performance
- Automatic migrations on startup
- Indexed columns for fast queries
- Foreign key constraints for data integrity
- Triggers for automatic timestamp updates
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down# Use production compose file
docker-compose -f docker-compose-production.yml up -dPOST /api/v1/users/register
Content-Type: application/json
{
"user_name": "johndoe",
"email": "john@example.com",
"password": "securepassword"
}POST /api/v1/users/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "securepassword"
}GET /api/v1/auth/google/login
GET /api/v1/auth/google/callbackPOST /api/v1/auctions
Authorization: Bearer <jwt_token>
Content-Type: multipart/form-data
{
"title": "Vintage Guitar",
"description": "Beautiful 1960s acoustic guitar",
"starting_price": 500.00,
"start_date": "2024-12-01T10:00:00Z",
"end_date": "2024-12-07T22:00:00Z",
"categories": [1, 2],
"image": <file>
}GET /api/v1/auctions?category=1&status=ACTIVE&page=1&limit=20GET /api/v1/auctions/{id}POST /api/v1/auctions/{id}/bids
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"amount": 550.00
}GET /api/v1/auctions/{id}/bidsGET /api/v1/users/{id}
Authorization: Bearer <jwt_token>GET /api/v1/users/{id}/stats
Authorization: Bearer <jwt_token>GET /api/v1/categoriesPOST /api/v1/categories
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "Electronics"
}Connect to real-time auction updates:
const ws = new WebSocket('ws://localhost:8080/api/v1/auctions/{auction_id}/ws');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('New bid:', data);
};# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package
go test ./internal/service/auction/...# Run integration tests
go test -tags=integration ./...# Install hey (HTTP load testing tool)
go install github.com/rakyll/hey@latest
# Test auction endpoint
hey -n 1000 -c 50 http://localhost:8080/api/v1/auctions- Set up RDS PostgreSQL
- Configure ElastiCache Redis
- Set up S3 bucket for file storage
- Deploy using ECS or EKS
# Multi-stage build for production
FROM golang:1.24.2-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o main cmd/server/main.go
FROM alpine:3.18
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/main .
CMD ["./main"]- Structured Logging: Using Zap logger for performance
- Health Checks: Built-in health check endpoints
- Metrics: Prometheus-compatible metrics
- Tracing: OpenTelemetry support
- Follow Go best practices and conventions
- Use
gofmtfor code formatting - Use
golintfor linting - Write meaningful tests with good coverage
# Create new migration
goose -dir ./internal/migrations create migration_name sql
# Apply migrations
goose -dir ./internal/migrations postgres "connection_string" up
# Rollback migration
goose -dir ./internal/migrations postgres "connection_string" down- Service Layer: Implement business logic in
internal/service/ - Store Layer: Add data access methods in
internal/store/ - Handler Layer: Create HTTP handlers in
internal/handler/ - Types: Define data structures in
pkg/types/ - Tests: Write comprehensive tests
We love contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make changes and add tests
- Ensure tests pass:
go test ./... - Commit changes:
git commit -am 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
Found a bug? Please open an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- System information (Go version, OS, etc.)
This project is licensed under the MIT License - see the LICENSE file for details.