Skip to content

Ayush-iitkgp/fastapi-python-service

Repository files navigation

Prerequisites

Project requires python 3.10.8, pyenv, colima, docker, and poetry.

Install pyenv tool to manage python version.

Install container runtime

# install docker
brew install docker
brew link docker # optional

# install docker-compose
brew install docker-compose

# install colima container run time
brew install colima

Running

# via docker
colima start
docker compose up -d

The application is accessible at http:https://localhost:3000.

Create tables

  1. Connect to the postgresSQL database from the local machine using the url localhost:https://postgres:postgres@postgres:5432/db

  2. Run the SQL script in create_table.sql file located in the db folder

Insert data in the tables

  1. Start the containers
docker-compose up -d
  1. Exec into the docker container
docker-compose run app bash
  1. Change the working directory to scripts directory
cd scripts
  1. Run the python command
python insert_data.py

Testing

pytest will run all unit tests that you specify in your codebase.

As pytest convention, all files matching test_*.py will be included.

Running tests

docker-compose run app bash
poetry run pytest

Possible future improvements

  • Implement Authentication - DONE
  • Write (more) tests and fix the not working test
  • Implement CI/CD Pipeline
  • Github hooks for formatting the code

About

Sample FastAPI Python Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published