How navuluribalaji/model-inventory works
Project type and purpose
• This is a full-stack, single-page web application built on Next.js (App Router) whose purpose is to let users submit one prompt to multiple AI models (open-source via OpenRouter and proprietary via Google Gemini) and compare the responses side-by-side.
File structure
• Top-level:
• next.config.ts, tsconfig.json, tailwind.config.ts, package.json → Next.js + TypeScript + Tailwind CSS
• src/app → App Router entrypoints (layout.tsx, page.tsx, global CSS)
• src/components → UI layers split into “app” (page-specific components) and “ui” (reusable ShadCN UI primitives)
• src/ai → AI orchestration code (Genkit integration, flow definitions for generating requests, fetching model responses, summarization)
• src/lib → shared helpers (model definitions, OpenRouter wrapper, utils)
• src/hooks → React hooks (e.g., device detection, toast notifications)
• No dedicated database or backend folder—data persistence (chat history, API keys) happens in browser localStorage. Calls to AI providers are proxied via Genkit (serverless).
Extract insights from the README
• Key features: side-by-side comparison, performance metrics, persistent chat history, secure in-browser key storage, dynamic/interactive UI, JSON/table formatting, responsive design.
• Tech stack: Next.js, Genkit by Firebase, Tailwind CSS, ShadCN UI, Lucide React, TypeScript.
Main components & relationships
a. Frontend Browser (Client)
• React UI (src/app + src/components)
• CSS (Tailwind-generated)
• Local Storage (API keys, chat history)
b. Next.js Runtime (Serverless)
• App Router handles SSR/SSG and server components
• Routes invoke src/ai/genkit.ts → Genkit calls
c. Genkit (Firebase Gen AI Kit service)
• Orchestrates flows defined in src/ai/flows/*.ts
• Dispatches calls to external AI providers
d. External AI Providers
• OpenRouter endpoints (Llama 3, Mistral, etc.)
• Google Gemini API
e. Shared Code
• src/lib: abstracts model configs, HTTP wrappers, utilities
• src/hooks: state handling and UI utilities
Interactions:
1. User enters prompt → React component triggers an AI flow
2. Flow function (generate → get-model-responses → summarize) invoked via Genkit
3. Genkit forwards requests to each model endpoint
4. Responses return to Genkit → delivered back to Next.js route
5. UI renders response cards with timing metrics; chat saved to localStorage
Architectural patterns & design principles
• Component-based UI separation (app vs. UI primitives)
• Flow-based AI orchestration (modular “flows”)
• Thin serverless layer (Next.js + Genkit) — business logic in cloud functions
• Client-side persistence (no centralized database)
• API abstraction (src/lib/openrouter, genkit wrapper)
Detail without overthinking
• Break out src/ai/flows, src/lib, src/components/app, src/components/ui, and src/hooks as separate sub-components
• How configuration (next.config.ts, tailwind.config.ts) feeds into build/deploy
• Flow of data (prompt → multi-model calls → aggregated responses)
• No-server-DB choice (localStorage) and secure key management