How unagi22/rcat works
What this project is (type + purpose)
From the file tree + README, this is a single-page frontend web app built with React + TypeScript + Vite. It has no separate backend service in the repository. Instead, it calls the Google Gemini API directly from the client using an API key provided via .env.local.
The app has two primary UI modes/roles indicated by components:
• components/AdminView.tsx
• components/CustomerView.tsx
It also has two “service” modules:
• services/gemini.ts → external AI API integration
• services/storage.ts → client-side persistence (likely localStorage / indexedDB / in-memory abstraction)
So the architecture is essentially: Browser UI → App logic → (Gemini API + local persistence).
App entry + composition
• index.html → Vite HTML entry template
• index.tsx → React root render (mounts <App />)
• App.tsx → top-level orchestrator: routing/conditional rendering between Admin vs Customer, shared state, and service usage
UI “feature slices”
• components/AdminView.tsx → Admin-facing flows and UI
• components/CustomerView.tsx → Customer-facing flows and UI
Domain/config/types
• constants.ts → app-level configuration/flags/prompts/defaults
Integration layer (“services”)
• services/gemini.ts → the “AI Client” adapter wrapping Gemini SDK/HTTP calls
• services/storage.ts → persistence adapter (client storage abstraction)
Tooling/build (usually a separate “build pipeline” lane
• vite.config.ts, tsconfig.json, package.json → build/test/dev tooling and dependency graph
User (Actor)
• Optionally split into Admin User and Customer User since there are distinct views.
Browser (Execution Environment)
• Contains the React SPA.
React SPA (Container)
• Sub-components inside it:
• App.tsx (composition + state)
• AdminView (UI feature)
• CustomerView (UI feature)
• Gemini Service Adapter (services/gemini.ts)
• Storage Service Adapter (services/storage.ts)
• Constants/Types (constants.ts, types.ts)
External Service: Google Gemini API
• Called over HTTPS.
Client Storage
• LocalStorage/IndexedDB (whatever storage.ts uses). Even if it’s “not a server,” it’s a distinct runtime dependency.
• Admin User → Browser → React SPA
• Customer User → Browser → React SPA
• Views/App → services/gemini.ts → Gemini API
• Views/App → services/storage.ts → Browser Storage
• .env.local (GEMINI_API_KEY) → services/gemini.ts (show as configuration injection at build/runtime)
Important note to capture explicitly:
This explains how code becomes a deployed artifact.
• Developer workstation
• Node.js + npm
• Vite dev server (npm run dev)
• Vite build output (static assets: HTML/CSS/JS bundle)
• Hosting/CDN (where the static site is deployed; if unknown, label generically: “Static hosting (e.g., Cloudflare Pages / Vercel / Netlify)”)
• Developer → npm install (package.json dependencies)
• Developer → npm run dev → Vite dev server → Browser
• CI/CD (optional generic) → vite build → static hosting → end users
Architectural patterns/design principles to highlight
Based on file layout:
• Separation of concerns:
• UI components in components/
• External integrations behind services/
• Shared constants/types centralized
• Adapter pattern for integrations:
• services/gemini.ts abstracts Gemini calls
• services/storage.ts abstracts persistence
• Role-based UI slices:
• Admin vs Customer flows split into separate components
Of these explicitly:
Clear labels
Use filenames in parentheses to keep it grounded:
• “Gemini Client Adapter (services/gemini.ts)"
• “Admin View (components/AdminView.tsx)”
• “App Shell (App.tsx)”
• “Prompt / context → Generate content”
• “AI response → Render UI”
• “Save/Load session state / settings”
Left: Actors
• Admin
• Customer
Middle: Browser boundary
• React SPA
• App.tsx
• AdminView
• CustomerView
• services/gemini.ts
• services/storage.ts
Bottom (inside browser): Browser Storage
• Local storage / IndexedDB