
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).
Task class that can be extended for any type of taskpip install brinjal
# 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.
make devcurl -X POST http://localhost:8000/api/tasks/example_taskhttp://localhost:8000/api/tasks/test in your browserfrom 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")
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)
<!-- 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>
GET /api/tasks/queue - Get all tasksPOST /api/tasks/example_task - Create an example taskGET /api/tasks/{task_id}/stream - Stream task updates via SSEGET /api/tasks/static/{file} - Static files (TaskList.js, etc.)task_id, task_type, status, progress, img, heading, body# Run all tests
make test
# Run specific test suites
make test-task-manager
make test-example-task
# Run with coverage
make test-cov
make docs
make build
Brinjal is designed with separation of concerns in mind:
Task: Base class for all tasks with common functionalityTaskManager: Manages task execution and SSE event generationExampleTask: Concrete implementation demonstrating task patternsMIT License - see LICENSE.txt for details.