Ritik Goyal - AI Developer | ContraWork by Ritik Goyal
Ritik Goyal

Ritik Goyal

Python & Django developer for web apps and APIs

New to Contra

Ritik is ready for their next project!

Cover image for Hit a classic Django trap
Hit a classic Django trap this week and figured it's worth sharing since so many people are running into it now. I was adding an LLM feature to a Django app. The AI call takes a few seconds, so naturally I made the view async so it doesn't block a worker while waiting. Wrote the async view, called the ORM like I always do, and boom: SynchronousOnlyOperation: You cannot call this from an async context. Turns out Django's ORM can't just be called normally inside async code. The classic sync API isn't safe in an event loop, so Django protects it and throws this error instead. The fix is simpler than most people think. Since Django 4.1 the ORM has async versions of everything, same names with an "a" prefix. So objects.get() becomes await objects.aget(), create() becomes acreate(), save() becomes asave(). For loops over querysets, async for works directly. And for old sync code or third party libraries you can't change, wrap them with sync_to_async(). Why this matters right now: everyone is bolting AI features onto Django apps, and LLM calls are exactly the slow I/O that async is made for. Which means a lot of devs who never touched async Django are suddenly hitting this error for the first time. One honest caveat: transactions still don't fully work in async mode, so if you need atomic blocks, keep that path sync and wrap it. Anyone else made the jump to async views yet, or still happily on WSGI?
0
64
Cover image for An AI-driven trading engine that
An AI-driven trading engine that analyzes 200-DMA breakouts and real-time market sentiment to generate long/short recommendations. It scans 1,500+ NSE stocks in under 2 seconds and uses generative AI to build option strategies, delivering event-driven trade signals end-to-end. I built the full Django backend, async APIs, and the signal-generation logic. Accomplishments and responsibilities: Built an AI-driven trading engine analyzing 200-DMA breakouts and market sentiment, generating long/short signals with ~70% directional accuracy — outperforming baseline strategies by 35%; Integrated generative-AI insights for automated option-strategy creation (spreads, straddles, condors), improving Sharpe ratio by 1.6× and cutting manual analysis time by 60%; Developed a Django backend with async APIs scanning 1,500+ NSE stocks in under 2 seconds, achieving 40% lower latency with event-driven alerts.
0
62
Cover image for An AI-powered news platform that
An AI-powered news platform that delivers concise, real-time AI-industry updates to 2,500+ active users. It scrapes and aggregates 500+ sources daily, removes duplicates, and uses generative-AI summarization to cut reading time significantly while surfacing the most relevant stories. I built the backend responsible for scraping, deduplication, and the LLM summarization pipeline.
0
63
Cover image for An enterprise SaaS platform that
An enterprise SaaS platform that lets FMCG companies plan, simulate, and optimize trade promotions. It gave 15+ enterprise clients the ability to model 200+ promotional scenarios monthly, run what-if analysis through a Promotion Calendar Optimizer and Simulator, and forecast the impact of promotions on revenue, volume, and profitability across $50M+ in annual promotional spend. My focus was architecting and building the Python/Django backend that powered the simulation and optimization engine.
0
64
Built a Python-powered automated trading tool that pulls live market data, runs technical analysis, and generates real-time trade signals. Features normalized comparison charts across multiple assets (Nifty, USD Index, Brent Crude, US 10Y Yield), a macro pressure table, correlation analysis, and a portfolio helper. Backend built in Python with automated data pipelines, live market feeds, and signal interpretation logic that flags bullish/bearish pressure. Clean, data-dense dashboard for fast decision-making. Tech: Python, Pandas, REST APIs, data automation, real-time charting.
1
88
Cover image for Spent an afternoon this week
Spent an afternoon this week chasing down why a client's order dashboard took around 2.5s to load. Turned out the page was firing 300+ database queries. Classic N+1 problem. Every order in the loop was making its own separate trip to the DB just to grab the customer and product. One line fixed it. select_related() tells Django to pull the related rows in a single JOIN instead of querying them one at a time. 312 queries down to 3. Page load went from 2.4s to 0.08s. The annoying part is this never shows up on small datasets in dev. It only bites you in production once the table grows. So now I always check the query count in Django Debug Toolbar before shipping any list view. What's the worst N+1 you've run into?
0
73