This is a RESTful Todo application built using FastAPI. The project is organized using the MVC (Model-View-Controller) architecture. The application allows users to create, read, update, and delete tasks (todos) in a database, and it supports detailed task management, including descriptions, deadlines, and tracking of estimated and actual work hours. Based on this project https://github.com/ktechhub/fastapi_todo
-
CRUD Operations:
- Create new tasks.
- Read existing tasks (single or multiple).
- Update task details.
- Delete tasks.
-
Task Management:
- Track task names, descriptions, deadlines (due dates), estimated hours, actual hours, and completion status.
- Automatically tracks task creation and update timestamps.
-
Database Integration:
- Uses SQLAlchemy for ORM.
- Alembic for database migrations.
.
├── alembic/ # Alembic migration files
├── app/ # Application code
│ ├── __init__.py
│ ├── api/ # API routes (Controllers)
│ │ ├── __init__.py
│ │ └── v1/ # Versioned API endpoints
│ │ ├── __init__.py
│ │ ├── todos/ # Todo-related API endpoints
│ │ │ ├── create.py
│ │ │ ├── read.py
│ │ │ ├── update.py
│ │ │ └── delete.py
│ ├── core/ # Core settings and configurations
│ │ ├── __init__.py
│ │ └── config.py
│ ├── database/ # Database connection setup
│ │ ├── __init__.py
│ │ └── base_class.py # Base class for SQLAlchemy models
│ ├── main.py # Application entry point
│ ├── models/ # Database models (Models)
│ │ ├── __init__.py
│ │ └── todo.py # Todo model definition
│ ├── schemas/ # Pydantic schemas for request/response validation
│ │ ├── __init__.py
│ │ └── todo.py # Todo-related schemas
│ └── tests/ # Unit tests
├── requirements.txt # Python dependencies
├── alembic.ini # Alembic configuration file
└── README.md # Project documentation
The application uses a Todo table in the database with the following schema:
| Column | Type | Description |
|---|---|---|
id |
Integer | Primary key |
task_name |
String(120) | Title or name of the task |
description |
String(255) | Description of the task |
due_date |
DateTime | Deadline for the task |
estimated_hours |
Integer | Estimated time to complete the task (hours) |
actual_hours |
Integer | Actual time spent on the task (hours) |
is_completed |
Boolean | Status of the task (completed or not) |
created_at |
DateTime | Timestamp of task creation |
updated_at |
DateTime | Timestamp of last task update |
- Python 3.8+
- MySQL or any other supported database
pipfor dependency management
-
Clone the repository:
git clone https://github.com/Lgithubprogram/todo--your--job.git cd todo--your--job -
Create and activate a virtual environment:
conda create -n your_env_name python = 3.12 conda activate your_env_name conda activate your_env_name
-
Install dependencies:
pip install -r requirements.txt
-
Configure your database connection in
app/core/config.py.
-
Initialize the Alembic migrations:
alembic init alembic
-
Autogenerate the initial migration:
alembic revision --autogenerate -m "Initial migration" -
Apply the migrations:
alembic upgrade head
Start the FastAPI development server:
uvicorn app.main:app --reloadThe application will be available at http://127.0.0.1:8000.
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
-
Database Errors:
- Ensure the database is running and the connection string in
app/core/config.pyis correct. - If Alembic reports missing revisions, clear the
alembic_versiontable and recreate the migrations.
- Ensure the database is running and the connection string in
-
Dependency Issues:
- Run
pip install email-validatorif prompted.
- Run
Feel free to fork this repository and submit pull requests. Contributions are welcome!