Skip to content

Farruxh/postgresql-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI + PostgreSQL Project

This project is a learning exploration of FastAPI, PostgreSQL, and Python best practices, with CRUD operations implemented for a Book entity.

What I Learned

During this project, I explored:

  • FastAPI basics: routes, decorators, and syntax (@app.get, @app.put)
  • Controllers and service logic: separating route handling from database operations
  • Python packages:
    • Pydantic: for data validation and schema definitions
    • SQLAlchemy ORM: for interacting with PostgreSQL using classes and objects
    • Uvicorn: as the ASGI server to run the FastAPI app
  • Virtual environments: how to create and use venv in Python to isolate dependencies
  • PostgreSQL + pgAdmin: connecting to and managing databases
  • Models and Schemas: defining SQLAlchemy models and Pydantic schemas for data structure
  • Project structure: organizing the project with app/ folder, models, schemas, routes, services
  • Environment variables: storing sensitive data like database URL
  • Pydantic BaseSettings: how to manage environment variables and configuration using BaseSettings
  • CRUD operations: performing create, read, update, and delete actions for a Book entity
  • Key functions and concepts learned: model_dump, declarative_base(), db.add(), db.commit(), unpacking operator (**), response_model, and how they work in practice

Key Points

  • Routes handle HTTP requests, call service functions, and return responses
  • Controllers/Services contain the business logic for database operations
  • Database interactions are done via SQLAlchemy ORM and sessions
  • Environment variables keep sensitive data safe and separate from code
  • Models and Schemas define how data is structured in the database

This project helped me understand how to structure a FastAPI project properly, connect to PostgreSQL, manage configuration and secrets, and write clean, modular code.

About

A FastAPI project with PostgreSQL and Pydantic, implementing CRUD for a Book entity and exploring models, schemas, routes, and SQLAlchemy ORM.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages