LemonAi.Application (lemon_ai v0.1.0)

View Source

OTP Application for the AI module.

Supervision Tree

  • LemonAi.Supervisor (one_for_one)
    • LemonAi.StreamTaskSupervisor - Dynamic supervisor for streaming tasks
    • LemonAi.RateLimiterRegistry - Registry for per-provider rate limiters
    • LemonAi.CircuitBreakerRegistry - Registry for per-provider circuit breakers
    • LemonAi.CallDispatcher - Central dispatcher for request coordination
    • LemonAi.ProviderSupervisor - Dynamic supervisor for per-provider services

Design Decisions

  • ProviderRegistry: Uses :persistent_term instead of a GenServer for crash resilience. Providers survive process restarts without re-registration.

  • StreamTaskSupervisor: A Task.Supervisor that manages all provider streaming tasks. This ensures proper lifecycle management and crash isolation.

  • Rate Limiting & Circuit Breaking: Per-provider GenServers registered via LemonAi.RateLimiterRegistry and LemonAi.CircuitBreakerRegistry. Started on-demand when providers are first used.

Summary

Functions

Register all built-in providers.

Functions

register_providers()

Register all built-in providers.

This is called during application startup and can also be called to re-register providers if needed.