Giter VIP home page Giter VIP logo

meal-planner-api's Introduction

Python Boilerplate

Table of Contents

About this Project

Python Boilerplate provides a common file structure for a Python project and encourages best practices in python development, including some simple code quality checks set up and some idiomatic examples of python data structures and functions. This project is a template that can be used as a foundation for future projects.

Made With

  • poetry - Dependency management library that makes creating and installing packages more streamlined.
  • pytest - Simplifies the design and execution of both unit and integration testing.
  • black - Autoformats code for consistent styling.
  • ruff - Checks that code follows idiomatic best practices for Python.
  • pylint - Applies a few additional checks that aren't covered by ruff.
  • pre-commit - Runs code quality checks before code is committed.

Relevant Documents

Getting Started

Prerequisites

  • Python installed on your local machine, a version between 3.7 and 3.9
  • Poetry installed on your local machine

In order to check that you have both Python and Poetry installed, run the following in your command line, and the output should look something like this:

NOTE: in all of the code blocks below, lines preceded with $ indicate commands you should enter in your command line (excluding the $ itself), while lines preceded with > indicate the expected output from the previous command.

$ python --version && poetry --version
> Python 3.9.0
> Poetry version 1.1.6

TROUBLESHOOTING: If you receive an error message, or the version of python you have installed is not between 3.7 and 3.9, consider using a tool like pyenv (on Mac/Linux) or pyenv-win (on Windows) to manage multiple python installations.

If you have python installed but not poetry, follow these installation instructions:

Installation

  1. Clone the repository on your local machine
  2. Change directory into the cloned project: cd python-boilerplate
  3. Run the setup command make setup

Usage

This Template

When using this boilerplate code as a template for your own project, follow the steps below:

  1. Complete all of the TODO items listed as comments in this README
  2. Pick a new name for your package, then replace the word boilerplate with that new name in the following places:
    • pyproject.toml
    • src/boilerplate/ and all files within that directory
    • tests/ and all of the files within that directory
  3. All new python code should be added either as a single module or collection of modules under the src/{your_package_name}/ directory. For reference:
    pyproject.toml
    src/
      your_package_name/
        main.py
        your_new_module_1.py
        your_new_module_2/
           your_new_module_2_1.py
           your_new_module_2_2.py
    tests/
    
  4. If the new code requires a package that is not already installed, add it to the project by using poetry add <package_name>
  5. If you make any manual changes to the pyproject.toml file make sure you run: poetry lock && poetry install
  6. Each new method or function you write needs to be accompanied by a test which calls that method or function. These unit and/or integration tests should be added to the tests/ directory using a file structure that mirrors the modules you are contributing to. For reference:
    tests/
      conftest.py
      test_main.py
      test_your_new_module_1.py
      your_new_module_2/
         test_your_new_module_2_1.py
         test_your_new_module_2_2.py
    
    

    NOTE

    • CI/CD checks will only pass if more than 90% of the code base is executed by the tests
    • Pytest requires the following naming conventions for test discovery

{Use Case 1}

{1-2 sentence summary of this use case}

  1. {Step 1 to complete use case}
  2. {Step 2 to complete use case}
  3. ...

Vision and Roadmap

The vision for this template is to simplify the process of creating open source python projects with high quality codebase and mechanisms that promote smart and collaborative project governance. This project aims to fulfill this vision by:

  • Adopting a common python package file structure
  • Implementing basic linting and code quality checks
  • Reinforcing compliance with those code quality checks using CI/CD
  • Providing templates for things like documentation, issues, and pull requests
  • Offering pythonic implementation examples of common data structures and scripting tasks like:
    • Creating classes, methods, and functions
    • Setting up unit and integration testing
    • Reading and writing to files

Contributing

Contributions are always welcome! We encourage contributions in the form of discussion on issues in this repo and pull requests for improvements to documentation and code.

See CONTRIBUTING.md for ways to get started.

License

Distributed under the MIT License. See LICENSE for more information.

Maintainers

Acknowledgements

meal-planner-api's People

Contributors

widal001 avatar

Watchers

 avatar

meal-planner-api's Issues

[Task]: Set up FastAPI

Summary

Set up a FastAPI application for the meal planner app

Acceptance criteria

  • Developers can start the api locally by running make api-dev

API consumers can get a list of meals

Summary

API consumers can get a list of recipes for their meal plan.

Acceptance criteria

When: API consumers call GET /meals/ they get the following response:

{
    "items": [
        {
            "title": "Sweet potato, black bean, and kale tacos",
            "description": "<Description of the recipe>",
            "ingredients": [
                {"name": "sweet potatoes", "quantity": 2, "unit": "count"},
                {"name": "black beans", "quantity": 1.5, "unit": "cup"},
                {"name": "tortillas", "quantity": 6, "unit": "count"},
            ],
            "tags": ["vegetarian", "dinner"],
        },
        {
            "title": "Kale pasta",
            "description": "<Description of the recipe>",
            "ingredients": [
                {"name": "pasta", "quantity": 0.5, "unit": "pound"},
                {"name": "kale", "quantity": 0.5, "unit": "pound"},
                {"name": "olive oil", "quantity": 0.25, "unit": "cup"},
            ],
            "tags": ["vegetarian", "lunch"],
        },
    ],
    "total": 30,
    "size": 10,
    "page": 1,
    "pages": 3
}

API consumers can create a new meal plan and save recipes to it

Summary

API consumers should be able to access API endpoints that allow them to:

  • Create a new meal plan
  • Save recipes to that meal plan

Acceptance criteria

Creating an meal plan

When API consumers call the POST /meal_plans/ endpoint with the following payload:

{
   "start_date": "2023-11-02",
   "end_date": "2023-11-08",
   "meal_count": 9
}

Then a new meal plan is created and returned with the following response:

{
   "id": "74675d10-ff0d-4753-8559-6d03f710ad33",
   "start_date": "2023-11-02",
   "end_date": "2023-11-08",
   "meal_count": 9,
   "collaborators": [
     {"number": "908-578-4622"}
   ]
}

Saving a meal to a meal plan

When API consumers call the PUT /meal_plans/{meal_plan_id}/recipes/{recipe_id}/save endpoint.

Then it adds a recipe to the meal plan's list of saved recipes and returns an empty response with status code 204 No content

Rejecting a meal from a meal plan

When API consumers call the PUT /meal_plans/{meal_plan_id}/recipes/{recipe_id}/reject endpoint.

Then it adds a recipe to the meal plan's list of rejected recipes and returns an empty response with status code 204 No content

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.