A comprehensive backend API for managing sports tournaments, matches, and communities with support for cricket and football.
Khelogames is a Go-based backend API that provides a complete sports management platform. It supports tournament management, live match scoring, player profiles, team management, and community features for both cricket and football sports.
- Cricket: Complete match management with batting/bowling scorecards, player statistics, and live scoring
- Football: Match management with incidents, lineups, substitutions, and statistics
- Create and manage tournaments
- Group stages and knockout formats
- Automatic standings calculation
- Team and player statistics tracking
- JWT-based authentication
- Google OAuth integration
- User profiles and player management
- Community membership system
- WebSocket-based messaging system
- Real-time match updates
- Live chat for communities
- RabbitMQ message queue integration
- File upload system with Tus protocol
- Profile picture management
- Match media uploads
- Cloud storage integration
- Language: Go 1.21.2
- Framework: Gin-gonic (HTTP router)
- Database: PostgreSQL with pgx driver
- Authentication: JWT tokens
- Real-time: WebSocket with Gorilla
- Message Queue: RabbitMQ
- File Upload: Tus protocol
- SMS: Twilio
- OAuth: Google OAuth2
- Go 1.21.2 or higher
- PostgreSQL 12+
- RabbitMQ 3.8+
- Redis (optional, for caching)
git clone https://github.com/your-org/khelogames.git
cd khelogamesgo mod download# Create database
createdb khelogames
# Run migrations (if available)
# Or use the provided SQL files in database/Create app.env file:
DB_DRIVER=postgres
DB_SOURCE=postgresql://username:password@localhost:5432/khelogames?sslmode=disable
SERVER_ADDRESS=0.0.0.0:8080
ACCESS_TOKEN_DURATION=15m
REFRESH_TOKEN_DURATION=168h
TOKEN_SYMMETRIC_KEY=your-32-character-secret-key
RABBIT_SOURCE=amqp://guest:guest@localhost:5672/# Start PostgreSQL
pg_ctl -D /usr/local/var/postgres start
# Start RabbitMQ
rabbitmq-server
# Run the application
go run main.gokhelogames/
βββ api/ # API endpoints
β βββ auth/ # Authentication endpoints
β βββ handlers/ # General handlers
β βββ sports/ # Sports-specific APIs
β βββ tournaments/ # Tournament management
β βββ teams/ # Team management
β βββ players/ # Player profiles
β βββ messenger/ # Real-time messaging
βββ database/ # Database models and queries
βββ util/ # Utility functions
βββ logger/ # Logging configuration
βββ token/ # JWT token management
βββ uploads/ # File upload handling
-
Authentication System
- JWT token-based authentication
- Google OAuth2 integration
- Session management
- Password reset via SMS
-
Sports Engine
- Cricket: Batting/bowling scorecards, player stats
- Football: Incidents, lineups, substitutions, statistics
- Live match updates
- Match result calculation
-
Tournament System
- Tournament creation and management
- Group stages and knockout formats
- Automatic standings calculation
- Team/player statistics
-
Community Features
- Community creation and management
- Thread-based discussions
- Real-time messaging
- File sharing
POST /api/v1/auth/signup- User registrationPOST /api/v1/auth/signin- User loginPOST /api/v1/auth/google- Google OAuthPOST /api/v1/auth/refresh- Token refresh
-
Cricket
GET /api/v1/cricket/matches- List cricket matchesPOST /api/v1/cricket/matches- Create cricket matchPUT /api/v1/cricket/matches/:id/score- Update match scoreGET /api/v1/cricket/players/:id/stats- Player statistics
-
Football
GET /api/v1/football/matches- List football matchesPOST /api/v1/football/matches- Create football matchPUT /api/v1/football/matches/:id/incidents- Add match incidents
GET /api/v1/tournaments- List tournamentsPOST /api/v1/tournaments- Create tournamentGET /api/v1/tournaments/:id/standing- Tournament standingsGET /api/v1/tournaments/:id/matches- Tournament matches
GET /api/v1/teams- List teamsPOST /api/v1/teams- Create teamGET /api/v1/players- List playersPOST /api/v1/players- Create player profile
GET /api/v1/communities- List communitiesPOST /api/v1/communities- Create communityPOST /api/v1/communities/:id/join- Join communityGET /api/v1/communities/:id/threads- Community threads
go test ./...go test -tags=integration ./...users- User accountsplayers- Player profilesteams- Team informationtournaments- Tournament detailsmatches- Match recordscricket_scores- Cricket match scoresfootball_scores- Football match scorescommunities- Community informationthreads- Discussion threads
- JWT token-based authentication
- Password hashing with bcrypt
- Rate limiting
- CORS configuration
- Input validation and sanitization
- SQL injection prevention
# Build the Docker image
docker build -t khelogames .
# Run with Docker Compose
docker-compose up -d- Set up PostgreSQL with proper configuration
- Configure environment variables
- Set up SSL certificates
- Configure reverse proxy (nginx)
- Set up monitoring and logging
- Structured logging with Logrus
- Request/response logging
- Error tracking and alerting
- Performance monitoring
- Health check endpoints
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@khelogames.com or join our community Discord server.