Automated Action 350b445f45 Implement task management tool with FastAPI and SQLite
- Setup project structure and FastAPI application
- Create SQLite database with SQLAlchemy
- Implement user authentication with JWT
- Create task and user models
- Add CRUD operations for tasks and users
- Configure Alembic for database migrations
- Implement API endpoints for task management
- Add error handling and validation
- Configure CORS middleware
- Create health check endpoint
- Add comprehensive documentation
2025-06-12 12:02:37 +00:00

2.7 KiB

Task Management Tool

A robust task management API built with FastAPI and SQLite.

Features

  • User authentication with JWT
  • Task management (create, read, update, delete)
  • Task priority and status tracking
  • Role-based access control (admin/regular users)
  • Error handling and validation
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic

Requirements

  • Python 3.8+
  • FastAPI
  • SQLAlchemy
  • Alembic
  • Pydantic
  • Python-jose
  • Passlib
  • Email-validator
  • Uvicorn

Installation

  1. Clone the repository
git clone <repository-url>
cd taskmanagementtool
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables (or use default values for development)
# JWT Secret Key
export SECRET_KEY="your-secret-key-here"

# JWT Algorithm
export ALGORITHM="HS256"

# JWT Token Expiration (minutes)
export ACCESS_TOKEN_EXPIRE_MINUTES="11520"  # 8 days
  1. Run database migrations
alembic upgrade head
  1. Start the server
uvicorn main:app --reload

The API will be available at http://localhost:8000

API Documentation

API documentation is automatically generated and available at:

API Endpoints

Authentication

  • POST /api/v1/auth/login - Get access token
  • POST /api/v1/auth/test-token - Test if token is valid

Users

  • GET /api/v1/users/ - List all users (admin only)
  • POST /api/v1/users/ - Create a new user
  • GET /api/v1/users/me - Get current user information
  • PUT /api/v1/users/me - Update current user information
  • GET /api/v1/users/{user_id} - Get user by ID

Tasks

  • GET /api/v1/tasks/ - List tasks (admins see all, users see their own)
  • POST /api/v1/tasks/ - Create a new task
  • GET /api/v1/tasks/{id} - Get task by ID
  • PUT /api/v1/tasks/{id} - Update task
  • DELETE /api/v1/tasks/{id} - Delete task

Health

  • GET /api/v1/health - Check if the service is running

Task Model

Tasks have the following attributes:

  • id: Unique identifier
  • title: Task title
  • description: Detailed description
  • priority: Priority level (LOW, MEDIUM, HIGH)
  • status: Current status (TODO, IN_PROGRESS, DONE)
  • due_date: Optional due date
  • user_id: Owner of the task
  • created_at: Creation timestamp
  • updated_at: Last update timestamp

Environment Variables

Variable Description Default
SECRET_KEY JWT Secret Key "YOUR_SECRET_KEY_HERE"
ALGORITHM JWT Algorithm "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES JWT Token Expiration (minutes) 11520 (8 days)

License

This project is licensed under the MIT License.