This is a Connect Four game implementation with both a server and client component written in Go. The project implements a full-featured online multiplayer Connect Four game with user authentication, game state management, and a console-based UI.
The project follows a clean architecture pattern with clear separation of concerns:
-
Client-Server Architecture:
- REST API server for game logic and state management
- Console-based client using the BubbleTea and LipGloss libraries for UI
-
Key Components:
- Database layer (MariaDB) for persisting users and games
- JWT authentication for secure API access
- RESTful API endpoints for game operations
- Terminal-based UI client
- API Framework: Uses Chi router for HTTP routing with well-organized endpoints
- Authentication: JWT-based authentication system
- Database: MariaDB with a simple schema for users and games
- Containerization: Docker Compose setup for easy deployment
- Game Logic: Clean implementation of Connect Four rules
- TUI Framework: Uses BubbleTea and LipGloss for terminal UI
- Authentication: Supports JWT authentication with optional credential storage
- API Integration: Well-structured API client for server communication
The project follows Go best practices with a clear organizational structure:
connectfour/
├── cmd/ # Application entry points
│ ├── client/ # Client application
│ └── server/ # Server application
├── internal/ # Internal application code
│ ├── client/ # Client implementation
│ ├── db/ # Database interfaces
│ ├── handlers/ # API handlers
│ ├── model/ # Domain models
│ └── service/ # Business logic services
├── sql/ # Database schemas
├── doc/ # Documentation
├── build/ # Build artifacts
└── compose.yaml # Docker Compose configuration
The database schema is simple but effective:
- User Table: Stores user information and authentication details
- Game Table: Stores game state, player information, and board state
The server exposes a RESTful API with these endpoints:
-
Authentication:
- POST
/login: User login - POST
/register: User registration
- POST
-
Game Management (JWT protected):
- GET
/games: List open games - GET
/games/my: List user's games - POST
/games: Create a new game - GET
/games/{key}: Get game state - POST
/games/{key}/join: Join an existing game - POST
/games/{key}/play: Make a move in a game
- GET
The project uses Docker Compose for deployment with:
- MariaDB container for the database
- Application container for the server
- Volume configuration for data persistence
- Secret management for database credentials
Claude AI says that the code appears to be of high quality :)
- Comprehensive test coverage
- Clean separation of concerns
- Good use of Go idioms and patterns
- Proper error handling
- Clear naming conventions
