Skip to main content

A generic, reusable task management system built with FastAPI and asyncio

Project description

Brinjal

A generic, reusable task management system built with FastAPI and asyncio. Brinjal provides a flexible foundation for building task-based applications with real-time progress updates via Server-Sent Events (SSE).

Features

  • Generic Task Management: Base Task class that can be extended for any type of task
  • Real-time Updates: Server-Sent Events (SSE) for live progress updates
  • Asynchronous Execution: Built on asyncio for high-performance task processing
  • Flexible Integration: No hardcoded prefixes - easily integrated into any FastAPI application
  • Web Components: Reusable frontend components for displaying tasks
  • Progress Tracking: Built-in progress monitoring and status updates

Quick Start

Installation

pip install brinjal

Running the Development Server

# Clone the repository
git clone https://github.com/sg-s/brinjal.git
cd brinjal

# Install dependencies
uv sync

# Run the development server
make dev

The server will start at http://localhost:8000.

End-to-End Testing

  1. Start the server: make dev
  2. Add a task: curl -X POST http://localhost:8000/api/tasks/example_task
  3. View the test page: Open http://localhost:8000/api/tasks/test in your browser
  4. Watch real-time updates: The task will appear and progress in real-time

Usage in Other Projects

Basic Integration

from fastapi import FastAPI
from brinjal.api.router import router as brinjal_router

app = FastAPI()

# Include brinjal with your desired prefix
app.include_router(brinjal_router, prefix="/api/tasks")

Advanced Integration with Custom Endpoints

from fastapi import APIRouter
from brinjal.api.router import router as brinjal_router
from brinjal.manager import task_manager

# Create your main router with the desired prefix
router = APIRouter(prefix="/api/tasks")

# Include all of brinjal's functionality
router.include_router(brinjal_router)

# Add your custom endpoints
@router.post("/custom_task")
async def custom_task():
    # Your custom logic here
    pass

# Include in your main app
app.include_router(router)

Frontend Integration

<!-- Load the TaskList component from your brinjal endpoint -->
<script src="/api/tasks/static/TaskList.js"></script>

<!-- Use the component -->
<task-list base_url="https://yourdomain.com"></task-list>

API Reference

Core Endpoints

  • GET /api/tasks/queue - Get all tasks
  • POST /api/tasks/example_task - Create an example task
  • GET /api/tasks/{task_id}/stream - Stream task updates via SSE
  • GET /api/tasks/static/{file} - Static files (TaskList.js, etc.)

Data Models

  • TaskUpdate: Generic task update model with task_id, task_type, status, progress, img, heading, body

Development

Running Tests

# Run all tests
make test

# Run specific test suites
make test-task-manager
make test-example-task

# Run with coverage
make test-cov

Building Documentation

make docs

Building the Package

make build

Architecture

Brinjal is designed with separation of concerns in mind:

  • Task: Base class for all tasks with common functionality
  • TaskManager: Manages task execution and SSE event generation
  • ExampleTask: Concrete implementation demonstrating task patterns
  • Router: FastAPI router with generic endpoints (no hardcoded prefixes)
  • Static Files: Web components and assets for frontend integration

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

MIT License - see LICENSE.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brinjal-0.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brinjal-0.2.0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file brinjal-0.2.0.tar.gz.

File metadata

  • Download URL: brinjal-0.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brinjal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 659c9c77278ef8905e5d0eaf7f3ea7b3aeb37ef16df77f97f83b151b904515f4
MD5 3e5fdde66f8cfe5375809da56e21d47d
BLAKE2b-256 993d47edc2a405f7cd5aa6fdd25ea55f303b8011135cbfb0126e7319546bb449

See more details on using hashes here.

Provenance

The following attestation bundles were made for brinjal-0.2.0.tar.gz:

Publisher: pypi.yml on sg-s/brinjal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brinjal-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: brinjal-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brinjal-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0dcb98f3f63fbec0c9573ab9f2221a7c3b044eaa0de4fd4db021ccde8c49564
MD5 be3085abb0e13479b28f58e6274a034f
BLAKE2b-256 8f3b2bb8df03413aa65dee5089a423bfd0b427f7f110378c04e5adae37608487

See more details on using hashes here.

Provenance

The following attestation bundles were made for brinjal-0.2.0-py3-none-any.whl:

Publisher: pypi.yml on sg-s/brinjal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page