Git Product home page Git Product logo

fastapi_dish_composer's Introduction

Recipe composer

ready to go API for storing, creating, and generating random recipes.

Navigation

Used tech

  • FastAPI - as python web framework
  • mongodb - as data storage
  • Docker/ Docker compose - as container runtime
  • punq - as DI framework

Architecture and patterns

  • Clean architecture by uncle Bob - as a mindset for building this application

  • Whole application is divided in layers to make business logic and technology specific code low coupled

  • Domain layer - contains domain specific entities

  • Logic layer - contains business specific logic or as it is called use cases

  • Infra layer - contains contains code that provides different infrastructure like repositories and DI container

  • Application layer - contains framework specific code

  • Mediator - in this project is not a classic implementation but something in the middle between observer and event bus

Contribution

  • Keep in mind that it is better to use DI than not to use
  • Keep same naming style
  • Use ruff as linter (configuration is in pyproject.toml)

TODO

  1. Tests - are very necessary
  2. Implementation of whole CRUD for recipes block is needed
  3. And a lot of things in the frontend

Start project for dev purposes

  • install dependencies
poetry install --no-root # to install only deps
  • raise mongo storage
make storages
  • provide environment variables in file named .env in the root of the project:
MONGO_USERNAME=admin
MONGO_PASSWORD=pass1234
MONGO_PORT=27017
MONGO_HOST=localhost
CORS_ORIGINS='["www.example.com"]'
MODE=DEV
  • run uvicorn test server
uvicorn fastapi_proj.application.main:app --reload

Everything is ready

There is configured pre-commit hook which will lint the code before commit. Also there is configuration for ruff in pyproject.toml. So you can use it to check code validity.

Run project in production environment

  • pull image from dockerhub:
docker pull ilya4r/recipe-builder:backend
  • run image with provided environment variables:
docker run --name backend \
-p 8000:8000 --network mongonet \
-e MONGO_PORT=27017 -e MONGO_HOST=localhost \
-e MONGO_USERNAME=admin -e MONGO_PASSWORD=superpassword  -d \
-e CORS_ORIGINS='["www.example.com"]' ilya4r/recipe-builder:backend

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.