Giter Site home page Giter Site logo

chefapi's Introduction

ChefAPI

Docker Docker Image CI

ChefAPI ๐Ÿš€

  • An API using FASTAPI & Python-Jose & SQLAlchemy to create and share or keeping track of awesome food recipes.

  • You can Sign Up / Login and share with others Your awesome Food Recipes.

  • Using PostgreSQL as a DataBase and Docker for containerization.

  • Easy to use and Simple to track No Bad Code โค๏ธ

Requirements ๐Ÿš€

  • To start using ChefAPI You need some experience in Cuisine maybe how to create a Moroccan CousCous or Tajine ๐Ÿ˜† , But also you need this:

  • Docker

  • PostgreSQL

  • Python

Installation

  • Get started by cloning the repository :
git clone https://github.com/GDGSNF/ChefAPI.git
pip install -r requirements.txt

Get Started ๐Ÿš€

  • An API with a High Quality of Code based on FastAPI is built on a Python framework called Starlette which is a lightweight ASGI framework/toolkit, which is itself built on Uvicorn.

  • Using SQLAlchemy to Connect to our PostgreSQL Database โค๏ธ

    POSTGRES_SERVER: str = Field(..., env="POSTGRES_SERVER")
    POSTGRES_USER: str = Field(..., env="POSTGRES_USER")
    POSTGRES_PASSWORD: str = Field(..., env="POSTGRES_PASSWORD")
    POSTGRES_DB: str = Field(..., env="POSTGRES_DB")
    SQLALCHEMY_DATABASE_URI: Optional[PostgresDsn] = None

    @validator("SQLALCHEMY_DATABASE_URI", pre=True)
    def assemble_db_connection(cls, v: Optional[str], values: Dict[str, Any]) -> Any:
        if isinstance(v, str):
            return v
        return PostgresDsn.build(
            scheme="postgresql",
            user=values.get("POSTGRES_USER"),
            password=values.get("POSTGRES_PASSWORD"),
            host=values.get("POSTGRES_SERVER"),
            path=f"/{values.get('POSTGRES_DB') or ''}",
        )
  • containerization for the Database and also for the FastAPI project.

Docker-compose.yaml

version: "3.8"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python main.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db
  • Connect and Install your PostgreSQL Container using the dockerfile :
# syntax=docker/dockerfile:1
FROM ubuntu:16.04

RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8

RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >/etc/apt/sources.list.d/pgdg.list

RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3

USER postgres

RUN /etc/init.d/postgresql start && \
    psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" && \
    createdb -O docker docker

RUN echo "host all  all    0.0.0.0/0  md5" >>/etc/postgresql/9.3/main/pg_hba.conf

RUN echo "listen_addresses='*'" >>/etc/postgresql/9.3/main/postgresql.conf

EXPOSE 5432

VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]

CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
  • To run the project you need docker-compose and run this command:
docker-compose up -d
  • To stop:
docker-compose down

Contributing โญ

  • Contributions are welcome โค๏ธ

  • Please share any features, and add unit tests!

  • Use the pull request and issue systems to contribute.

Credits & Thanks ๐Ÿ†

Medium Twitter Discord

chefapi's People

Contributors

dependabot[bot] avatar yezz123 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.