Skip to content

as-bas/py-app-api

Repository files navigation

FastAPI Project

A modern web API built with FastAPI, using Poetry for dependency management and Alembic for database migrations.

Features

  • Fast and high-performance API endpoints
  • Automatic interactive API documentation
  • Type hints throughout the codebase
  • Database integration with SQLAlchemy ORM
  • Database migrations using Alembic
  • Dependency management with Poetry

Tech Stack

  • FastAPI - Modern, fast web framework for building APIs
  • Pydantic - Data validation and settings management
  • SQLAlchemy - SQL toolkit and ORM
  • Alembic - Database migration tool
  • Poetry - Dependency management and packaging
  • Uvicorn - ASGI server

Installation

Prerequisites

  • Python 3.8 or higher
  • Poetry

Setup

  1. Clone the repository:
git clone https://github.com/username/app-api.git
cd app-api
  1. Install dependencies with Poetry:
poetry install
  1. Set up environment variables:
cp .env.example .env
# Edit .env file with your configuration
  1. Run database migrations:
poetry run db-migrate

Usage

Running the server

# Development mode
poetry run start

The API will be available at http://localhost:8000.

API Documentation

FastAPI provides automatic interactive API documentation:

Development

Project Structure

├── app/
│   ├── api/             # API endpoints
│   ├── core/            # Core functionality
│   ├── models/          # SQLAlchemy models
│   ├── repos/           # Repositories
│   ├── schemas/         # Pydantic schemas
│   ├── services/        # Application services
│   └── main.py          # Application entry point
├── alembic/             # Alembic migrations
├── tests/               # Test suite
├── pyproject.toml       # Poetry configuration
└── alembic.ini          # Alembic configuration

Database Migrations

This project uses Alembic for database migrations.

Create a new migration

poetry run db-generate "description of the change"

Apply migrations

poetry run db-migrate

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add some amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published