# Pyagenity API
A Python API framework with GraphQL support, task management, and CLI tools for building scalable web applications.
## Installation
### From PyPI (Recommended)
```bash
pip install pyagenity-api
```
### From Source
```bash
git clone https://github.com/Iamsdt/pyagenity-api.git
cd pyagenity-api
pip install -e .
```
## Quick Start
1. **Initialize a new project:**
```bash
pag init
```
2. **Start the API server with default configuration:**
```bash
pag api
```
3. **Start the API server with custom configuration:**
```bash
pag api --config custom-config.json
```
4. **Start the API server on different host/port:**
```bash
pag api --host 127.0.0.1 --port 9000
```
## CLI Commands
The `pag` command provides the following subcommands:
### `pag api`
Start the Pyagenity API server.
**Options:**
- `--config TEXT`: Path to config file (default: pyagenity.json)
- `--host TEXT`: Host to run the API on (default: 0.0.0.0)
- `--port INTEGER`: Port to run the API on (default: 8000)
- `--reload/--no-reload`: Enable auto-reload (default: enabled)
**Examples:**
```bash
# Start with default configuration
pag api
# Start with custom config file
pag api --config my-config.json
# Start on localhost only, port 9000
pag api --host 127.0.0.1 --port 9000
# Start without auto-reload
pag api --no-reload
```
### `pag init`
Initialize a new config file with default settings.
**Options:**
- `--output TEXT`: Output config file path (default: pyagenity.json)
- `--force`: Overwrite existing config file
**Examples:**
```bash
# Create default config
pag init
# Create config with custom name
pag init --output custom-config.json
# Overwrite existing config
pag init --force
```
### `pag version`
Show the CLI version information.
```bash
pag version
```
## Configuration
The configuration file (`pyagenity.json`) supports the following structure:
```json
{
"app": {
"name": "Pyagenity API",
"version": "1.0.0",
"debug": true
},
"server": {
"host": "0.0.0.0",
"port": 8000,
"workers": 1
},
"database": {
"url": "sqlite://./pyagenity.db"
},
"redis": {
"url": "redis://localhost:6379"
}
}
```
## File Resolution
The CLI automatically finds your config file in this order:
1. Absolute path (if provided with `--config`)
2. Current working directory
3. Relative to script location (for development)
4. Package installation directory (fallback)
## Project Structure
```
pyagenity-api/
├── pyagenity_api/ # Main package directory
│ ├── __init__.py # Package initialization
│ ├── cli.py # CLI module
│ └── src/ # Source code
│ └── app/ # FastAPI application
│ ├── main.py # FastAPI app entry point
│ ├── core/ # Core functionality
│ ├── routers/ # API routes
│ └── tasks/ # Background tasks
├── graph/ # Graph implementation
├── migrations/ # Database migrations
├── scripts/ # Utility scripts
├── docs/ # Documentation
├── pyproject.toml # Project configuration
├── requirements.txt # Dependencies
├── Makefile # Development commands
├── MANIFEST.in # Package manifest
└── README.md # This file
```
## Features
- **FastAPI Backend**: High-performance async web framework
- **GraphQL Support**: Built-in GraphQL API with Strawberry
- **Task Management**: Background task processing with Taskiq
- **CLI Tools**: Command-line interface for easy management
- **Database Integration**: Support for multiple databases via Tortoise ORM
- **Redis Integration**: Caching and session management
- **Authentication**: Firebase authentication support
- **Development Tools**: Pre-commit hooks, linting, testing
- **Docker Support**: Container deployment ready
## Setup
### Prerequisites
- Python 3.x
- pip
- [Any other prerequisites]
### Installation
1. Clone the repository:
```bash
git clone https://github.com/10XScale-in/backend-base.git
```
2. Create a virtual environment and activate:
```bash
python -m venv venv
source venv/bin/activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
## Database
### Database Configuration
The database configuration is located in `src/app/db/setup_database.py`.
### Database Migration
We use Aerich for database migrations. Follow these steps to manage your database:
1. Initialize the database initially:
```bash
aerich init -t src.app.db.setup_database.TORTOISE_ORM
```
2. Create initial database schema:
```bash
aerich init-db
```
3. Generate migration files:
```bash
aerich migrate
```
4. Apply migrations:
```bash
aerich upgrade
```
5. Revert migrations (if needed):
```bash
aerich downgrade
```
## Running the Application
### Command Line
To run the FastAPI application using Uvicorn:
1. Start the application:
```bash
uvicorn src.app.main:app --reload
```
2. You can also run the debugger.
### VS Code
Add the following configuration to your `.vscode/launch.json` file:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"src.app.main:app",
"--host",
"localhost",
"--port",
"8880"
],
"jinja": true,
"justMyCode": true
}
]
}
```
Then you can run and debug the application using the VS Code debugger.
### Run the Broker
1. Run the taskiq worker
```taskiq worker src.app.worker:broker -fsd -tp 'src/**/*_tasks.py' --reload
```
## Development
### Using the Makefile
The project includes a comprehensive Makefile for development tasks:
```bash
# Show all available commands
make help
# Install package in development mode
make dev-install
# Run tests
make test
# Test CLI installation
make test-cli
# Format code
make format
# Run linting
make lint
# Run all checks (lint + test)
make check
# Clean build artifacts
make clean
# Build package
make build
# Publish to TestPyPI
make publish-test
# Publish to PyPI
make publish
# Complete release workflow
make release
```
### Manual Development Setup
If you prefer manual setup:
1. **Clone the repository:**
```bash
git clone https://github.com/Iamsdt/pyagenity-api.git
cd pyagenity-api
```
2. **Create a virtual environment:**
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
3. **Install in development mode:**
```bash
pip install -e .
```
4. **Install development dependencies:**
```bash
pip install pytest pytest-cov ruff mypy pre-commit
```
5. **Set up pre-commit hooks:**
```bash
pre-commit install
```
### Testing
Run tests using pytest:
```bash
pytest src/tests/ -v --cov=pyagenity_api
```
Or use the Makefile:
```bash
make test
```
### Publishing to PyPI
1. **Test your package locally:**
```bash
make test-cli
```
2. **Publish to TestPyPI first:**
```bash
make publish-test
```
3. **If everything works, publish to PyPI:**
```bash
make publish
```
# Resources
https://keda.sh/
Get all the fixers
pytest --fixtures
https://www.tutorialspoint.com/pytest/pytest_run_tests_in_parallel.html
Raw data
{
"_id": null,
"home_page": null,
"name": "pyagenity-api",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Shudipto Trafder <iamsdt@duck.com>",
"keywords": "api, fastapi, graphql, task-management, cli",
"author": null,
"author_email": "Shudipto Trafder <iamsdt@duck.com>",
"download_url": "https://files.pythonhosted.org/packages/9b/84/babf66fe715e0c1a1a2cbd403e679d6ae423caa171f6d214da530490c541/pyagenity_api-1.0.0.tar.gz",
"platform": null,
"description": "\n# Pyagenity API\n\nA Python API framework with GraphQL support, task management, and CLI tools for building scalable web applications.\n\n## Installation\n\n### From PyPI (Recommended)\n```bash\npip install pyagenity-api\n```\n\n### From Source\n```bash\ngit clone https://github.com/Iamsdt/pyagenity-api.git\ncd pyagenity-api\npip install -e .\n```\n\n## Quick Start\n\n1. **Initialize a new project:**\n```bash\npag init\n```\n\n2. **Start the API server with default configuration:**\n```bash\npag api\n```\n\n3. **Start the API server with custom configuration:**\n```bash\npag api --config custom-config.json\n```\n\n4. **Start the API server on different host/port:**\n```bash\npag api --host 127.0.0.1 --port 9000\n```\n\n## CLI Commands\n\nThe `pag` command provides the following subcommands:\n\n### `pag api`\nStart the Pyagenity API server.\n\n**Options:**\n- `--config TEXT`: Path to config file (default: pyagenity.json)\n- `--host TEXT`: Host to run the API on (default: 0.0.0.0)\n- `--port INTEGER`: Port to run the API on (default: 8000)\n- `--reload/--no-reload`: Enable auto-reload (default: enabled)\n\n**Examples:**\n```bash\n# Start with default configuration\npag api\n\n# Start with custom config file\npag api --config my-config.json\n\n# Start on localhost only, port 9000\npag api --host 127.0.0.1 --port 9000\n\n# Start without auto-reload\npag api --no-reload\n```\n\n### `pag init`\nInitialize a new config file with default settings.\n\n**Options:**\n- `--output TEXT`: Output config file path (default: pyagenity.json)\n- `--force`: Overwrite existing config file\n\n**Examples:**\n```bash\n# Create default config\npag init\n\n# Create config with custom name\npag init --output custom-config.json\n\n# Overwrite existing config\npag init --force\n```\n\n### `pag version`\nShow the CLI version information.\n\n```bash\npag version\n```\n\n## Configuration\n\nThe configuration file (`pyagenity.json`) supports the following structure:\n\n```json\n{\n \"app\": {\n \"name\": \"Pyagenity API\",\n \"version\": \"1.0.0\",\n \"debug\": true\n },\n \"server\": {\n \"host\": \"0.0.0.0\",\n \"port\": 8000,\n \"workers\": 1\n },\n \"database\": {\n \"url\": \"sqlite://./pyagenity.db\"\n },\n \"redis\": {\n \"url\": \"redis://localhost:6379\"\n }\n}\n```\n\n## File Resolution\n\nThe CLI automatically finds your config file in this order:\n1. Absolute path (if provided with `--config`)\n2. Current working directory\n3. Relative to script location (for development)\n4. Package installation directory (fallback)\n\n## Project Structure\n\n```\npyagenity-api/\n\u251c\u2500\u2500 pyagenity_api/ # Main package directory\n\u2502 \u251c\u2500\u2500 __init__.py # Package initialization\n\u2502 \u251c\u2500\u2500 cli.py # CLI module\n\u2502 \u2514\u2500\u2500 src/ # Source code\n\u2502 \u2514\u2500\u2500 app/ # FastAPI application\n\u2502 \u251c\u2500\u2500 main.py # FastAPI app entry point\n\u2502 \u251c\u2500\u2500 core/ # Core functionality\n\u2502 \u251c\u2500\u2500 routers/ # API routes\n\u2502 \u2514\u2500\u2500 tasks/ # Background tasks\n\u251c\u2500\u2500 graph/ # Graph implementation\n\u251c\u2500\u2500 migrations/ # Database migrations\n\u251c\u2500\u2500 scripts/ # Utility scripts\n\u251c\u2500\u2500 docs/ # Documentation\n\u251c\u2500\u2500 pyproject.toml # Project configuration\n\u251c\u2500\u2500 requirements.txt # Dependencies\n\u251c\u2500\u2500 Makefile # Development commands\n\u251c\u2500\u2500 MANIFEST.in # Package manifest\n\u2514\u2500\u2500 README.md # This file\n```\n\n## Features\n\n- **FastAPI Backend**: High-performance async web framework\n- **GraphQL Support**: Built-in GraphQL API with Strawberry\n- **Task Management**: Background task processing with Taskiq\n- **CLI Tools**: Command-line interface for easy management\n- **Database Integration**: Support for multiple databases via Tortoise ORM\n- **Redis Integration**: Caching and session management\n- **Authentication**: Firebase authentication support\n- **Development Tools**: Pre-commit hooks, linting, testing\n- **Docker Support**: Container deployment ready\n\n## Setup\n\n### Prerequisites\n- Python 3.x\n- pip\n- [Any other prerequisites]\n\n### Installation\n1. Clone the repository:\n ```bash\n git clone https://github.com/10XScale-in/backend-base.git\n ```\n\n2. Create a virtual environment and activate:\n ```bash\n python -m venv venv\n source venv/bin/activate\n ```\n\n3. Install dependencies:\n ```bash\n pip install -r requirements.txt\n ```\n\n## Database\n\n### Database Configuration\nThe database configuration is located in `src/app/db/setup_database.py`.\n\n### Database Migration\nWe use Aerich for database migrations. Follow these steps to manage your database:\n\n1. Initialize the database initially:\n ```bash\n aerich init -t src.app.db.setup_database.TORTOISE_ORM\n ```\n\n2. Create initial database schema:\n ```bash\n aerich init-db\n ```\n\n3. Generate migration files:\n ```bash\n aerich migrate\n ```\n\n4. Apply migrations:\n ```bash\n aerich upgrade\n ```\n\n5. Revert migrations (if needed):\n ```bash\n aerich downgrade\n ```\n\n## Running the Application\n\n### Command Line\nTo run the FastAPI application using Uvicorn:\n1. Start the application:\n ```bash\n uvicorn src.app.main:app --reload\n ```\n\n2. You can also run the debugger.\n\n### VS Code\nAdd the following configuration to your `.vscode/launch.json` file:\n```json\n{\n \"version\": \"0.2.0\",\n \"configurations\": [\n {\n \"name\": \"Python: FastAPI\",\n \"type\": \"python\",\n \"request\": \"launch\",\n \"module\": \"uvicorn\",\n \"args\": [\n \"src.app.main:app\",\n \"--host\",\n \"localhost\",\n \"--port\",\n \"8880\"\n ],\n \"jinja\": true,\n \"justMyCode\": true\n }\n ]\n}\n```\nThen you can run and debug the application using the VS Code debugger.\n### Run the Broker\n1. Run the taskiq worker\n```taskiq worker src.app.worker:broker -fsd -tp 'src/**/*_tasks.py' --reload\n```\n## Development\n\n### Using the Makefile\n\nThe project includes a comprehensive Makefile for development tasks:\n\n```bash\n# Show all available commands\nmake help\n\n# Install package in development mode\nmake dev-install\n\n# Run tests\nmake test\n\n# Test CLI installation\nmake test-cli\n\n# Format code\nmake format\n\n# Run linting\nmake lint\n\n# Run all checks (lint + test)\nmake check\n\n# Clean build artifacts\nmake clean\n\n# Build package\nmake build\n\n# Publish to TestPyPI\nmake publish-test\n\n# Publish to PyPI\nmake publish\n\n# Complete release workflow\nmake release\n```\n\n### Manual Development Setup\n\nIf you prefer manual setup:\n\n1. **Clone the repository:**\n ```bash\n git clone https://github.com/Iamsdt/pyagenity-api.git\n cd pyagenity-api\n ```\n\n2. **Create a virtual environment:**\n ```bash\n python -m venv .venv\n source .venv/bin/activate # On Windows: .venv\\Scripts\\activate\n ```\n\n3. **Install in development mode:**\n ```bash\n pip install -e .\n ```\n\n4. **Install development dependencies:**\n ```bash\n pip install pytest pytest-cov ruff mypy pre-commit\n ```\n\n5. **Set up pre-commit hooks:**\n ```bash\n pre-commit install\n ```\n\n### Testing\n\nRun tests using pytest:\n```bash\npytest src/tests/ -v --cov=pyagenity_api\n```\n\nOr use the Makefile:\n```bash\nmake test\n```\n\n### Publishing to PyPI\n\n1. **Test your package locally:**\n ```bash\n make test-cli\n ```\n\n2. **Publish to TestPyPI first:**\n ```bash\n make publish-test\n ```\n\n3. **If everything works, publish to PyPI:**\n ```bash\n make publish\n ```\n\n\n# Resources\nhttps://keda.sh/\nGet all the fixers\npytest --fixtures\nhttps://www.tutorialspoint.com/pytest/pytest_run_tests_in_parallel.html\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python API framework with GraphQL support and task management",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://pyagenity-api.readthedocs.io/",
"Homepage": "https://github.com/Iamsdt/pyagenity-api",
"Issues": "https://github.com/Iamsdt/pyagenity-api/issues",
"Repository": "https://github.com/Iamsdt/pyagenity-api"
},
"split_keywords": [
"api",
" fastapi",
" graphql",
" task-management",
" cli"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5fd187673ca104ecd16d5f272e7c379be192d922909596f4de49011534abc2a1",
"md5": "118704b426e6e3939ce3dbd3efa27665",
"sha256": "39ab369a1c499f4c0410613931b266c9526d06f4dbf63b402507712c430e6860"
},
"downloads": -1,
"filename": "pyagenity_api-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "118704b426e6e3939ce3dbd3efa27665",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 111184,
"upload_time": "2025-09-12T05:36:54",
"upload_time_iso_8601": "2025-09-12T05:36:54.101674Z",
"url": "https://files.pythonhosted.org/packages/5f/d1/87673ca104ecd16d5f272e7c379be192d922909596f4de49011534abc2a1/pyagenity_api-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9b84babf66fe715e0c1a1a2cbd403e679d6ae423caa171f6d214da530490c541",
"md5": "b386d9f01edaa70807c3c958de0f6b18",
"sha256": "25d95c63d13b6dc38951241b47b477bf69c01630f56e8ea33b617fcd25a69e96"
},
"downloads": -1,
"filename": "pyagenity_api-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "b386d9f01edaa70807c3c958de0f6b18",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 80595,
"upload_time": "2025-09-12T05:36:57",
"upload_time_iso_8601": "2025-09-12T05:36:57.208728Z",
"url": "https://files.pythonhosted.org/packages/9b/84/babf66fe715e0c1a1a2cbd403e679d6ae423caa171f6d214da530490c541/pyagenity_api-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-12 05:36:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Iamsdt",
"github_project": "pyagenity-api",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "aerich",
"specs": [
[
"==",
"0.7.2"
]
]
},
{
"name": "aiosmtplib",
"specs": [
[
"==",
"2.0.2"
]
]
},
{
"name": "aiofiles",
"specs": [
[
"==",
"24.1.0"
]
]
},
{
"name": "asyncpg",
"specs": []
},
{
"name": "fastapi",
"specs": []
},
{
"name": "firebase-admin",
"specs": [
[
"==",
"6.5.0"
]
]
},
{
"name": "gunicorn",
"specs": [
[
"==",
"23.0.0"
]
]
},
{
"name": "httpx",
"specs": [
[
"==",
"0.27.0"
]
]
},
{
"name": "injector",
"specs": [
[
"==",
"0.22.0"
]
]
},
{
"name": "lib",
"specs": [
[
"==",
"4.0.0"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "mkdocs-gen-files",
"specs": [
[
"==",
"0.5.0"
]
]
},
{
"name": "mkdocstrings",
"specs": [
[
"==",
"0.25.2"
]
]
},
{
"name": "mypy-extensions",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "oauth2client",
"specs": [
[
"==",
"4.1.3"
]
]
},
{
"name": "orjson",
"specs": []
},
{
"name": "pre-commit",
"specs": [
[
"==",
"3.8.0"
]
]
},
{
"name": "python-multipart",
"specs": [
[
"==",
"0.0.19"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.8.2"
]
]
},
{
"name": "pydantic-settings",
"specs": [
[
"==",
"2.3.4"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"8.3.2"
]
]
},
{
"name": "pytest-env",
"specs": [
[
"==",
"1.1.3"
]
]
},
{
"name": "redis",
"specs": [
[
"==",
"5.0.7"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
},
{
"name": "ruff",
"specs": [
[
"==",
"0.5.2"
]
]
},
{
"name": "sentry-sdk",
"specs": [
[
"==",
"2.10.0"
]
]
},
{
"name": "snowflakekit",
"specs": []
},
{
"name": "starlette",
"specs": [
[
"==",
"0.40.0"
]
]
},
{
"name": "strawberry-graphql",
"specs": [
[
"==",
"0.257.0"
]
]
},
{
"name": "taskiq",
"specs": [
[
"==",
"0.11.10"
]
]
},
{
"name": "taskiq-redis",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "tortoise",
"specs": [
[
"==",
"0.1.1"
]
]
},
{
"name": "tortoise-orm",
"specs": [
[
"==",
"0.22.1"
]
]
},
{
"name": "uvicorn",
"specs": [
[
"==",
"0.30.1"
]
]
}
],
"lcname": "pyagenity-api"
}