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.
Before you begin, ensure you have the following installed on your machine:
-
Clone the repository:
git clone https://github.com/progdog/fastapi_crud.git cd fastapi_crud
-
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}
-
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.
-
Access the application:
- FastAPI application: http://localhost:8000
- FastAPI automatic docs (Swagger UI): http://localhost:8000/docs
- FastAPI alternative docs (ReDoc): http://localhost:8000/redoc
- pgAdmin: http://localhost:80
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.
This project uses Alembic for database migrations. To create and apply migrations, follow these steps:
-
Create a new migration:
poetry run alembic revision --autogenerate -m "Migration message"
-
Apply the migration:
poetry run alembic upgrade head
Contributions are welcome! Please open an issue or submit a pull request for any changes.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.