A demonstration of Claude Code best practices - A RESTful API for task management with SQLite persistence and MCP integration.
- RESTful API - Complete CRUD operations for task management
- SQLite Database - Persistent data storage with automatic migrations
- MCP Integration - Model Context Protocol server for AI assistant integration
- Validation - Input validation using Zod schemas
- Error Handling - Centralized error handling with custom AppError class
- Logging - Request logging with performance monitoring
- Configuration - Environment-based configuration management
# Clone the repository
git clone <repository-url>
cd task-manager-api
# Install dependencies
npm install
# Initialize database (automatically runs on first start)
npm startCreate a .env file for custom configuration:
PORT=3000
NODE_ENV=development
DATABASE_PATH=./data/tasks.db
LOG_LEVEL=info# Start REST API server
npm start
# Start in development mode (auto-reload)
npm run dev
# Start MCP server
npm run start:mcp
# Start both servers
npm run start:bothhttp://localhost:3000
GET /healthGET /api| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks |
List all tasks with optional filters |
| GET | /api/tasks/:id |
Get a specific task |
| POST | /api/tasks |
Create a new task |
| PATCH | /api/tasks/:id |
Update task fields |
| PUT | /api/tasks/:id |
Replace entire task |
| DELETE | /api/tasks/:id |
Delete a task |
| GET | /api/tasks/stats |
Get task statistics |
| POST | /api/tasks/batch |
Create multiple tasks |
| POST | /api/tasks/archive |
Archive old completed tasks |
curl -X POST http://localhost:3000/api/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project",
"description": "Finish the task manager API",
"priority": "high",
"status": "in_progress",
"tags": ["development", "api"]
}'curl "http://localhost:3000/api/tasks?status=pending&priority=high"curl -X POST http://localhost:3000/api/tasks/batch \
-H "Content-Type: application/json" \
-d '{
"tasks": [
{"title": "Task 1", "priority": "high"},
{"title": "Task 2", "priority": "medium"}
]
}'interface Task {
id: string; // UUID
title: string; // Required, max 200 chars
description?: string;// Optional, max 2000 chars
status: 'pending' | 'in_progress' | 'completed' | 'archived';
priority: 'low' | 'medium' | 'high' | 'urgent';
assignee?: string; // Optional
dueDate?: string; // ISO 8601 datetime
tags: string[]; // Array of tags
createdAt: string; // ISO 8601 datetime
updatedAt: string; // ISO 8601 datetime
}src/
βββ config/ # Configuration management
βββ core/ # Core business logic
β βββ database/ # Database connection & migrations
β βββ errors/ # Custom error classes
β βββ repositories/# Data access layer
β βββ schemas/ # Validation schemas
βββ middleware/ # Express middleware
βββ models/ # Data models
βββ routes/ # API routes
βββ services/ # Business logic
βββ index.js # Application entry point
# Run tests
npm test
# Run linting
npm run lint
# Format code
npm run format
# Type checking
npm run typecheck# Reset database
npm run db:reset
# Test MCP server
npm run mcp:test
# Pre-commit checks
npm run pre-commitThe project includes a Model Context Protocol (MCP) server that allows AI assistants to interact with the task management system.
create_task- Create a new tasklist_tasks- List tasks with filtersget_task- Get task by IDupdate_task- Update existing taskdelete_task- Delete a taskget_task_stats- Get task statistics
Add to your Claude Desktop configuration:
{
"mcpServers": {
"task-manager": {
"command": "node",
"args": ["/path/to/task-manager-api/src/mcp-server.js"]
}
}
}NODE_ENV=production
PORT=3000
DATABASE_PATH=/var/data/tasks.db
LOG_LEVEL=error
CORS_ORIGIN=https://yourdomain.com# Backup database
cp data/tasks.db backups/tasks-$(date +%Y%m%d).db
# Restore database
cp backups/tasks-20240101.db data/tasks.dbMIT
- Fork the repository
- Create your 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
For issues and questions, please open an issue on GitHub.
Built with β€οΈ using Claude Code best practices