First off, thank you for considering contributing to FastAPI Admin CLI! It's people like you that make this tool better for everyone. This document provides guidelines and instructions for contributing to this project.
- Introduction
- Project Structure
- Development Setup
- Development Workflow
- Adding New Commands
- Testing
- Documentation
- Pull Request Process
- Style Guidelines
- Code of Conduct
FastAPI Admin CLI is a Django-inspired command-line tool for managing FastAPI applications with a modular structure. It helps developers quickly scaffold and manage FastAPI projects with a clean, organized architecture.
The project aims to simplify common tasks in FastAPI development, such as:
- Creating new projects with a well-structured template
- Adding modular apps within a project
- Managing Docker containers
- Handling database migrations
- Providing easy access to shell and admin operations
Here's an overview of the project's structure:
fastapi-admin-cli/
├── fastapi_admin/ # Main package directory
│ ├── __init__.py # Package initialization with version
│ ├── cli.py # Main CLI entry point
│ ├── commands/ # CLI commands implementation
│ │ ├── __init__.py # Package initialization
│ │ ├── app.py # App creation command
│ │ ├── container.py # Container shell access
│ │ ├── docker.py # Docker management commands
│ │ ├── migrations.py # Database migration commands
│ │ ├── project.py # Project creation command
│ │ └── superuser.py # Superuser management
│ └── utils/ # Utility functions
│ ├── __init__.py # Package initialization
│ ├── docker_utils.py # Docker-related utilities
│ ├── file_utils.py # File operation utilities
│ └── template_utils.py # Template handling utilities
├── pyproject.toml # Project metadata and dependencies
├── README.md # Project documentation
├── record_demo.sh # Demo recording script
└── test_commands.sh # Test script for CLI commands
-
cli.py: The main entry point for the CLI tool. It registers all the command groups.
-
commands/: Each file in this directory implements a specific command group:
project.py: Creates new FastAPI projectsapp.py: Creates new apps within a projectdocker.py: Manages Docker containersmigrations.py: Handles database migrationscontainer.py: Provides shell access to containerssuperuser.py: Manages superuser creation
-
utils/: Contains utility functions used across the project:
template_utils.py: Handles fetching and processing templatesfile_utils.py: Provides file system operationsdocker_utils.py: Contains Docker-related utilities
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/fastapi-admin-cli.git
cd fastapi-admin-cli- Add the original repository as upstream:
git remote add upstream https://github.com/amal-babu-git/fastapi-admin-cli.git- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install the package in development mode:
pip install -e .- Install additional development dependencies:
pip install pytest black isort mypy- Create a branch for your feature or bugfix:
git checkout -b feature-or-fix-name- Make your changes and commit them:
git add .
git commit -m "Description of your changes"- Keep your branch updated with the upstream:
git fetch upstream
git rebase upstream/main- Push your changes to your fork:
git push origin feature-or-fix-name- Open a pull request on GitHub
To add a new command to the CLI:
- Create a new file in the
fastapi_admin/commands/directory, e.g.,mycommand.py. - Implement your command using
typer(see existing commands for examples). - Register your command in
cli.pyby adding:
from fastapi_admin.commands import mycommand
cli_app.add_typer(mycommand.app, name="mycommand")Example command structure:
import typer
from rich.console import Console
from rich.panel import Panel
app = typer.Typer(help="My new command description")
console = Console()
@app.callback(invoke_without_command=True)
def main(param: str):
"""Main command implementation"""
console.print(Panel(f"Executing command with {param}"))
# Command implementation hereYou can test your changes using the test_commands.sh script:
./test_commands.shIf you're adding new commands or features, consider adding tests for them to this script.
For interactive testing, use:
fastapi-admin your-command --your-parametersWhen adding new features, please update the documentation:
- Add your command to the command table in README.md
- Document your command's usage with examples
- If your command adds significant functionality, consider adding a section to README.md
- Ensure your code passes all tests and linting checks
- Update the documentation if needed
- Make sure your PR title and description clearly describe the changes
- Link any related issues in your PR description
- Be responsive to feedback and be willing to make requested changes
This project follows these style guidelines:
- Use Black for code formatting
- Use isort for import sorting
- Follow PEP 8 style guidelines
- Write clear docstrings for functions and classes
- Use type hints where appropriate
Before submitting a PR, format your code:
black fastapi_admin
isort fastapi_adminThank you for contributing to FastAPI Admin CLI! Your efforts help make this tool better for everyone.