Skip to main content

CLI for services template for Python (FastAPI, SQLAlchemy, Alembic)

Project description

Skeletone

A minimal, well-toned Python project skeleton and micro-framework for rapid backend development.
Built on top of FastAPI, SQLAlchemy, and Alembic with automated template versioning, advanced logging, and production-ready features.

Features

  • ๐Ÿš€ FastAPI foundation with modern Python async practices
  • ๐Ÿ—„๏ธ SQLAlchemy (async) ORM with Alembic migrations
  • ๐Ÿงฉ Minimal framework structure with clear folder layout
  • ๐Ÿ“ฆ Template management: init, upgrade, downgrade, version lock
  • ๐Ÿ“„ Patch-based updates between template versions (v1.1.0 to v1.9.0)
  • ๐Ÿ” Incremental version tracking via skeletone.lock
  • ๐Ÿ“Š Advanced Request Logging: All incoming API requests logged to database
  • ๐Ÿงพ Batch Logging System with async buffer and periodic flush (v1.4.0+)
  • ๐Ÿ›ก๏ธ Bulkhead Pattern middleware for concurrency control (v1.9.0+)
  • ๐Ÿ”„ Lifespan Management for startup/shutdown tasks
  • โšก Production-ready - optimized for performance and reliability

What's New in Latest Versions

v1.9.0

  • โœจ Bulkhead Middleware: Control max concurrent requests to prevent overload
  • ๐Ÿ—๏ธ Restructured middleware organization

v1.8.0 - v1.7.0

  • ๐Ÿ“ Enhanced logging service architecture
  • ๐Ÿ”ง Improved lifespan management

v1.6.0 - v1.4.0

  • ๐Ÿš€ Batch Logging: Logs are buffered and flushed periodically for better performance
  • โฑ๏ธ Async logging with configurable flush intervals
  • ๐Ÿ”„ Graceful shutdown with log flushing

v1.3.0 - v1.1.0

  • ๐Ÿ“Š Initial request logging to database
  • ๐Ÿ›๏ธ Base project structure with FastAPI + SQLAlchemy

Installation

pip install skeletone

Quick Start

1. Initialize a New Project

mkdir my-awesome-api && cd my-awesome-api
skeletone init

2. Check Available Versions

skeletone versions

3. Upgrade Your Project

skeletone upgrade

4. Rollback if Needed

# Interactive version selection
skeletone downgrade

# Or specify version directly
skeletone downgrade -v v1.2.0

CLI Commands

Command Description
skeletone init Initialize new project from latest template
skeletone upgrade Upgrade to latest template version
skeletone downgrade Downgrade to a previous template version
skeletone versions List all available template versions
skeletone help Show detailed help and usage examples

How It Works

Skeletone is built around a patch-based versioning system:

  • Init: Sets up a fresh project from the latest template (currently v1.9.0)
  • Upgrade: Applies sequential .patch diffs to upgrade your project
  • Downgrade: Applies reverse patches to safely revert
  • Track: Saves current version to skeletone.lock

Template Structure

The generated project includes:

your-project/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ models/          # SQLAlchemy models (async)
โ”‚   โ”œโ”€โ”€ routers/         # FastAPI route handlers
โ”‚   โ”œโ”€โ”€ dependencies/    # DI system & authorization
โ”‚   โ”œโ”€โ”€ services/        # Business logic & logging service
โ”‚   โ”œโ”€โ”€ middlewares/     # Request logging & bulkhead pattern
โ”‚   โ”œโ”€โ”€ lifespan/        # Startup/shutdown management
โ”‚   โ””โ”€โ”€ utils/           # Enums, configs, helpers
โ”œโ”€โ”€ alembic/             # Database migrations
โ”œโ”€โ”€ config.py            # App settings
โ”œโ”€โ”€ main.py              # FastAPI application entrypoint
โ”œโ”€โ”€ requirements.txt     # Dependencies
โ””โ”€โ”€ skeletone.lock       # Template version lock file

Key Components

๐Ÿ›ก๏ธ Bulkhead Middleware (v1.9.0+)

Prevents system overload by limiting concurrent requests:

app.add_middleware(BulkheadMiddleware, max_concurrent_requests=40, timeout=0)

๐Ÿ“Š Advanced Logging System

  • Request Logger: Automatically logs all HTTP requests with path, method, status, response time
  • Batch Processing: Logs are buffered and flushed periodically for optimal performance
  • Database Storage: All logs stored in PostgreSQL for analysis
  • Async Everything: Non-blocking logging that doesn't impact response times

๐Ÿ”„ Lifespan Management

Clean startup and shutdown handling:

  • Initialize services on startup
  • Gracefully close connections on shutdown
  • Flush pending logs before termination

Example Workflow

# Create and initialize a new project
mkdir blog-api && cd blog-api
skeletone init

# Do your development work...

# Upgrade to latest version (v1.9.0)
skeletone upgrade

# Check available versions
skeletone versions
# Shows: v1.9.0 (current), v1.8.0, v1.7.0, ... v1.1.0

# Rollback if needed
skeletone downgrade -v v1.1.0

Version Table Example

Available Skeletone Versions
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Version โ”‚ Status      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ v1.9.0  โ”‚ โœ… Current   โ”‚
โ”‚ v1.8.0  โ”‚             โ”‚
โ”‚ ...     โ”‚             โ”‚
โ”‚ v1.1.0  โ”‚             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Best Practices

  1. Always commit your code before upgrade/downgrade
  2. Review diffs and changes after updating
  3. Thoroughly test after version transitions
  4. Track your modifications to avoid patch conflicts
  5. Configure bulkhead limits based on your server capacity
  6. Monitor logs regularly for performance insights

Template Repository

The base template for Skeletone lives here:
๐Ÿ‘‰ https://github.com/yoursteacup/skeletone

Contributing

Contributions are welcome! Please see the GitHub repo for guidelines and issue tracking.

Author

Developer: Zhaxybayev Daulet
GitHub: yoursteacup
Telegram: @yoursteacup

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skeletone-0.1.15.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skeletone-0.1.15-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file skeletone-0.1.15.tar.gz.

File metadata

  • Download URL: skeletone-0.1.15.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for skeletone-0.1.15.tar.gz
Algorithm Hash digest
SHA256 63ad8346065c8282cbe68c7b448418b832571740931a915b5328323ef9493799
MD5 6433ea1d58911290c9a83486396497d4
BLAKE2b-256 02168d7bda33b66e485c0a8bbc18d3ce4d69a832ccd52a7509402302224c0955

See more details on using hashes here.

File details

Details for the file skeletone-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: skeletone-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for skeletone-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 cca7d050ca111d2f18d986f51f42920f57c80ac607572c35c4da9de363b96afa
MD5 281207de36297388157b6e5fe7632fef
BLAKE2b-256 6b71f095c46b2dd68bfb97f2525adef6c7eb3b223cb50eb34b0311135e1f54cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page