How oumelab/demo-ai-review-analysis-app works
Project type and purpose
• This is a front-end only, single-page web application (built with Vite + React + Bun), deployed as a static site on Cloudflare Pages.
• Its purpose is to fetch user reviews from Google Sheets, display them, then call the Gemini AI API to generate summaries.
File structure
• Top-level files: index.html, vite.config.ts, package.json, bun.lock → static front-end build.
• /public → static assets (images, favicon, screenshot).
• /src
• main.tsx, App.tsx → React entry point + top-level component
• /components → presentational UI components (review list, AI summary card, star rating, footer) plus a /ui folder for shared design system primitives (badge, button, card, tabs) from shadcn/ui.
• /hooks → data-access and business logic hooks (useReview for Google Sheets + SWR, useAISummaryLogic for Gemini calls).
• /lib → utility functions and wrappers.
• /constants and /types → static data, TypeScript types.
• index.css → Tailwind CSS globals.
• No separate backend; all API calls are made directly from the client.
README for additional insights
• Features: fetch+display reviews, AI summarization.
• Built With: Vite, React, Bun, Tailwind CSS, shadcn/ui, SWR, Google Sheets API, Gemini API, Cloudflare Pages.
a. Main components
• Client (Browser)
– React SPA (App.tsx → components/ui + src/components)
– Data-layer hooks (useReview, useAISummaryLogic)
– Utilities (src/lib) + constants/types
• Hosting / CDN
– Cloudflare Pages serving built static assets
• External services
– Google Sheets API (reads spreadsheet rows of reviews)
– Gemini AI API (summarization endpoint)
b. Relationships & data flow
1. Browser loads SPA from Cloudflare Pages
2. React app renders ReviewList; useReview hook issues GET to Google Sheets REST API via SWR
3. Google Sheets returns review data → React renders reviews
4. User clicks “Summarize” → useAISummaryLogic invokes Gemini API with review text
5. Gemini returns summary → React displays SummaryCard
c. Architectural patterns & principles
• Component-based UI (shadcn/ui primitives + custom components)
• Separation of concerns:
– “UI” layer (components)
– “Data” layer (hooks + SWR caching)
– “Utility” layer (/lib)
• Static hosting + direct client-to-API integration (no custom backend)
d. Key technologies to annotate
• Vite build + dev server
• React + TypeScript
• Tailwind CSS / shadcn/ui
• SWR (data fetching & caching)
• Google Sheets REST API
• Gemini AI API
• Cloudflare Pages (CDN/distribution)