Git Product home page Git Product logo

cawokru / fastapi-over-northwind Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adniec/fastapi-over-northwind

0.0 0.0 0.0 9.05 MB

Microservices built with FastAPI over Northwind database ported to PostgreSQL and deployed by Docker Swarm. Payments via PayPal sandbox. Sample metrics setup with cAdvisor, Prometheus and Grafana.

License: Other

Shell 13.23% Python 84.93% Dockerfile 1.83%

fastapi-over-northwind's Introduction

FastAPI over Northwind PostgreSQL Database

Diagram

About

Sample implementation of microservices created with FastAPI and run by Docker over Northwind database ported to PostgreSQL. Endpoints authorization through HTTP Basic. Payment mechanism via PayPal sandbox. Monitoring and alerting with:

Performance of operations direct on database versus through API is shown here.

Animation below illustrates making an order and not finalizing payment (changes to database are reversed after some time - shorter for example purpose):

make_order

Build

To build project use Docker Swarm. Follow instructions below:

git clone https://github.com/ethru/fastapi-over-northwind.git
cd fastapi-over-northwind
docker stack deploy app -c docker-compose.yml

To see service documentation and test it go to http://0.0.0.0:8080/api/'service-name'/docs in browser.

Note: during first run database is created and there can occur problem with connection from services listed below. If 502 Bad Gateway shows up after going to services URLs restart them with:

docker service update --force app_categories_service
docker service update --force app_products_service
docker service update --force app_orders_service
docker service update --force app_reports_service

Services

Endpoints

products

Manual tests of services can be done in Swagger UI (see photo). To send DELETE request click on it then press Try it out button and Execute. Result will appear below.

Authorization

Some endpoints are protected with HTTP Basic against unauthorized access. They are marked with grey locker on the right side. To perform action log in first. Press Authorize button or locker icon and pass authorization header into value field. It is created from username and password . Default: admin and password which give header Basic YWRtaW46cGFzc3dvcmQ=. Feel free to modify linked files to your needs. Then generate header using for example this tool.

Tests

Animation shows manual tests performed through Swagger UI:

errors

Tests are located in tests directory. To run them install all dependencies first:

pip install pytest
pip install pytest-dependency
pip install pytest-ordering

Then build project. It is mandatory, because all tests are performed on live endpoints. When environment will be ready in main directory use command:

python -m pytest tests

tests

License

This project is under the Ms-PL License

fastapi-over-northwind's People

Contributors

adniec avatar pthom avatar goodguygregory avatar koushik-shetty avatar mat013 avatar larryq avatar suschevsky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.