A modern CLI tool for FastAPI developers - initialize projects with middleware, manage settings, and generate SSL certificates.
- 🚀 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
pip install git+https://github.com/ndugram/fastgram-cli.gitgit clone https://github.com/ndugram/fastgram-cli.git
cd fastgram
pip install -e .# 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/docsfastgram 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
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 |
Edit settings.py to modify middleware:
MIDDLEWARE = [
"middleware.rate_limit.RateLimitMiddleware",
"middleware.logging.LoggingMiddleware",
"middleware.cors.CORSMiddleware",
"middleware.request_id.RequestIDMiddleware",
]Configure rate limiting in settings.py:
RATE_LIMIT_LIMIT = "5/second" # Format: "<count>/<second|minute>"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",
]Creates SSL certificates in certs/ directory:
certs/cert.pem- SSL certificatecerts/key.pem- Private key
| Command | Description |
|---|---|
init [name] |
Initialize FastAPI project structure |
ssl |
Generate self-signed SSL certificates |
help |
Show available commands |
After initializing a project, use manage.py for development tasks:
cd myprojectpython 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-reloadpython manage.py migrate # Create database tablespython manage.py helpGenerated 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
- Python 3.10+
- OpenSSL (for SSL certificate generation)
Contributions are welcome! Please read our Contributing Guide.
For security issues, please read our Security Policy.
This project is licensed under the MIT License - see the LICENSE file for details.