4.3 KiB
4.3 KiB
Task Manager API
A RESTful API for managing tasks and user accounts. Built with FastAPI, SQLAlchemy, and SQLite.
Features
- User Management: Registration, authentication, and profile management
- Task Management: Create, read, update, and delete tasks
- Task Status Tracking: Track tasks as todo, in-progress, or done
- Task Prioritization: Set task priorities as low, medium, or high
- API Documentation: Interactive API documentation with Swagger UI and ReDoc
Technology Stack
- FastAPI: High-performance web framework for building APIs
- SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM)
- SQLite: File-based database
- Alembic: Database migration tool
- Pydantic: Data validation and settings management
- JWT: JSON Web Tokens for authentication
- Uvicorn: ASGI server for running the application
Project Structure
task-manager-api/
├── app/
│ ├── api/
│ │ ├── endpoints/ # API endpoint modules
│ │ │ ├── health.py # Health check endpoint
│ │ │ ├── login.py # Login endpoints
│ │ │ ├── tasks.py # Task management endpoints
│ │ │ └── users.py # User management endpoints
│ │ ├── deps.py # Dependency injection functions
│ │ └── routes.py # API router configuration
│ ├── core/
│ │ ├── config.py # Application configuration
│ │ └── security.py # Security utilities
│ ├── crud/ # CRUD operations
│ │ ├── base.py # Base CRUD class
│ │ ├── crud_task.py # Task CRUD operations
│ │ └── crud_user.py # User CRUD operations
│ ├── db/
│ │ └── session.py # Database session setup
│ ├── models/ # SQLAlchemy models
│ │ ├── task.py # Task model
│ │ └── user.py # User model
│ └── schemas/ # Pydantic schemas
│ ├── task.py # Task schemas
│ ├── token.py # Token schemas
│ └── user.py # User schemas
├── migrations/ # Alembic migrations
│ ├── versions/ # Migration versions
│ ├── env.py # Migration environment
│ └── script.py.mako # Migration script template
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Project dependencies
Getting Started
Prerequisites
- Python 3.8+
- pip (Python package installer)
Installation
- Clone the repository
git clone <repository-url>
cd task-manager-api
- Install dependencies
pip install -r requirements.txt
- Set up environment variables
# Create a .env file in the project root
touch .env
# Add the following variables to the .env file
SECRET_KEY=your-secret-key
- Run database migrations
alembic upgrade head
- Start the server
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API Documentation
Once the server is running, you can access the API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Authentication
POST /api/v1/login/access-token
- Get JWT access token
Users
POST /api/v1/users/open
- Register a new userGET /api/v1/users/me
- Get current userPUT /api/v1/users/me
- Update current user
Tasks
GET /api/v1/tasks
- List all tasks for the current userPOST /api/v1/tasks
- Create a new taskGET /api/v1/tasks/{task_id}
- Get task by IDPUT /api/v1/tasks/{task_id}
- Update taskDELETE /api/v1/tasks/{task_id}
- Delete taskPOST /api/v1/tasks/{task_id}/complete
- Mark task as completePOST /api/v1/tasks/{task_id}/incomplete
- Mark task as incompletePOST /api/v1/tasks/{task_id}/status/{status}
- Update task status
Health Check
GET /health
- API health check
License
This project is licensed under the MIT License - see the LICENSE file for details.