Skip to content

oussemabenhassena5/FastAPI-Kickoff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Starter

A starter template for building scalable and production-ready FastAPI applications with PostgreSQL and Alembic. This project is fully containerized using Docker and Docker Compose for easy setup and deployment.

Features

  • FastAPI backend
  • PostgreSQL database
  • Alembic for database migrations
  • Docker and Docker Compose for easy setup
  • JWT authentication
  • Pre-configured environment variables

Installation

Prerequisites

Make sure you have the following installed on your machine:

Clone the Repository

git clone https://github.com/yourusername/fastapi-starter.git
cd fastapi-starter

Setup Environment Variables

Create a .env file in the root directory and copy the content from .env.example. Modify it if needed.

cp .env.example .env

Build and Run the Project

Run the following command to build and start the containers:

docker-compose up --build

This will:

  • Start a PostgreSQL database container
  • Build and start the FastAPI backend

The application will be available at:

Running Migrations

Before using the application, run database migrations:

docker-compose exec backend alembic upgrade head

Creating a Superuser

A default superuser will be created automatically using the credentials in the .env file. If you need to create another superuser, you can manually add it via an API call.

Stopping the Application

To stop the application, run:

docker-compose down

Project Structure

fastapi-starter/
│── backend/
│   ├── src/
│   │   ├── main.py          # FastAPI entry point
│   │   ├── models/          # SQLAlchemy models
│   │   ├── crud/            # Database interaction functions
│   │   ├── config/          # Configuration settings
│   ├── Dockerfile           # Backend service Dockerfile
│── docker-compose.yml       # Docker Compose configuration
│── .env                     # Environment variables
│── requirements.txt         # Dependencies
│── README.md                # Documentation

API Endpoints

Once the application is running, visit http://localhost:8000/docs to explore available endpoints.

Contributing

Feel free to fork this repository and customize it according to your needs. Contributions are welcome!

License

This project is licensed under the MIT License.

About

FastAPI Starter with PostgreSQL and Docker

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors