This repository contains the source code to illustrate a fundamental understanding of REST API principles and how to execute basic CRUD (Create, Read, Update, Delete) operations.
- Build a basic REST API for CRUD operations on a person resource.
- Interface the API with a database of your preference.
- Implement parameter handling for tasks like adding or retrieving a person by their identity.
- Create UML diagrams to document the system's design and database structure.
- Develop an automated testing script to validate each API function.
- Host the entire project on GitHub.
- Provide well-structured documentation in the repository.
- Include details on request/response formats, setup instructions, and API usage examples in the documentation.
- Python
- FastAPI
- SQlite
Make sure you have Python3 installed on your machine.
Detailed instructions for setting up the project on a local development environment.
-
Run
git clone <repo link>
to clone this repo -
Creat and activate a virtual environment
Setup virtual environment on Windows or Linux
python -m venv env source env/bin/activate # Linux env\Scripts\activate.bat # Windows
-
Install project dependencies
pip install -r requirements.txt
-
Database Setup
Upon statring your local server. The application takes care of setting up a database with a filename
lite.db
for you.SQlite does not require complex setup process which makes it suitable for a project of the nature.
-
Start local server
uvicorn app.main:app --host "0.0.0.0" --port 80
-
Navigate to http://localhost:80/ Viola !! 😄
- Build Docker Image
docker build -t myimage .
- Start Docker Container
docker run -d --name mycontainer -p 80:80 myimage
- Visit Endpoint @ http://localhost:80/
If you would love to setup FastAPI in production. Read the official documentation
https://hngx-task-two-zjqf.onrender.com
For a more extensive crud api checkout, https://github.com/princewilling/fastapi-crud-api.