Skip to content

MissingCorner/fastapi-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Training

FastAPI training API with Postgres, SQLAlchemy, Alembic, and user/chat modules.

Project Layout

.
├── api/                 # FastAPI app, Alembic, tests, Python dependencies
│   ├── app/             # Backend application package
│   ├── alembic/         # Database migrations
│   ├── tests/           # API tests
│   └── pyproject.toml
└── docker-compose.yml   # db + api local stack

Prerequisites

  • Docker Desktop
  • uv for running the API outside Docker

Docker Compose is the recommended local setup because it runs the API and database with the right network and env wiring.

Environment Setup

Create the API env file:

cp api/.env.example api/.env

Then configure it:

DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/fastapi_db
ENVIRONMENT=development
OPENAI_API_KEY=your_api_key_here

Run Locally With Docker

Start services:

docker compose up --build

Or run in the background:

docker compose up -d --build

Open:

  • API docs: http://127.0.0.1:8000/docs
  • Postgres: localhost:5432

Stop the stack:

docker compose stop

Remove containers and volumes when you want a clean database:

docker compose down -v

Run API Manually

cd api
uv sync
uv run uvicorn app.main:app --reload

When running manually, make sure Postgres is available and api/.env points to the correct database host.

Tests

Run API tests from the API project root:

cd api
uv run pytest

The tests expect Postgres at localhost:5432 with a fastapi_test_db database.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors