Code Monkey home page Code Monkey logo

fastapi-pgstarterkit's Introduction

πŸš€ fastapi-postgresql-starterkit - The Backend Saga! πŸŽ‰

Badge Badge Badge Badge

Hello there, coding wanderer! 🌍 If you're here, you probably love FastAPI, enjoy PostgreSQL, and adore backends. Oh, and did I mention? We're now sailing smoothly with Docker! 🐳 No more environment discrepancies, just pure coding bliss.

Why This Project? πŸ€”

Because the backend is where the real action happens! It's like the backstage of a rock concert - not visible to all, but without it, the show won't go on!

What's Changed? ⏳

I took the majestic backend of the original full-stack-fastapi-postgresql project, dusted off the cobwebs, replaced the rusty bolts, and added a sprinkle of Docker goodness! A modernized, faster, and improved version now awaits you.

Features 🌈

  1. FastAPI Magic - Because speed is not just about Fast & Furious movies!
  2. PostgreSQL Integration - Store data like a pro. No more data loss nightmares!
  3. Docker Integration - Set sail with a consistent environment. Because why let tech discrepancies ruin your day?
  4. Fixes, Fixes, Fixes - All those bugs? Gone! (Well, most of them, but let's be optimistic!)

Setup & Run πŸƒβ€β™‚οΈ

To set this baby up:

If you don't have one yet, set up a .env file with your configuration. For a basic version for local testing use:

cp dot-env-template .env

Be aware that .env is excluded from git because it contains secrets, API keys and so on. Never put your .env file into git.

Then build and start the test/debug stack with:

docker-compose up --build

Then:

  • Visit http://localhost:4000/docs for the interactive API docs (Swagger). For initial super-username and password to first authenticate see your .env file.
  • Modify your code, which is linked into the fastapi-app container and watch uvicorn auto-restart your app when changes have been made.
  • Run pytest in your container with docker exec fastapi-app bash ./test.sh [optional parameters]
  • Visit http://localhost:5050/ for the PostgreSQL administrator. Upon first use you'll need to register your DB server using your .env file.

Contribute! 🀝

Did you find more ancient bugs lurking around? Or perhaps you unearthed a potential treasure in the form of a feature? Pull requests are more than welcome. After all, multiple minds make light work. Let's polish this backend to be more radiant than a starry night! πŸ’«

Credits & A Bow πŸŽ–οΈ

A grand salute to the maestro behind the original full-stack-fastapi-postgresql. Their innovative groundwork laid the foundation, allowing this revamped symphony to come to life.

A Chuckle For the Road πŸ˜„

Here's a nugget of wisdom: The frontend is your application's charming smile, but the backend? That's the beating heart and the brilliant mind! Nurture it, for a healthy heart and a sharp mind make dreams come alive. πŸ˜‰

fastapi-pgstarterkit's People

Contributors

gmos avatar nsxsnx avatar romstar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fastapi-pgstarterkit's Issues

Celery to be or not.

What are your plans with Celery? It's now in the code but there is no Celery container. Add Celery or remove the support? Now it fails the test case every time.

What are the steps for adding new models / tbls?

If I make model changes then run:

alembic revision --autogenerate -m "Added ..."

I get the following error:

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "db" to address: nodename nor servname provided, or not known

Doesn't run - not reachable

I downloaded the repo and ran docker-compose up --build

and got this:
image

I tried going to http://localhost:8000/docs as per the readme but got "This site can’t be reached"
I also noticed in the screenshot above that the uvicorn port says 80, not 8000? But even going to localhost:80 doesn't work either though

Deployment guide

Hi guys,

First of all, Thank you very much for this amazing starterKit :)

Are there some deployment guidelines?
I am trying to follow the one provided here but it would be definitely better if there were a Deployment guide specifically designed for this starterKit.

Cheers

JWT Secret should come from an environment variable

Currently the config.py file sets the JWT secret to a random 32 character string upon the service startup and this is a really bad practice because in the wild this would force every single user to relogin upon a deployment among many other issues.

Also, the line load_dotenv() needs to exist before the definition of the class Settings otherwise environment variables aren't available within the Settings class.

how to run the tests?

AWESOME work!

I was wandering, though, how can I run the tests? In the "original" tiangolo version, there are a bunch of scripts that creates testing stack and run the tests on it. I'm trying to run the tests from your version with just pytest, but they're not passing 😒

Screenshot 2023-08-19 at 18 57 21

problem on mac

Thanks a lot for working on getting this live! I tried to run this on mac and I am getting this issue: any idea on how to fix this? Thanks in advance!

Building 0.7s (2/3) docker:desktop-linux
[+] Building 1.2s (3/3) FINISHED docker:desktop-linux
=> [fastapi-app internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 288B 0.0s
=> [fastapi-app internal] load .dockerignore 0.1s
=> => transferring context: 111B 0.0s
=> ERROR [fastapi-app internal] load metadata for docker.io/library/python 0.6s

[fastapi-app internal] load metadata for docker.io/library/python:3.11-slim:


failed to solve: python:3.11-slim: error getting credentials - err: exit status 1, out: ``

SQLModel

I want to include SQLModel in the backend to remove redundancies between models and schemas. Would that fit your plans with the repo?

Cannot run the default package

Hi. I got this error right after I installed package and run docker-compose up --build.

fastapi-app_1 | INFO:__main__:Initializing service fastapi-app_1 | INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it. pgadmin | NOTE: Configuring authentication for SERVER mode. pgadmin | pgadmin | pgAdmin 4 - Application Initialisation pgadmin | ====================================== pgadmin | pgadmin | postfix/postlog: starting the Postfix mail system pgadmin | [2023-08-19 23:17:06 +0000] [1] [INFO] Starting gunicorn 20.1.0 pgadmin | [2023-08-19 23:17:06 +0000] [1] [INFO] Listening at: http://[::]:80 (1) pgadmin | [2023-08-19 23:17:06 +0000] [1] [INFO] Using worker: gthread pgadmin | [2023-08-19 23:17:06 +0000] [91] [INFO] Booting worker with pid: 91 fastapi-app_1 | ERROR:__main__:(psycopg2.OperationalError) connection to server at "db" (172.18.0.2), port 5432 failed: Connection timed out fastapi-app_1 | Is the server running on that host and accepting TCP/IP connections? fastapi-app_1 | fastapi-app_1 | (Background on this error at: https://sqlalche.me/e/20/e3q8) fastapi-app_1 | WARNING:__main__:Finished call to '__main__.init' after 129.312(s), this was the 1st time calling it. fastapi-app_1 | INFO:__main__:Starting call to '__main__.init', this is the 2nd time calling it.

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.