Constraints
- Keep provider credentials and system prompts on the backend.
- Deploy a Next.js client and Python service together from one repository.
- Persist chat locally without adding a hosted user database.
- Bound provider requests and fail clearly when upstream services do not respond.
Architecture
- 01
Browser
The user selects controls and submits a prompt.
- 02
Next.js application
The client renders the workflow and sends a typed request.
- 03
FastAPI service
The Python service owns the model-facing endpoint.
- 04
Validation
Pydantic validates models, payload size, and request shape.
- 05
Prompt boundary
Backend-owned prompt construction keeps system behavior off the client.
- 06
OpenRouter
The service routes the request through an OpenAI-compatible client.
- 07
Model provider
The selected free model produces a response within a timeout.
- 08
Response
The API returns the answer and exact model used.
- 09
Browser persistence
sql.js stores chat history in browser SQLite.
- 10
Analytics and monitoring
Vercel Analytics and Speed Insights observe the web experience.
Data and models
Pretendo routes a validated list of free OpenRouter models. The public repository uses Next.js 16, React 19, TypeScript, FastAPI, Pydantic, Python 3.12, an OpenAI-compatible client, and sql.js.
Key engineering decisions
Backend-owned model boundary
Local-first persistence
Return the resolved model
Evaluation methodology
The repository includes focused API tests, web tests, TypeScript checks, and production builds. This project demonstrates validated boundaries and failure handling; it does not claim model-quality benchmark results.
Results
- Deployed as a Next.js and FastAPI multi-service application on Vercel.
- Implements validated free-model selection and returns the resolved model with each reply.
- Includes browser SQLite history, analytics, automated API checks, web tests, type checks, and build checks.
Failure modes
- The selected upstream model can be unavailable or time out.
- A provider can reject a request or return an unexpected error shape.
- Browser storage can be cleared or unavailable.
- An invalid or stale model selection can reach the API.
Limitations
- The application has no meaningful public-usage or customer-adoption metric.
- Browser-local persistence does not synchronize across devices.
- The model catalog and availability depend on OpenRouter.
- The deployment uses Vercel’s experimental Services setup.
Reliability and security controls
- CORS allowlists and backend-held credentials.
- Pydantic request and response validation.
- Backend-owned system prompts and validated model selection.
- Request limits and provider timeouts.
- Focused API and web tests plus TypeScript and production-build checks.
Latency and cost observations
The application uses free OpenRouter model selection, but provider latency varies by model and availability. No stable latency or cost figures are published.
Deployment
The monorepo deploys the Next.js client and FastAPI service together through Vercel Services, with Analytics and Speed Insights on the web application.
What I would improve next
- Add explicit provider retry and fallback behavior where it improves clarity.
- Add optional synchronized persistence without weakening the local-first default.
- Expand request-level observability around provider failures.
- Evaluate model-routing behavior against a defined prompt set.
Inspect the work
