中文版本 | English
A RESTful API server for the Todo for AI task management system, built with Flask and designed specifically for AI assistant integration.
🚀 Try it now: Visit https://todo4ai.org/ to experience our product!
- 🔐 Multi-Authentication: JWT tokens and API tokens support
- 🌐 OAuth Integration: Google and GitHub OAuth login
- 📊 Project Management: Complete project lifecycle management
- ✅ Task Management: Advanced task tracking with status, priority, and assignments
- 🤖 AI Integration: MCP (Model Context Protocol) support for AI assistants
- 📝 Context Rules: Custom prompts and context management
- 🔒 Security: Token encryption, CORS protection, and secure session management
- 📈 Dashboard: Real-time statistics and analytics
- 🔍 Search & Filter: Advanced filtering and sorting capabilities
- 📱 RESTful API: Clean, well-documented REST endpoints
- Python 3.8+
- MySQL 5.7+ or 8.0+
- pip or conda
- Clone the repository
git clone https://github.com/todo-for-ai/todo-for-ai-api-server.git
cd todo-for-ai-api-server
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Configure environment variables
cp .env.example .env
# Edit .env with your configuration
- Initialize database
python migrations/create_database.py
- Run the server
python app.py
The API server will be available at http://localhost:50110
Create a .env
file with the following variables:
# Database Configuration
DATABASE_URL=mysql+pymysql://username:password@localhost:3306/todo_for_ai
# Flask Configuration
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key-here
FLASK_ENV=development
# OAuth Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
# Server Configuration
HOST=127.0.0.1
PORT=50110
# CORS Configuration
CORS_ORIGINS=http://localhost:5173,http://localhost:50111
# Logging
LOG_LEVEL=INFO
LOG_FILE=app.log
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:50110/todo-for-ai/api/v1/auth/google/callback
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL:
http://localhost:50110/todo-for-ai/api/v1/auth/github/callback
http://localhost:50110/todo-for-ai/api/v1
The API supports two authentication methods:
- JWT Tokens (for web applications)
- API Tokens (for AI assistants and integrations)
# Login to get JWT token
curl -X POST http://localhost:50110/todo-for-ai/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password"}'
# Use token in requests
curl -H "Authorization: Bearer <jwt_token>" \
http://localhost:50110/todo-for-ai/api/v1/projects
# Create API token
curl -X POST http://localhost:50110/todo-for-ai/api/v1/api-tokens \
-H "Authorization: Bearer <jwt_token>" \
-H "Content-Type: application/json" \
-d '{"name": "My API Token", "expires_in_days": 30}'
# Use API token in requests
curl -H "Authorization: Bearer <api_token>" \
http://localhost:50110/todo-for-ai/api/v1/projects
GET /health
GET /todo-for-ai/api/v1/health
POST /todo-for-ai/api/v1/auth/login
POST /todo-for-ai/api/v1/auth/logout
GET /todo-for-ai/api/v1/auth/google
GET /todo-for-ai/api/v1/auth/github
GET /todo-for-ai/api/v1/projects # List projects
POST /todo-for-ai/api/v1/projects # Create project
GET /todo-for-ai/api/v1/projects/{id} # Get project
PUT /todo-for-ai/api/v1/projects/{id} # Update project
DELETE /todo-for-ai/api/v1/projects/{id} # Delete project
GET /todo-for-ai/api/v1/tasks # List tasks
POST /todo-for-ai/api/v1/tasks # Create task
GET /todo-for-ai/api/v1/tasks/{id} # Get task
PUT /todo-for-ai/api/v1/tasks/{id} # Update task
DELETE /todo-for-ai/api/v1/tasks/{id} # Delete task
POST /todo-for-ai/api/v1/tasks/{id}/feedback # Submit feedback
GET /todo-for-ai/api/v1/mcp/projects/{name}/tasks # Get project tasks
GET /todo-for-ai/api/v1/mcp/tasks/{id} # Get task details
POST /todo-for-ai/api/v1/mcp/tasks # Create task
POST /todo-for-ai/api/v1/mcp/tasks/{id}/feedback # Submit feedback
todo-for-ai-api-server/
├── api/ # API endpoints
│ ├── auth.py # Authentication endpoints
│ ├── projects.py # Project management
│ ├── tasks.py # Task management
│ ├── mcp.py # MCP integration
│ ├── tokens.py # Token management
│ └── ...
├── core/ # Core modules
│ ├── config.py # Configuration
│ ├── auth.py # Authentication logic
│ ├── middleware.py # Middleware
│ └── ...
├── models/ # Database models
│ ├── user.py # User model
│ ├── project.py # Project model
│ ├── task.py # Task model
│ └── ...
├── migrations/ # Database migrations
├── app.py # Application entry point
├── requirements.txt # Python dependencies
└── README.md # This file
# Test health endpoint
curl http://localhost:50110/health
# Test API documentation
curl http://localhost:50110/todo-for-ai/api/v1/docs
# Test authentication
curl -X POST http://localhost:50110/todo-for-ai/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "password"}'
# Install test dependencies
pip install pytest pytest-flask pytest-cov
# Run tests
pytest
# Run with coverage
pytest --cov=api --cov=core --cov=models
# Build image
docker build -t todo-for-ai-api:latest .
# Run container
docker run -d --name todo-for-ai-api \
-p 50110:50110 \
-e DATABASE_URL="mysql+pymysql://user:pass@host:3306/db" \
-e SECRET_KEY="your-secret-key" \
todo-for-ai-api:latest
- Use production WSGI server
gunicorn -w 4 -b 0.0.0.0:50110 app:app
- Set production environment
export FLASK_ENV=production
export DATABASE_URL="mysql+pymysql://user:pass@host:3306/db"
- Configure reverse proxy (nginx recommended)
-
Database Connection Error
- Check DATABASE_URL format
- Ensure MySQL server is running
- Verify credentials and database exists
-
OAuth Authentication Failed
- Check OAuth client credentials
- Verify callback URLs match configuration
- Ensure OAuth apps are properly configured
-
CORS Issues
- Check CORS_ORIGINS environment variable
- Verify frontend URL is included in allowed origins
# View application logs
tail -f logs/todo_for_ai.log
# View Flask debug logs (development)
export FLASK_ENV=development
python app.py
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License
🌟 Ready to integrate? Visit https://todo4ai.org/ and start building with our API!