Skip to content

ninja-data/fastapi-backend

Repository files navigation

fastapi-backend

Backend API service built with FastAPI, SQLAlchemy, and Alembic for a social pet platform.

Tech stack

  • FastAPI
  • SQLAlchemy
  • Alembic migrations
  • PostgreSQL
  • JWT-based authentication

Quick start

1) Install dependencies

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

2) Configure environment

Create a .env file in the project root with the following keys:

DATABASE_HOSTNAME=localhost
DATABASE_PORT=5432
DATABASE_PASSWORD=your_password
DATABASE_NAME=your_database
DATABASE_USERNAME=your_user
SECRET_KEY=your_secret
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

AZURE_STORAGE_CONNECTION_STRING=your_connection_string
AZURE_STORAGE_ACCOUNT_KEY=your_account_key
AZURE_STORAGE_CONTAINER_NAME=your_container

EMAIL_SENDER=your_sender@example.com
EMAIL_PASSWORD=your_email_password

3) Run migrations

alembic upgrade head

4) Start the API

uvicorn app.main:app --reload

Open Swagger docs at: http://127.0.0.1:8000/docs

Project structure

  • app/main.py – app initialization and router wiring
  • app/routers/ – route handlers (auth, users, posts, pets, messaging, etc.)
  • app/models.py – SQLAlchemy models
  • app/schemas.py – Pydantic schemas
  • app/database.py – database connection/session setup
  • alembic/ – migration configuration and revision history

Improvement opportunities

  • Add automated tests for core auth and post flows (smoke + integration tests).
  • Introduce structured logging and request IDs for easier production debugging.
  • Add CI checks for linting, migration drift, and test execution.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors