A RESTful API server for managing tasks in the Solo application built with Go, Gin, GORM, and SQLite.
- RESTful API: Clean REST endpoints for task management
- Database: SQLite with GORM ORM (CGO-free)
- Configuration: YAML-based configuration with environment variable substitution
- Logging: Structured logging with Zap
- CLI: Cobra-based command line interface
- CORS: Built-in CORS middleware
- Validation: Request validation and error handling
- Framework: Gin (HTTP web framework)
- Database: SQLite with GORM
- Logging: Zap
- CLI: Cobra
- Configuration: YAML + environment variables
- UUID: Google UUID for task IDs
api/
├── cmd/
│ └── server/
│ └── main.go # Main entry point
├── internal/
│ ├── config/
│ │ └── config.go # Configuration management
│ ├── database/
│ │ └── database.go # Database setup and models
│ ├── handler/
│ │ └── task.go # HTTP handlers
│ ├── model/
│ │ └── task.go # Data models and DTOs
│ └── service/
│ └── task.go # Business logic
├── pkg/
│ ├── logger/
│ │ └── logger.go # Logging setup
│ └── utils/
└── config.yaml # Configuration file
Method | Endpoint | Description |
---|---|---|
GET | /api/tasks |
Get all tasks |
GET | /api/tasks/:id |
Get a specific task |
POST | /api/tasks |
Create a new task |
PUT | /api/tasks/:id |
Update a task |
DELETE | /api/tasks/:id |
Delete a task |
Method | Endpoint | Description |
---|---|---|
GET | /health |
Health check endpoint |
{
"id": "uuid",
"title": "string",
"description": "string",
"status": "string",
"assignee": "string",
"tags": ["string"],
"created_at": "datetime",
"updated_at": "datetime"
}
todo
- To Doinprogress
- In Progressinreview
- In Reviewdone
- Donecancelled
- Cancelled
-
Copy the environment configuration:
cp .env.example .env
-
Update the configuration as needed in
config.yaml
or set environment variables -
Build the application:
go build -o bin/server ./cmd/server
-
Run the server:
./bin/server
The application uses YAML configuration with environment variable substitution. Configuration can be provided via:
config.yaml
file- Environment variables
.env
file
# Server Configuration
SERVER_HOST=localhost
SERVER_PORT=8080
# Database Configuration
DATABASE_TYPE=sqlite
DATABASE_DSN=./tasks.db
# Logger Configuration
LOGGER_LEVEL=info
LOGGER_FORMAT=console
LOGGER_OUTPUT=stdout
# With default config
./bin/server
# With custom config
./bin/server -c /path/to/config.yaml
# Help
./bin/server --help
# Version
./bin/server version
curl -X POST http://localhost:8080/api/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project",
"description": "Finish the API implementation",
"status": "todo",
"assignee": "john.doe",
"tags": ["backend", "api"]
}'
curl http://localhost:8080/api/tasks
curl http://localhost:8080/api/tasks/{task-id}
curl -X PUT http://localhost:8080/api/tasks/{task-id} \
-H "Content-Type: application/json" \
-d '{
"status": "inprogress"
}'
curl -X DELETE http://localhost:8080/api/tasks/{task-id}
The API returns consistent error responses:
{
"error": "Error type",
"message": "Detailed error message"
}
The application uses structured logging with Zap. Log levels and formats can be configured:
- Levels: debug, info, warn, error
- Formats: console, json
- Output: stdout, file
The application uses SQLite with GORM ORM. The database file is created automatically on first run and includes:
- Auto-migration of task schema
- UUID primary keys
- Timestamps for created_at and updated_at
- JSON storage for tags array
- Follow the existing code structure and patterns
- Keep handlers thin - business logic should be in the service layer
- Use structured logging for debugging
- Validate all inputs in handlers
- Follow RESTful conventions for API endpoints