Back to Projects
AI Application Development · Asynchronous Workflows

GlitrAI Mini Content Engine — Multi-Step LLM Workflow

A backend service demonstrating asynchronous job orchestration for multi-stage LLM text generation and AI image synthesis, with persistent job lifecycle tracking and fallback reliability.

PythonFastAPIGroq LLMPollinations AIPostgreSQL / SQLiteAsyncIOPydantic
View on GitHub

01 / Overview

A backend service demonstrating asynchronous job orchestration for multi-stage LLM text generation and AI image synthesis, with persistent job lifecycle tracking and fallback reliability.

02 / The Problem

Monolithic single-shot AI prompts frequently fail or produce unstructured responses. Complex multi-modal generation (structured marketing copy paired with tailored visual assets) requires decoupled pipelines with status polling.

03 / My Solution & Architecture

Engineered with FastAPI and AsyncIO. Manages generation jobs through distinct states (PENDING, PROCESSING, COMPLETED, FAILED) with database persistence. Stage 1 generates structured topic outlines via Groq API; Stage 2 distills visual prompts; Stage 3 orchestrates image synthesis with retry logic.

Key Engineering Decisions & Trade-Offs

FastAPI BackgroundTasks with Persistent State Machine

Long-running AI model synthesis must never block HTTP threads. Immediate return of a Job UUID with client status polling delivers an optimal user experience.

Decoupled Two-Stage Prompt Distillation

Separating marketing copy generation from visual prompt generation allows tailored optimization for both LLM text reasoning and diffusion image synthesis.

Automatic Fallback Retry Logic

External AI endpoints frequently experience transient rate limits or 503 errors. Built-in exponential backoff and fallback endpoints ensure high pipeline resilience.

04 / Technologies Used

PythonFastAPIGroq LLMPollinations AIPostgreSQL / SQLiteAsyncIOPydantic

Every technology in this stack was chosen for direct architectural fitness, verifiable benchmarking ability, and clean maintainability in a production or research setting.

05 / How It Works & Interactive Visualizer

Here is a breakdown of how the system functions in practice:

  • Asynchronous job orchestration engine with UUID job tracking.
  • Multi-stage generation workflow (copy writing + visual prompt extraction + image synthesis).
  • Persistent job status database schema with Pydantic serialization.
  • Automated rate-limit retry with provider fallback.
  • OpenAPI interactive Swagger documentation.

Interactive Technical Visualizer

How to interact: Use the controls above to trigger live states, test inputs, and observe system data flow directly in your browser.

06 / Results & Verified Findings

  • Decoupled multi-stage generation architecture with deterministic job polling.
  • Zero worker starvation: AsyncIO event loop processes API queries while generation tasks run.
  • Complete resilience against rate limits with structured error codes and descriptive feedback.

07 / What I Learned & Direct Contributions

Key engineering responsibilities and lessons gained during this project:

  • Architected non-blocking asynchronous job pipeline in FastAPI handling concurrent generation requests.
  • Engineered robust error-handling and fallback retry mechanisms for external AI model endpoints.
  • Designed SQLite/PostgreSQL schema for persistent job status, input prompts, and generated output URLs.
  • Implemented clean OpenAPI documentation with typed Pydantic request/response models.

08 / Future Improvements

Currently uses in-process AsyncIO tasks suitable for small-to-medium loads; Redis and Celery worker pools are planned for high-concurrency production deployments.

Email copied to clipboard