# Task Manager API A comprehensive task management API built with FastAPI and SQLite. This API provides a full-featured backend for task management applications, including user authentication, task CRUD operations, and task assignment functionality. ## Features - **User Management** - User registration and authentication - JWT-based authentication - User profile management - **Task Management** - Create, read, update, and delete tasks - Task filtering and search - Task status tracking (todo, in_progress, completed, cancelled) - Task priority levels (low, medium, high, urgent) - **Task Assignment** - Assign tasks to multiple users - View tasks assigned to you - Task ownership and permission controls - **API Documentation** - Interactive API documentation with Swagger UI and ReDoc - Detailed endpoint descriptions ## Technical Stack - **Framework**: FastAPI - **Database**: SQLite with SQLAlchemy ORM - **Migration Tool**: Alembic - **Authentication**: JWT with OAuth2 - **Password Hashing**: Bcrypt ## Project Structure ``` taskmanagerapi/ ├── alembic.ini # Alembic configuration ├── main.py # Application entry point ├── migrations/ # Database migrations │ ├── env.py │ ├── README │ ├── script.py.mako │ └── versions/ # Migration versions │ └── 001_initial_tables.py ├── app/ # Application package │ ├── api/ # API endpoints │ │ └── v1/ # API version 1 │ │ ├── api.py # API router │ │ └── endpoints/ # API endpoint modules │ │ ├── auth.py │ │ ├── health.py │ │ ├── task_assignments.py │ │ ├── tasks.py │ │ └── users.py │ ├── core/ # Core modules │ │ ├── config.py # Application configuration │ │ ├── deps.py # Dependencies │ │ ├── docs.py # API documentation │ │ └── security.py # Security utilities │ ├── db/ # Database │ │ ├── base.py # Base models │ │ ├── base_class.py # Base class for models │ │ ├── base_models.py # Import all models │ │ └── session.py # Database session │ ├── models/ # SQLAlchemy models │ │ ├── task.py │ │ └── user.py │ ├── schemas/ # Pydantic schemas │ │ ├── task.py │ │ ├── token.py │ │ └── user.py │ ├── services/ # Business logic │ └── utils/ # Utility functions └── requirements.txt # Project dependencies ``` ## Getting Started ### Prerequisites - Python 3.8+ - pip (Python package installer) ### Installation 1. Clone the repository: ```bash git clone cd taskmanagerapi ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Set environment variables: ```bash # For production use, set a secure secret key export SECRET_KEY="your-secure-secret-key" # Optional: Set the JWT token expiration time in minutes export ACCESS_TOKEN_EXPIRE_MINUTES=30 ``` 4. Run database migrations: ```bash alembic upgrade head ``` 5. Start the application: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` 6. Access the API documentation: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ### Environment Variables | Variable | Description | Default | |----------|-------------|---------| | SECRET_KEY | JWT secret key | "your-super-secret-key-for-development-only" | | ACCESS_TOKEN_EXPIRE_MINUTES | JWT token expiration in minutes | 30 | ## API Endpoints ### Authentication - **POST /api/v1/auth/login** - Login and get access token ### Users - **POST /api/v1/users** - Register a new user - **GET /api/v1/users/me** - Get current user info - **PUT /api/v1/users/me** - Update current user - **GET /api/v1/users/{user_id}** - Get user by ID (admin or self only) - **PUT /api/v1/users/{user_id}** - Update user by ID (admin only) ### Tasks - **GET /api/v1/tasks** - List tasks (owned or assigned to current user) - **POST /api/v1/tasks** - Create a new task - **GET /api/v1/tasks/{task_id}** - Get task by ID - **PUT /api/v1/tasks/{task_id}** - Update task by ID - **DELETE /api/v1/tasks/{task_id}** - Delete task by ID (soft delete) ### Task Assignments - **GET /api/v1/tasks/{task_id}/assignees** - Get task assignees - **POST /api/v1/tasks/{task_id}/assignees/{user_id}** - Assign user to task - **DELETE /api/v1/tasks/{task_id}/assignees/{user_id}** - Remove user from task ### Health - **GET /api/v1/health** - API health check - **GET /health** - General health check ## License This project is licensed under the MIT License - see the LICENSE file for details. ## Contributing Contributions are welcome! Please feel free to submit a Pull Request.