Coder Social home page Coder Social logo

nightriddler / fastapi_realworld Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 157 KB

Implementation RealWorld project. Fastapi, pydantic, sqlalchemy, pytest, asyncio, aioredis, docker-compose.

License: MIT License

Python 99.17% Mako 0.53% Dockerfile 0.18% Shell 0.12%
fastapi sqlalchemy pydantic docker-compose postgresql pytest async gitactions-workflow aioredis

fastapi_realworld's Introduction

FastAPI Realworld

logo

Styles Tests codecov Code style: black license MIT

FastAPI SQLAlchemy Pydantic

Implementation for RealWorld project using FastAPI and SQLAlchemy.

Also:

fastapi
pydantic
sqlalchemy
alembic
asyncpg
asyncio
aioredis
pytest
httpx

Redis for cache favorite articles and count favorite articles.

Deployment in Docker

  1. Clone repository
git clone https://github.com/nightriddler/fastapi_realworld.git
  1. In the root folder create a file .env with environment variables (or rename the file .env.example to .env)::
SECRET=secret-key
DATABASE_URL=postgresql+asyncpg2://postgres:postgres@db/postgres
REDIS_URL=redis://redis:6379

You can generate your SECRET with the command (from the root):

echo SECRET=$(openssl rand -hex 32) >> .env
  1. In the same folder, run docker-compose with the command
docker-compose up
  1. The project is available at
http://127.0.0.1:8000/docs/

The pgAdmin panel is available:

http://127.0.0.1:5050/

Testing in Docker

Run the migration to test it:

docker-compose exec web alembic upgrade head

And then, run the tests:

docker-compose exec web python -m pytest

Deployment local

  1. Clone repository
git clone https://github.com/nightriddler/fastapi_realworld.git
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/Scripts/activate 
  1. Install go to the backend folder and install the dependencies:
cd backend/
pip install -r requirements.txt
  1. Create a .env (you can use .env.example), with your SECRET and DATABASE_URL in the same backend folder.

  2. Run the migrations:

alembic head upgrade
  1. Run the application:
uvicorn main:app --reload
  1. The app will be available at:
http://127.0.0.1:8000/docs
  1. Running tests:
python -m pytest

Documentation

The documentation /docs/openapi.yml can be seen at https://editor.swagger.io/ and also when you start the project at http://127.0.0.1:8000/docs/.

Contact the author

LinkedIn

Telegram

Portfolio

fastapi_realworld's People

Contributors

nightriddler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

aland-zhang

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.