Skip to content

vmrh21/taskmaster-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskMaster API

A simple yet realistic task management REST API built with Go. Manage tasks with priorities, statuses, and due dates.

Features

  • RESTful API - Clean HTTP endpoints for task management
  • Authentication - API key-based authentication
  • Task Management - Create, read, update, and delete tasks
  • Status Tracking - Track tasks through pending, in-progress, and completed states
  • Priority System - Assign priority levels (1-5) to tasks
  • Due Dates - Set and track task due dates
  • Filtering - Filter tasks by status
  • Health Checks - Monitor API health

Project Structure

taskmaster-api/
├── cmd/
│   └── server/          # Application entry point
├── internal/
│   ├── handlers/        # HTTP request handlers
│   ├── middleware/      # HTTP middleware (auth, logging)
│   ├── models/          # Domain models
│   └── storage/         # Data storage layer
├── pkg/
│   └── auth/           # Authentication utilities
└── go.mod

API Endpoints

Health Check

GET /health

Tasks

GET    /api/tasks           # List all tasks (supports ?status= filter)
POST   /api/tasks           # Create a new task
GET    /api/tasks/{id}      # Get a specific task
PUT    /api/tasks/{id}      # Update a task
DELETE /api/tasks/{id}      # Delete a task

Authentication

All /api/* endpoints require authentication using an API key:

X-API-Key: taskmaster-secret-key-123

Or using Bearer token:

Authorization: Bearer taskmaster-secret-key-123

Getting Started

Prerequisites

  • Go 1.21 or higher

Installation

# Clone the repository
git clone https://github.com/example/taskmaster-api
cd taskmaster-api

# Download dependencies
go mod download

# Run the server
go run cmd/server/main.go

The server will start on port 8080 by default. Set PORT environment variable to change it.

Running Tests

go test ./...

Run with coverage:

go test -cover ./...

Usage Examples

Create a Task

curl -X POST http://localhost:8080/api/tasks \
  -H "X-API-Key: taskmaster-secret-key-123" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Complete project documentation",
    "description": "Write comprehensive API documentation",
    "status": "pending",
    "priority": 4
  }'

List All Tasks

curl http://localhost:8080/api/tasks \
  -H "X-API-Key: taskmaster-secret-key-123"

Filter by Status

curl http://localhost:8080/api/tasks?status=in_progress \
  -H "X-API-Key: taskmaster-secret-key-123"

Get a Specific Task

curl http://localhost:8080/api/tasks/{task-id} \
  -H "X-API-Key: taskmaster-secret-key-123"

Update a Task

curl -X PUT http://localhost:8080/api/tasks/{task-id} \
  -H "X-API-Key: taskmaster-secret-key-123" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated title",
    "status": "completed",
    "priority": 5
  }'

Delete a Task

curl -X DELETE http://localhost:8080/api/tasks/{task-id} \
  -H "X-API-Key: taskmaster-secret-key-123"

Health Check

curl http://localhost:8080/health

Task Model

{
  "id": "uuid",
  "title": "Task title",
  "description": "Task description",
  "status": "pending|in_progress|completed",
  "priority": 1-5,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z",
  "due_date": "2024-12-31T00:00:00Z"
}

Configuration

  • PORT - Server port (default: 8080)
  • API key is currently hardcoded for demo purposes. In production, use environment variables.

Architecture

  • Handlers - Process HTTP requests and responses
  • Middleware - Handle cross-cutting concerns (logging, auth)
  • Models - Define domain entities and business logic
  • Storage - Manage data persistence (currently in-memory)

Future Enhancements

  • Database integration (PostgreSQL, MongoDB)
  • User authentication with JWT
  • Task assignment to users
  • Task comments and attachments
  • WebSocket support for real-time updates
  • Rate limiting
  • Comprehensive test coverage

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors