How harishivam/hage-ai works
Project Type and Purpose
• This is a full‑stack, React‑based web application built with Next.js (app directory structure).
• Purpose: A dashboard (“Hage‑Ai”) that lets users sign up/login, upload CSV review data or paste social media text, and view sentiment analysis (charts, stats, history).
File Structure Analysis
• Top‑level “app” directory: Next.js app router for pages (dashboard, login, signup, global layout).
• “components” folder: UI components organized by feature (auth, dashboard, layout, theme) and a generic UI library.
• “hooks” and “lib”: Custom hooks and service code (e.g., use-review-analysis, review-service.ts) indicating a client⇄server data layer.
• Config files: next.config.js, tailwind.config.ts, tsconfig.json—typical for Next.js + TypeScript + Tailwind CSS.
• No internal “api” folder, so data operations likely go through external API endpoints (AI‑analysis service, auth provider).
Key Systems & Layers to Capture
a. Frontend (Browser)
• Next.js Client Components (e.g., forms, inputs, charts)
• Static assets (CSS, images, JS chunks) served from .next/static
b. Next.js Server
• Server Components and SSR/SSG rendering
• Build and caching layers (Webpack cache, manifest files under .next/)
• Routing (app folder routing → pages-manifest.json)
c. Data & Service Layer
• review-service.ts calls external API(s) for sentiment analysis
• Custom hooks (use-review-analysis, use-review-filters) abstract fetch logic
d. External Services
• AI/ML sentiment analysis API (e.g., OpenAI or proprietary service)
• Authentication provider (if used; could be OAuth or Auth0)
• File storage/hosting (e.g., S3) if CSV upload persists externally
e. Deployment & CDN
• Vercel (or similar) for hosting serverless Next.js functions and static assets
• CDN layer for caching static chunks and assets
Relationships & Data Flow
• User’s Browser ⇄ Next.js Server
• HTTP(S) GET/POST for pages and data APIs
• SSR Pages deliver HTML + JSON payloads
• Next.js Server → External Services
• review-service forwards CSV/text to AI API
• receives sentiment results → passes to client via props or next.js API routes
• Caching & Static Generation
• Static pages (login, signup) served from CDN
• Dynamic pages (dashboard) may use server-side rendering or incremental static regeneration
Architectural Patterns & Principles
• Component‑driven UI: reusable UI library under components/ui
• Separation of concerns:
• Presentation (components) vs Business logic (hooks, services) vs Utilities (lib/utils)
• SSR/SSG: Hybrid rendering strategies for performance
• Single codebase with clear folders for app, components, hooks, lib
Essential Elements
• Notes on rendering strategies (SSR vs static) if space allows