This is a coding assignment implementation that provides a simple CRUD API for property listings.
In order to run this project you will need venv and SQLite.
Note: Project tested via Python 3.9.6
First navigate to project root.
$ cd <path to project>
Then create virtual environment using venv (if it is not already exists).
$ python3 -m venv venv
then activate it via;
$ source venv/bin/activate
(venv) $
Now you can install required packages.
(venv) $ pip install -r requirements.txt
Next we need to create required tables and populate mock data.
First delete db if exists;
(venv) $ rm -f api.db
Then create new db with mock data using;
(venv) $ sqlite3 -init ./sql/prep.sql api.db .quit
Just run pytest at the project root
(venv) $ pytest
In order to run the project execute following command;
(venv) $ python -m uvicorn app.main:app --reload
Now you can access project via following URLS;
Project: http://127.0.0.1:8000/
Swagger UI: http://127.0.0.1:8000/docs
Redoc UI: http://127.0.0.1:8000/redoc
Module / Folder | Description |
---|---|
sql | SQL scripts |
app | Application main module |
app.core | Generic codes which used by other modules such as configs and base implementations |
app.controller | Methods handles HTTP API requests |
app.model | Model classes |
app.repository | Repository classes which handles custom db operations. Note: Repositories only handles model specific operations. Generic CRUD operations handled via classes resides in app.core.db module |
app.schema | pydantic schemas which used for validations |
app.test | Unit tests for API Tests |
app/main.py | Application entry point |