All Projects → jearistiz → guane-intern-fastapi

jearistiz / guane-intern-fastapi

Licence: MIT license
FastAPI-PostgreSQL-Celery-RabbitMQ-Redis bakcend with Docker containerization

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to guane-intern-fastapi

vue-element-admin-fastapi
vue-element-admin-fastapi
Stars: ✭ 145 (+168.52%)
Mutual labels:  celery, fastapi
fastapi-celery-redis-rabbitmq
A simple docker-compose app for orchestrating a fastapi application, a celery queue with rabbitmq(broker) and redis(backend)
Stars: ✭ 81 (+50%)
Mutual labels:  celery, fastapi
FastAPI Tortoise template
FastAPI - Tortoise ORM - Celery - Docker template
Stars: ✭ 144 (+166.67%)
Mutual labels:  celery, fastapi
Stack-Lifecycle-Deployment
OpenSource self-service infrastructure solution that defines and manages the complete lifecycle of resources used and provisioned into a cloud! It is a terraform UI with rest api for terraform automation
Stars: ✭ 88 (+62.96%)
Mutual labels:  celery, fastapi
Tplan
😃 T计划 是一个集成了任务队列、进程管理、爬虫部署、服务可视化监控、数据展示、在线编码、远程部署的通用系统。
Stars: ✭ 59 (+9.26%)
Mutual labels:  celery, fastapi
Full Stack Fastapi Postgresql
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Stars: ✭ 7,635 (+14038.89%)
Mutual labels:  celery, fastapi
fastapi
基于Fastapi开发,集成Celery-redis分布式任务队列、JWT 用户系统、ElasticSearch和encode orm的基础项目模板,大家可以根据自己的需求在本模板上进行修改
Stars: ✭ 75 (+38.89%)
Mutual labels:  celery, fastapi
logtoes
Demo of Asynchronous pattern (worker) using Python Flask & Celery
Stars: ✭ 49 (-9.26%)
Mutual labels:  celery
KivyMLApp
The repository host the API for the ML model via FastAPI, Flask and contains android app development files using KivyMD.
Stars: ✭ 54 (+0%)
Mutual labels:  fastapi
lrnfast
FastAPI Notes Example using databases and postgresql
Stars: ✭ 12 (-77.78%)
Mutual labels:  fastapi
fastAPI-aiohttp-example
How to use and test fastAPI with an aiohttp client
Stars: ✭ 69 (+27.78%)
Mutual labels:  fastapi
fastapi-project
FastAPI application without global variables(almost) =)
Stars: ✭ 26 (-51.85%)
Mutual labels:  fastapi
cell
actor framework for Kombu
Stars: ✭ 73 (+35.19%)
Mutual labels:  celery
FastAPI-template
Feature rich robust FastAPI template.
Stars: ✭ 660 (+1122.22%)
Mutual labels:  fastapi
chitra
A multi-functional library for full-stack Deep Learning. Simplifies Model Building, API development, and Model Deployment.
Stars: ✭ 210 (+288.89%)
Mutual labels:  fastapi
ptt-studyabroad-api
🔎 Search articles with personalized results on ptt/studyabroad
Stars: ✭ 57 (+5.56%)
Mutual labels:  fastapi
funboost
pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和全球一切知名消息队列中间件,python函数加速器,框架包罗万象,一统编程思维,兼容50% python编程业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数。旧名字是function_scheduling_distributed_framework
Stars: ✭ 351 (+550%)
Mutual labels:  celery
DeadPool
该项目是一个使用celery作为主体框架的爬虫应用,能够灵活的添加爬虫任务,并且同时运行多站点的爬虫工作,所有组件都能够原生支持规模并发和分布式,加上celery原生的分布式调用,实现大规模并发。
Stars: ✭ 38 (-29.63%)
Mutual labels:  celery
ml gallery
This is a master project of some experiments with Neural Networks. Every project here is runnable, visualized and explained clearly.
Stars: ✭ 18 (-66.67%)
Mutual labels:  fastapi
image-background-remove-tool
✂️ Automated high-quality background removal framework for an image using neural networks. ✂️
Stars: ✭ 767 (+1320.37%)
Mutual labels:  fastapi

