Skip to content

A-A-D-I-C-O-D-E/FastAPI-Postgres-CRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI-Postgres-CRUD

A project for building a robust and scalable CRUD API using FastAPI, PostgreSQL, SQLAlchemy, and Alembic. This template is designed to help developers quickly set up a backend application with essential features like database migrations, ORM integration, and API documentation.

FastAPI PostgreSQL SQLAlchemy Alembic Pydantic Uvicorn Python

🚀 Features

  • FastAPI: High-performance web framework for building APIs with Python 3.7+.
  • PostgreSQL: Reliable and scalable relational database system.
  • SQLAlchemy: ORM for seamless database interactions.
  • Alembic: Database migration tool for version control.
  • Pydantic: Data validation and settings management.
  • Uvicorn: ASGI server for serving FastAPI applications.
  • Swagger UI: Interactive API documentation for easy testing and exploration.

📂 Project Structure

FastAPI-Postgres-CRUD/
├── app/
│   ├── main.py          # FastAPI application instance
│   ├── models.py        # SQLAlchemy models
│   ├── schemas.py       # Pydantic schemas
│   ├── crud.py          # CRUD operations
│   ├── database.py      # Database session management
│   └── config.py        # Configuration settings
├── alembic.ini          # Alembic configuration
├── requirements.txt     # Project dependencies
└── README.md            # Project documentation

🛠️ Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.7 or higher
  • PostgreSQL database
  • pip (Python package installer)

📦 Installation

  1. Clone the repository:

    git clone https://github.com/A-A-D-I-C-O-D-E/FastAPI-Postgres-CRUD.git
    cd FastAPI-Postgres-CRUD
  2. Create and activate a virtual environment:

    python -m venv venv
    • Windows:

      venv\Scripts\activate
    • macOS/Linux:

      source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure PostgreSQL database:

    • Create a new database in PostgreSQL.
  5. Update database connection URL:

    Modify app/config.py to set your database connection string:

    SQLALCHEMY_DATABASE_URL = "postgresql://user:password@localhost/dbname"
  6. Run database migrations:

    alembic upgrade head
  7. Start the FastAPI application:

    uvicorn app.main:app --reload
  8. Access API documentation:

💡 Contributing

Contributions are welcome! Fork the repository and submit a pull request with your suggestions or improvements.

👨‍💻 Author

Aditya Gupta

About

A project for a CRUD API using FastAPI, PostgreSQL, SQLAlchemy, and Alembic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors