A modern, secure, and scalable rewrite of the ControlMe platform in Go, providing a clean modern API for applications.
- β Modern API: RESTful API with JWT authentication
- β RFC 7807 Error Handling: Standardized, developer-friendly error responses
- β Real-time Communication: WebSocket support for instant messaging
- β Secure: Modern authentication, bcrypt password hashing, HTTPS support
- β Interactive Documentation: Swagger/OpenAPI documentation
- β Scalable: Docker-based deployment
- β Cross-platform: Runs on Linux, macOS, and Windows
- β Well-tested: Comprehensive test coverage
The API now provides structured, consistent error responses following the RFC 7807 Problem Details standard:
{
"type": "validation_error",
"title": "Validation Failed",
"status": 422,
"detail": "One or more fields failed validation",
"help": "Please check the field requirements in the API documentation",
"errors": [
{
"field": "username",
"message": "Username must be at least 3 characters long",
"code": "MIN_LENGTH"
}
]
}Benefits for client developers:
- π― Consistent structure across all error responses
- π οΈ Machine-readable error types and codes
- π Detailed validation errors with field-specific information
- π Actionable guidance for resolving issues
- π Complete documentation with examples
controlme-go/
βββ cmd/
β βββ server/ # Main application entry point
β βββ tools/ # Development and maintenance tools
βββ internal/
β βββ api/
β β βββ handlers/ # HTTP request handlers
β β βββ responses/ # RFC 7807 response types
β β βββ routes/ # Route definitions
β βββ auth/ # Authentication logic
β βββ config/ # Configuration management
β βββ database/ # Database connection and setup
β βββ middleware/ # HTTP middleware
β βββ models/ # Data models (GORM)
β βββ services/ # Business logic layer
β βββ websocket/ # WebSocket hub and handlers
βββ configs/ # Configuration files
βββ scripts/ # Development and deployment scripts
βββ docker/ # Docker configuration
βββ docs/ # Documentation
- Go 1.21+
- Docker & Docker Compose
- Make (optional, but recommended)
-
Clone the repository
git clone <repository-url> cd controlme-go
-
Set up the development environment
make setup
-
Start the development server
make dev
The server will be available at http://localhost:3080
-
Start Docker services
./scripts/docker.sh up
-
Install dependencies
go mod tidy
-
Build and run
go build -o bin/server cmd/server/main.go ./bin/server
make help # Show all available commands
make setup # Set up development environment
make dev # Start development server with hot reload
make build # Build the server binary
make test # Run all tests
make lint # Run code linter
make fmt # Format code
make clean # Clean build artifacts
make docker-up # Start Docker services (includes Swagger UI)
make docker-down # Stop Docker services
make seed # Run database seed data
make swagger # Generate Swagger documentation
make swagger-serve # Generate docs and start serverThe Docker Compose setup includes:
- PostgreSQL Database (port 5432)
- Go Server with hot reload (port 3080)
- Swagger UI for API documentation (port 3080)
- Nginx reverse proxy for production (port 80/443)
- API Server: http://localhost:3080
- Built-in Swagger: http://localhost:3080/swagger/index.html
- Dedicated Swagger UI: http://localhost:3080
- Health Check: http://localhost:3080/health
Copy the example configuration and modify as needed:
cp configs/config.example.yaml configs/config.yamlKey configuration options:
- Database connection settings
- Server port and host
- JWT secret keys
- CORS settings
- Log levels
Run the full test suite:
make testTest specific packages:
go test ./internal/auth/...
go test ./internal/api/handlers/...Base URL: http://localhost:3080/api/v1
All endpoints return RFC 7807 compliant error responses with structured error details and optional developer help. See docs/ERROR_RESPONSE_REFERENCE.md for complete error handling documentation.
POST /auth/login- User authenticationPOST /auth/register- User registration
GET /commands/pending- Get pending commands for userPOST /commands/complete- Mark command as completed
GET /users- Get all usersGET /users/{id}- Get user by ID
GET /health- Server health check
WS /ws/client- Universal WebSocket connection (all clients)
ControlApp is designed to support rich 3rd party clients! Whether you're building a desktop app, mobile client, web interface, or IoT integration, we provide comprehensive resources:
- docs/CLIENT_DEVELOPMENT_GUIDE.md - Complete guide for building 3rd party clients
- docs/STANDARD_COMMANDS.md - Official command set that all clients should support
- docs/WEBSOCKET_IMPLEMENTATION.md - WebSocket API implementation details
- JavaScript/Web - Full-featured browser client with all standard commands
- Python - Async client library perfect for automation and scripting
- Go - High-performance client for system integration
- Examples - Platform-specific implementations (React Native, Flutter, Desktop)
// Minimal client in just a few lines
const client = new WebSocket('ws://localhost:3080/ws/client?token=your-jwt');
client.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === 'command') {
executeCommand(message.payload);
}
};For comprehensive documentation including API references, implementation guides, and examples:
- docs/ - Complete documentation directory
- docs/API-REFERENCE.md - Complete REST + WebSocket API documentation
- docs/ERROR_RESPONSE_REFERENCE.md - RFC 7807 error handling guide
- Swagger UI - Interactive API documentation
- Language: Go 1.21+
- Web Framework: Gin
- Database: PostgreSQL with GORM ORM
- Authentication: JWT with bcrypt password hashing
- Real-time: WebSocket with message hub
- Deployment: Docker Compose
- Modern API Layer: RESTful API with proper HTTP methods and status codes
- Authentication Service: JWT-based authentication with bcrypt password hashing
- WebSocket Hub: Real-time message broadcasting and client management
- Command Service: Business logic for command creation, assignment, and completion
- User Service: User management, authentication, and profile handling
-
Production deployment
docker-compose -f docker-compose.prod.yml up -d
-
Environment variables
export DB_HOST=your-db-host export DB_PASSWORD=your-secure-password export JWT_SECRET=your-jwt-secret
-
Build for production
CGO_ENABLED=0 GOOS=linux go build -o controlme-server cmd/server/main.go
-
Run with environment configuration
export ENVIRONMENT=production ./controlme-server
go test ./internal/...go test -tags=integration ./...# TODO: Add load testing instructionsThe cmd/tools/ directory contains helpful development and testing utilities:
Comprehensive API validation tool that tests the server against its documentation:
# Run the integration test
go run cmd/tools/integration-test/main.goWhat it tests:
- β
REST API endpoints (
/auth/register,/auth/login) - β JWT token generation and validation
- β WebSocket connections and authentication
- β RFC 7807 error response format
- β All documented authentication methods
Use cases:
- π Validate API changes don't break existing functionality
- π Ensure documentation stays accurate with implementation
- π CI/CD pipeline integration for automated testing
- π Debug authentication and WebSocket issues
The tool creates test users (test1, test2) and runs a full integration test suite, providing detailed output and appropriate exit codes for automated environments.
test-client/- Interactive WebSocket client for manual testingtest-websocket-auth/- WebSocket authentication testing utility
See individual tool README files for detailed usage instructions.
curl http://localhost:3080/health- Application metrics available at
/metrics(when enabled) - Docker container metrics via
docker stats
- Structured JSON logging via logrus
- Log levels: debug, info, warn, error
- Configurable log output (stdout, file)
- Password Security: bcrypt hashing with salt
- JWT Authentication: Secure token-based authentication
- HTTPS Support: TLS/SSL configuration available
- CORS: Configurable cross-origin resource sharing
- Rate Limiting: Built-in request rate limiting
- Input Validation: Comprehensive input sanitization
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Run linter (
make lint) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow standard Go conventions
- Use
gofmtfor formatting - Write comprehensive tests
- Document public APIs
- Follow semantic commit messages
This project is for educational and research purposes only.
- Documentation: Check this README and inline code documentation
- Issues: Open an issue on GitHub
- JWT-based authentication
- Bcrypt password hashing
- RESTful API design
- WebSocket communication
- Enhanced security features
- Improved error handling
- Comprehensive testing
- Performance optimization
- Microservices architecture
- Advanced monitoring
- Load balancing
- Multi-tenant support
- API versioning strategy
Last Updated: July 2025
Version: 1.0.0
Go Version: 1.21+