Bhai Thik Kor
Web Application, Apr to Aug 2026. Role: Full-Stack Developer.
Open the live appCode on GitHub
Bhai Thik Kor is a prompt optimiser: you type a rough request and it returns a ready-to-use prompt plus a model recommendation for three price tiers. It accepts Bangla and romanized Bangla input and answers in English. Prompts can be refined, shared through a compressed link, or reopened from local history.
Highlights
- Streams structured JSON with streamObject and refinements with streamText from the Vercel AI SDK
- Round-robin pool over Groq, Gemini and OpenRouter; a model that fails twice is cooled down for 2 minutes, shared across instances through Redis
- Upstash sliding-window limits (50 generations per day, 3 to 5 per minute on other routes) and Zod caps prompts at 4,000 characters
- URL reader rejects private and internal addresses, including DNS names that resolve to them
- Password-protected admin page with daily usage counters and provider health checks
- Chrome extension (Manifest V3, TypeScript, Shadow DOM) rewrites text in place with Alt+I and skips password, payment and OTP fields
Main challenge
The app runs on free-tier AI APIs, which hit rate limits often and sometimes fail after the response has already started. One provider going down could not take the app down, and a public endpoint had to be protected from abuse and from server-side request forgery through the URL reader.
How it was solved
Every route draws from a provider pool that rotates requests, cools down failing models in a Redis-shared circuit breaker, and pulls the current list of free OpenRouter models at runtime. A stream guard waits for the first real token before sending the response, so a provider that dies early still falls over to the next one. Upstash rate limits, Zod schemas and an IP-range check on fetched URLs guard the API, and a small admin page shows daily usage and provider health.
What shipped
- Live on Vercel; the public health endpoint reports the rate-limit store, generation, guided mode and refinement
- GitHub Actions runs lint, typecheck, Vitest unit tests, a production build and mocked Playwright tests on every push and pull request
- Unit tests cover the provider pool, stream guard, URL safety, request schemas and admin auth
- A companion Manifest V3 extension reuses the same API without storing any keys in the browser
Built with
- Next.js
- React
- TypeScript
- Vercel AI SDK
- Upstash Redis
- Zod
- Tailwind CSS
- Vitest
- Playwright
- Chrome Extension