/fastapi_crud

A sample project of FastAPI CRUD application

Primary LanguagePythonApache License 2.0Apache-2.0

FastAPI CRUD Application

This is a simple CRUD (Create, Read, Update, Delete) application built with FastAPI and PostgreSQL. The project uses Docker and Docker Compose to manage containerization.

Table of Contents

Requirements

Before you begin, ensure you have the following installed on your machine:

Installation

  1. Clone the repository:

    git clone https://github.com/progdog/fastapi_crud.git
    cd fastapi_crud
  2. Create the .env file:

    Create a .env file in the root of the project directory using your own credentials based on the .env.example file:

    POSTGRES_USER={your db username}
    POSTGRES_PASSWORD={your db password}
    POSTGRES_DB={your database name}
  3. Build and start the Docker containers:

    docker-compose up --build

    This command will build the Docker images and start the containers for the FastAPI application, PostgreSQL database, and pgAdmin.

  4. Access the application:

Usage

After setting up the project and starting the Docker containers, you can interact with the FastAPI application using HTTP requests. You can use tools like curl, Postman, or the built-in Swagger UI to test the endpoints.

Running Migrations

This project uses Alembic for database migrations. To create and apply migrations, follow these steps:

  1. Create a new migration:

    poetry run alembic revision --autogenerate -m "Migration message"
  2. Apply the migration:

    poetry run alembic upgrade head

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.