brinjal

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

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

Data Models

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:

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.