Replace Synchronous HTTP Clients with Async Alternatives in AI Endpoints
@XPE-7 is already working on this.
Since Nov 17, 2025.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- fastapi, python, supabase
- Domain
- ai, api, backend, performance
Research direction
Start in ai.py by inventorying the AI endpoints and their synchronous requests calls, Supabase queries, and external Gemini and YouTube API calls. Trace how each route is declared and how responses are handled. Done means the endpoints use non-blocking alternatives and preserve their existing behavior while allowing concurrent requests without blocking the event loop.
Written by the indexing model from the issue text.
Description
Problem Description
The AI endpoints in ai.py currently use synchronous HTTP libraries (requests) within async FastAPI route handlers. This creates a performance bottleneck that significantly impacts the application's ability to handle concurrent requests efficiently.
Current problematic patterns:
# Blocking synchronous calls in async context
@router.get("/api/trending-niches")
def trending_niches(): # Should be async
resp = requests.get(url, timeout=10) # Blocks event loop
supabase.table("trending_niches").select("*").execute() # Also synchronous
Performance Impact
- Event Loop Blocking: Synchronous HTTP calls block the entire event loop, preventing other requests from being processed
- Thread Pool Exhaustion: FastAPI falls back to thread pool execution (limited to 40 threads by default)
- Poor Scalability: Application cannot efficiently handle concurrent AI requests
- Increased Latency: Context switching overhead between threads adds unnecessary delays
- Resource Waste: Thread pool threads remain blocked during network I/O operations
Expected Behavior
AI endpoints should use non-blocking, async HTTP clients that allow the event loop to process other requests while waiting for external API responses (Gemini AI, YouTube API, Supabase).
Additional Context
This enhancement aligns with FastAPI's async-first architecture and is crucial for production deployments. The change will unlock the application's true concurrent processing potential, especially important for AI endpoints that involve multiple external API calls.
- Dominant language
- TypeScript
- Stars
- 101
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/InPactAI
-
UI Bug: Low contrast makes input text unreadable in Sign Up and Login formPossibly taken @Abhik-Mudi claimed this 307 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AOSSIE-Org/InPactAI#218 ·
-
DOCS UPDATE: Fix incorrect .env file location in Backend Setup instructionsPossibly taken @PulkitDadwal claimed this 322 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
AOSSIE-Org/InPactAI#201 ·
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
AOSSIE-Org/InPactAI#314 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
AOSSIE-Org/InPactAI#312 ·
-
FEATURE REQUEST: Add API Pagination to Backend List EndpointsMay be free again @alphacoder-hash claimed this 193 days ago, and no pull request is open. Open
Difficulty 4/5 3-5 days Newbie friendliness 50/100
AOSSIE-Org/InPactAI#307 · 2 comments ·
All issues in AOSSIE-Org/InPactAI
Similar issues
-
[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inferencePossibly taken @alok-108 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/playwright#43263 ·
Maintainers usually reply within 1 day
-
bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 75/100
lingdojo/kana-dojo#32018 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
paperclipai/paperclip#15751 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BuilderIO/agent-native#7275 ·
Maintainers usually reply within 1 day