# chitrangi25/notes-ai architecture

> Architecture diagram of the GitHub repository chitrangi25/notes-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chitrangi25/notes-ai
- Repository: https://github.com/chitrangi25/notes-ai

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js 13 (the “app” directory API).
- Purpose: allow users to submit text for AI-powered summarization, authenticate via Firebase, and then view saved summaries.

##### File structure
- app/
- layout.tsx, globals.css – global layout and styles
- page.tsx – home page
- summarize/page.tsx – form/UI to submit text for summarization
- summary/[textId]/page.tsx – dynamic route to view a saved summary
- components/
- Reusable UI pieces (Hero, Navbar, Tabs, Dialog, etc.)
- config/
- AIConfig.ts – credentials and endpoints for the AI summarization service
- firebaseconfig.ts – Firebase project settings (Auth + Firestore)
- hooks/useGetUserInfo.ts – custom React hook to retrieve the authenticated user’s profile
- lib/utils.ts – helper functions (e.g., wrappers around fetch, error handling)
- next.config.ts, tsconfig.json, package.json, postcss.config.mjs, public/ – build, lint, deploy, and static-assets config

##### README
- Key dependencies: React, Next.js (app router), Firebase, an AI service (e.g., OpenAI), and Next’s built-in font/loading optimizations.

##### Main components
a. Client Browser (User’s device)
b. Next.js Application (deployed on Vercel or similar)
- React Server Components (pages in app/)
- React Client Components (components/ & hooks/)
c. Firebase (Authentication & Firestore Database)
d. External AI Summarization Service (via AIConfig.ts)
e. Utility Layer (lib/utils.ts)

##### Relationships & data flows
- User → Browser UI → Next.js (Client Components in components/)
- Next.js Router (app/summarize/page.tsx) → invokes server-side logic (lib/utils + AIConfig) → communicates with AI service → returns summarized text
- Summarized text → optionally written to Firestore via Firebase SDK (firebaseconfig + hooks/useGetUserInfo)
- User navigates to /summary/[textId] → Next.js Server Component fetches summary from Firestore → renders page

##### Highlighted architectural patterns
- Hybrid rendering:
- Server-Side Rendering (SSR) for initial page loads and data-fetching pages (summary/[textId])
- Client-Side Rendering (CSR) for interactive components, dialogs, tabs
- Separation of concerns:
- config/ holds external-service setup
- lib/ holds utilities
- hooks/ encapsulate React-specific logic

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    subgraph "Browser (Client)"
        BROWSER["User Browser"]:::client
    end

    %% Next.js Application
    subgraph "Next.js App" 
        subgraph "Server Components"
            LAYOUT["app/layout.tsx"]:::server
            HOME["app/page.tsx"]:::server
            SUMPAGE["app/summarize/page.tsx"]:::server
            DETAIL["app/summary/[textId]/page.tsx"]:::server
        end
        subgraph "Client Components"
            HERO["components/Hero.tsx"]:::client
            NAVBAR["components/Navbar.tsx"]:::client
            DIALOG["components/ui/dialog.tsx"]:::client
            TABS["components/ui/tabs.tsx"]:::client
            SONNER["components/ui/sonner.tsx"]:::client
            HOOK["hooks/useGetUserInfo.ts"]:::client
        end
    end

    %% Utility Layer
    UTILS["lib/utils.ts"]:::utils

    %% External Services
    subgraph "Firebase (Auth & Firestore)"
        FIRECONFIG["config/firebaseconfig.ts"]:::external
        AUTH["Firebase Auth"]:::external
        FIRESTORE["Firestore Database"]:::external
    end

    subgraph "AI Service"
        AICONF["config/AIConfig.ts"]:::external
        AIPROVIDER["External AI API"]:::external
    end

    %% Data Flows
    BROWSER -->|"navigates to routes"| HOME
    BROWSER -->|"submits text"| SUMPAGE
    BROWSER -->|"interacts UI"| HERO
    BROWSER -->|"interacts UI"| NAVBAR
    BROWSER -->|"interacts UI"| DIALOG
    BROWSER -->|"interacts UI"| TABS
    BROWSER -->|"receives notifications"| SONNER
    BROWSER -->|"auth flow"| HOOK

    SUMPAGE -->|"callAI() via Utils"| UTILS
    UTILS -->|"uses AIConfig"| AICONF
    UTILS -->|"requestSummarization()"| AIPROVIDER
    AIPROVIDER -->|"returns summary"| SUMPAGE

    SUMPAGE -->|"saveSummary() via SDK"| FIRESTORE
    FIRESTORE -->|"acknowledgement"| SUMPAGE

    DETAIL -->|"fetchSummary() via SDK"| FIRESTORE
    FIRESTORE -->|"returns data"| DETAIL

    HOOK -->|"getUser() via SDK"| FIRECONFIG
    FIRECONFIG -->|"auth methods"| AUTH
    AUTH -->|"user info"| HOOK

    %% Click Events
    click LAYOUT "https://github.com/chitrangi25/notes-ai/blob/main/app/layout.tsx"
    click HOME "https://github.com/chitrangi25/notes-ai/blob/main/app/page.tsx"
    click SUMPAGE "https://github.com/chitrangi25/notes-ai/blob/main/app/summarize/page.tsx"
    click DETAIL "https://github.com/chitrangi25/notes-ai/blob/main/app/summary/[textId]/page.tsx"
    click HERO "https://github.com/chitrangi25/notes-ai/blob/main/components/Hero.tsx"
    click NAVBAR "https://github.com/chitrangi25/notes-ai/blob/main/components/Navbar.tsx"
    click DIALOG "https://github.com/chitrangi25/notes-ai/blob/main/components/ui/dialog.tsx"
    click TABS "https://github.com/chitrangi25/notes-ai/blob/main/components/ui/tabs.tsx"
    click SONNER "https://github.com/chitrangi25/notes-ai/blob/main/components/ui/sonner.tsx"
    click HOOK "https://github.com/chitrangi25/notes-ai/blob/main/hooks/useGetUserInfo.ts"
    click FIRECONFIG "https://github.com/chitrangi25/notes-ai/blob/main/config/firebaseconfig.ts"
    click AICONF "https://github.com/chitrangi25/notes-ai/blob/main/config/AIConfig.ts"
    click UTILS "https://github.com/chitrangi25/notes-ai/blob/main/lib/utils.ts"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef utils fill:#D3D3D3,stroke:#333,stroke-width:1px
```
