Skip to main content

fastgram

A modern CLI tool for FastAPI developers - initialize projects with middleware, manage settings, and generate SSL certificates.

Python Version License PyPI Version

Features

  • 🚀 Initialize FastAPI project structure with Django-like folder layout
  • 🔐 Generate self-signed SSL certificates
  • 📦 Pre-configured middleware (CORS, Request ID, Logging, Rate Limit)
  • ⚙️ Centralized settings (server, middleware, rate limits)
  • 💅 Beautiful output with Rich library
  • ⚡ Fast and easy to use
  • 📦 Ready for PyPI publication

Installation

From GitHub

pip install git+https://github.com/ndugram/fastgram-cli.git

From Source

git clone https://github.com/ndugram/fastgram-cli.git
cd fastgram
pip install -e .

Quick Start

# Initialize a new project
fastgram init myproject

# Enter project directory
cd myproject

# Start development server
python manage.py runserver

# Open in browser
# http://127.0.0.1:8000
# API docs: http://127.0.0.1:8000/docs

Initialize Project

fastgram init [name]

Creates a new FastAPI project structure with pre-configured middleware:

project_name/
├── api/
│   └── __init__.py
├── core/
│   └── __init__.py
├── database/
│   └── __init__.py
├── schema/
│   └── __init__.py
├── service/
│   └── __init__.py
├── views/
│   └── __init__.py
├── middleware/
│   ├── __init__.py
│   ├── cors.py
│   ├── logging.py
│   ├── rate_limit.py
│   ├── request_id.py
│   └── loader.py
├── main.py
├── manage.py
└── settings.py

Default project name: backend

Middleware

Generated projects include these middleware by default:

Middleware Description
RateLimitMiddleware Rate limiting (default: 5 requests/second)
LoggingMiddleware Logs incoming HTTP requests
CORSMiddleware Cross-Origin Resource Sharing (permissive)
RequestIDMiddleware Adds unique request ID to each request

Configure Middleware

Edit settings.py to modify middleware:

MIDDLEWARE = [
    "middleware.rate_limit.RateLimitMiddleware",
    "middleware.logging.LoggingMiddleware",
    "middleware.cors.CORSMiddleware",
    "middleware.request_id.RequestIDMiddleware",
]

Rate Limit Settings

Configure rate limiting in settings.py:

RATE_LIMIT_LIMIT = "5/second"  # Format: "<count>/<second|minute>"

Settings

All configuration is centralized in settings.py:

SECRET_KEY = "generated_secret_key_here"

# Database settings
DB_URL = "sqlite+aiosqlite:///./db.sqlite3"

# Server settings
HOST = "127.0.0.1"
PORT = 8000
RELOAD = True

# Rate limit settings
RATE_LIMIT_LIMIT = "5/second"

# Middleware registration
MIDDLEWARE = [
    "middleware.rate_limit.RateLimitMiddleware",
    "middleware.logging.LoggingMiddleware",
    "middleware.cors.CORSMiddleware",
    "middleware.request_id.RequestIDMiddleware",
]

Generate SSL Certificates

Creates SSL certificates in certs/ directory:

  • certs/cert.pem - SSL certificate
  • certs/key.pem - Private key

Commands

Command Description
init [name] Initialize FastAPI project structure
ssl Generate self-signed SSL certificates
help Show available commands

manage.py Commands

After initializing a project, use manage.py for development tasks:

cd myproject

Run Development Server

python manage.py runserver                    # Default: 127.0.0.1:8000
python manage.py runserver --host 0.0.0.0     # Bind to all interfaces
python manage.py runserver --port 8080        # Custom port
python manage.py runserver --noreload         # Disable auto-reload

Database Migration

python manage.py migrate                      # Create database tables

Show Help

python manage.py help

Project Structure

Generated projects follow a clean architecture:

myproject/
├── api/          # API route handlers
├── core/         # Core application settings
├── database/     # Database models and connections
├── middleware/   # Custom middleware (CORS, Logging, Rate Limit, etc.)
├── schema/       # Pydantic schemas
├── service/      # Business logic
├── views/        # View controllers
├── main.py       # FastAPI application entry point
├── manage.py     # Django-like management script
└── settings.py   # Centralized configuration

Requirements

  • Python 3.10+
  • OpenSSL (for SSL certificate generation)

Contributing

Contributions are welcome! Please read our Contributing Guide.

Security

For security issues, please read our Security Policy.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for fastgram-cli 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastgram-cli 0.1.9
File Size Uploaded Provenance Actions
fastgram_cli-0.1.9.tar.gz 53.5 kB Without provenance Details for fastgram_cli-0.1.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastgram-cli 0.1.9
File Interpreter ABI Platform Actions
fastgram_cli-0.1.9-py3-none-any.whl Python 3 none any Details for fastgram_cli-0.1.9-py3-none-any.whl

Total release size: 66.0 kB

Release files / fastgram_cli-0.1.9.tar.gz

Download URL fastgram_cli-0.1.9.tar.gz
Size 53.5 kB
Tags Source
SHA-256 checksum
How to use checksums
34f91c3ae58305e8b7b596e7cd80ae3be2629e82974a1d5545681f22ed249ce4
BLAKE2b-256 checksum
How to use checksums
a20c529b3b8a56b68993895906f02e88546bf30193dd1559362ff20c57869ea9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / fastgram_cli-0.1.9-py3-none-any.whl

Download URL fastgram_cli-0.1.9-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
133d072e0c57949424d539cd8b3a388e6c8a7022c9bbac56728c19abd76847f0
BLAKE2b-256 checksum
How to use checksums
2c7002127b7555f4f085c3feabc4a50f59015bc6fc309a7da95f408155c4ed1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for fastgram-cli 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page