Skip to content

A REST API application that serves data from RIVM 2016 dataset. Written in Fast API. Uses docker-compose

License

Notifications You must be signed in to change notification settings

prashant0079/metabolic_assignment

Repository files navigation

Metabolic Assignment

  • An application built as a microservice which hosts data in the form of a REST API.
  • It uses docker-compose to run services.
  • There are three services primary in docker-compose.yml: (db, pgadmin, app)
  • db service: Database is run over db service.
  • pgadmin: Pgadmin is used to access the database and for query purposes.
  • app: This is the main service which contains the logic for accessing the data from the db. Dockerfile is dedicated to the setup of this service.
  • app is written in FastAPI, endpoints are validated using Pydantic
  • It has volumes support(Persistant storage in DBs).
  • Alembic is used as a migration manager.

Requirement or Assumption

  • Docker and docker-compose

Architecture

pipeline_daltix_cli

Installation

# Step 1: cd into the repository root after cloning
# rename .env.template to .env
# also don't forget to fill the valid placeholders in .env. These serve as environment variables
$ mv .env.template .env
# Step 2 Build the microservice
$ docker-compose build
# Step 3 Run the microservice container
$ docker-compose up
# Open another terminal
# Step 4 Setup versions directory for alembic
$ docker-compose run app mkdir migration/versions/
# Step 5
# Issue command to the app for setting up migrations
$ docker-compose run app alembic revision --autogenerate -m "1st Schema Migration"
# Step 6 Apply those migrations
$ docker-compose run app alembic upgrade head
# Step 7 Add valid data to the tables 
$ docker-compose run app python src/scripts/data_preparation.py
# Step 8 Run the unit tests
$ docker-compose run app python -m unittest src/tests/unit_test.py

Sample Usage

# After installation, api will run on localhost:8000
$ docker-compose up
# To remove the project and volumes
$ docker-compose down -v

Checklist

  • Added Unit Tests
  • docker-compose.yml file is fully fledged
  • PG-Admin for accessing and querying db
  • Well documented Swagger Page(OpenAPI)
  • To add async support as psycopg2 is sync
  • API Gateway
  • Logging

Improvements

  • Using an async database driver to make async calls to the database in order to make the application fully asynchronous
  • Putting logging mechanism
  • Implementing API Gateway.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. You can also drop a mail to Prashant Tyagi Please make sure to update tests as appropriate.

License

MIT

About

A REST API application that serves data from RIVM 2016 dataset. Written in Fast API. Uses docker-compose

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published