This project is a simple FastAPI application that demonstrates CRUD (Create, Read, Update, Delete) operations using an SQLite database. It's perfect for beginners who want to learn how to build web APIs with FastAPI, Python, and SQLAlchemy.
- CRUD Operations: Easily create, read, update, and delete Todo items using FastAPI endpoints.
- SQLite Database: Lightweight and easy-to-set-up database solution.
- Interactive API Documentation: Automatically generated with FastAPI and accessible via
/docs. - Modular Structure: Clean and modular project structure using routers, models, and schemas.
- Python 3.7+
- FastAPI
- Uvicorn
- SQLAlchemy
- Pydantic
-
Clone the repository:
git clone https://github.com/lymanny/FastAPI-CRUD-Todo.git
-
Navigate into the project directory:
cd FastAPI-CRUD-Todo
Before running the project, it's best to use a virtual environment to manage dependencies.
-
Create a virtual environment:
python -m venv env
-
Activate the virtual environment:
-
On macOS/Linux:
source env/bin/activate -
On Windows:
.\env\Scripts\activate
-
-
Install the project dependencies:
pip install -r requirements.txt
-
Start the FastAPI application:
uvicorn main:app --reload
-
Open your browser and navigate to
http://127.0.0.1:8000/docsto access the interactive API documentation.
Hereβs an example of the interactive documentation generated by FastAPI:
FastAPI-CRUD-Todo/
βββ database.py # Database setup and connection
βββ models.py # SQLAlchemy models
βββ schemas.py # Pydantic schemas for validation
βββ routers/
β βββ todo.py # API endpoints for CRUD operations
βββ main.py # Entry point for the FastAPI app
βββ requirements.txt # List of dependencies
βββ README.md # Project documentation
Contributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.
This project is licensed under the MIT License.
lymanny - iOS Developer
π Portfolio