Metadata-Version: 2.4
Name: fastgram-cli
Version: 0.1.9
Summary: CLI tool for FastAPI - generate SSL certificates and more
Project-URL: Homepage, https://github.com/ndugram/fastgram-cli
Project-URL: Repository, https://github.com/ndugram/fastgram-cli
Project-URL: Issues, https://github.com/ndugram/fastgram-cli/issues
Author-email: NEFORCEO <n7for8572@gmail.com>
License: MIT
License-File: LICENSE
Keywords: certificate,cli,fastgram,ssl,tool
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: aiosqlite>=0.22.1
Requires-Dist: fastapi>=0.128.0
Requires-Dist: python-jose[cryptography]>=3.3.0
Requires-Dist: rich>=14.2.0
Requires-Dist: sqlalchemy>=2.0.45
Requires-Dist: typer>=0.21.1
Requires-Dist: uvicorn>=0.27.0
Description-Content-Type: text/markdown

# fastgram

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

![Python Version](https://img.shields.io/badge/python-3.10%2B-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![PyPI Version](https://img.shields.io/badge/pypi-latest-blue)

## 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

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

### From Source

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

## Quick Start

```bash
# 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

```bash
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:

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

### Rate Limit Settings

Configure rate limiting in `settings.py`:

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

## Settings

All configuration is centralized in `settings.py`:

```python

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:

```bash
cd myproject
```

### Run Development Server

```bash
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

```bash
python manage.py migrate                      # Create database tables
```

### Show Help

```bash
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](CONTRIBUTING.md).

## Security

For security issues, please read our [Security Policy](SECURITY.md).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.