FastAPI - PostgreSQL - Celery - Rabbitmq backend

This source code implements the following architecture:

architecture

All the required database endpoints are implemented and tested. These include crud operations for dog and user PostgreSQL relations. The asynchronous tasks are queued via one endpoint, and the upload of files to guane internal test server (external API) is implemented as another endpoint.

This app also executes HTTP requests to another external endpoint located at https://dog.ceo/api/breeds/image/random which returns a message with an URL to a random dog picture. The URL is stored as the field picture in the dog relation.

Deploy using Docker

To deploy this project using docker make sure you have cloned this repository

$ git clone https://github.com/jearistiz/guane-intern-fastapi

and installed Docker.

Now move to the project root directory

$ mv guane-intern-fastapi

Unless otherwise stated, all the commands should be executed from the project root directory denoted as ~/.

To run the docker images just prepare your environment variables in the ~/.env file and run

$ docker compose up --build

If you have an older Docker version which does not support the $ docker compose command, make sure you install the docker-compose CLI, then run

$ docker-compose up --build

The docker-compose.yml is configured to create an image of the application named application/backend, an image of PostgreSQL v13.3 –named postgres–, an image of RabbitMQ v3.8 –rabbitmq– and an image of Redis v6.2 –reddis. To see the application working sound and safe, visit the URI 0.0.0.0:8080/docs or the equivalent URI you defined in the ~/.env file (use the format ${BACKEND_HOST}:${BACKEND_PORT}/docs) and start sending HTTP requests to the application via this nice interactive documentation view, brought to us automatically thanks to FastAPI integration with OpenAPI

architecture

In order to use the POST, PUT or DELETE endpoints you should first authenticate at the top right of the application docs (0.0.0.0:8080/docs) in the button that reads Authorize. I have set up this two super users for you to test these endpoints, use the one you feel more comfortable with ;)

user: guane
password: ilovethori

or

user: juanes
password: ilovecharliebot

If other fields are required in the authentication form, please leave them empty.

Notes on the database relations

Please consider the following notes when trying to make requests to the app:

  • The dog and user relations are connected by the field id_user defined in the dog relation (this is done via foreign key deifinition). Make sure the entity user with id = id_example is created before the dog with id_user = id_example.
  • If you want to manually define the id field in the user and dog relations, make sure there is no other entity within the relation with the same id.
    • The best thing is to just let the backend define the id fields for you, so just don't include these in the HTTP request when trying to insert or update the entities via POST or PUT methods.

Thats it for deploying and manually testing the endpoints.

Test the application inside Docker using pytest

If you want to run the tests inside the docker container, first open another terminal window and get the <Container ID> of the app/backend container using the command

$ docker ps

This command will list information about all your docker images but you are interested only in the one named app/backend.

Afterwards, run a bash shell using this command

$ docker exec -it <Container ID> bash

When you are already inside the container's bash shell, make sure you are located in the /app directory (you can check this if $ pwd prints out /app... if not, execute $ mv /app), and execute the following command:

$ python scripts/app/run_tests.py

There are some options for this testing initialization script (which underneath uses pytest) such as --cov-html which will generate an html report of the coverage testing. If you want to see all the options just run $ python scripts/app/run_tests.py --help. And test using your own options.

Deploy without using Docker

The application can also be deployed locally in your machine. It is a bit more dificult since we need to meet more requirements and setup some stuff first, but soon I will post more info on this here. Soon.

Requirements

NOTE: you may find the scripts used for server initialization invasive. Please take into account that this scripts might start and stop the appropriate servers (postgres, celery, rabbitmq, redis), and they might create and delete users in the mentioned services. Please review the scripts before executing them and execute them only under your own responsibility.

Code quality

The developement process has been carefully monitored using the sonarcloud engine available at https://sonarcloud.io/dashboard?id=jearistiz_guane-intern-fastapi. Flake8 linter has also been used thoroughly for code style and pytest to ensure the code is working as expected.

References

This app was developed using as main reference @tiangolo's FastAPI documentation and his Full stack, modern web application generator, which are both distributed under an MIT License. Some parts of this source code are literal code blocks from the cited references.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].