# sujeetgund/laptopwise architecture

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

- Interactive diagram: https://gitdiagram.com/sujeetgund/laptopwise
- Repository: https://github.com/sujeetgund/laptopwise

## Overview

##### Project type and purpose
- Type: Full-stack, AI-powered web application.
- Purpose: Allow end-users to enter laptop specs via a Next.js/React UI, validate them with an AI flow (Genkit + LLM), then call an external ML-model API to estimate market price.

##### File structure
- Top-level:
- package.json / tsconfig.json / next.config.ts / tailwind.config.ts → Node/Next.js configuration
- public/ → Static assets (images, fonts)
- src/app/ → Next.js App Router pages and root layout
- src/components/ → UI building blocks, ShadCN/Tailwind based components, section-level and layout-level components
- src/ai/ → Genkit flows (validate specs, predict price) + Genkit initialization
- src/lib/ → Constants & utility functions
- src/hooks/ → Custom React hooks
- No internal database, no separate “backend” folder—AI-flow server (Genkit) functions as the business-logic / microservice layer.

##### Insights from README
- Confirmed tech stack: Next.js (App Router), React, TypeScript, ShadCN UI, Tailwind, Genkit (LLM flows), external Python ML model on a cloud endpoint, Google AI credentials for Genkit.
- Workflow:
1. User fills form (react-hook-form + zod)
2. Call validate-laptop-specs flow (Genkit + LLM)
3. If valid, call predict-laptop-price-flow (Genkit → external ML API)
4. Result + insights

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Client Browser"]:::external
        NextJS["Next.js Frontend"]:::frontend
        StaticAssets["Static Assets (public/)"]:::service
    end

    %% Backend / AI Layer
    subgraph "Backend / AI Layer"
        direction TB
        GenkitServer["Genkit Flow Server"]:::backend
        LLMProvider["LLM Provider (Google AI/Gemini)"]:::external
        MLAPI["External ML Model API"]:::external
    end

    %% Details within Next.js Frontend
    subgraph "Next.js Frontend"
        direction TB
        AppRouter["App Router (src/app/)"]:::frontend
        GlobalsCSS["Global CSS (src/app/globals.css)"]:::frontend
        LayoutTSX["Root Layout (src/app/layout.tsx)"]:::frontend
        PageTSX["Main Page (src/app/page.tsx)"]:::frontend
        ComponentsDir["UI Components (src/components/)"]:::frontend
        SectionsDir["Section Components (src/components/sections/)"]:::frontend
        LayoutComponents["Layout Components (src/components/layout/)"]:::frontend
        FormResultComp["Form & Result Components"]:::frontend
        UIPrimitives["UI Primitives (src/components/ui/)"]:::frontend
        HooksDir["Custom Hooks (src/hooks/)"]:::frontend
        LibUtils["Utils (src/lib/utils.ts)"]:::frontend
        LibConst["Constants (src/lib/constants.ts)"]:::frontend
        NextConfig["Next.js Config (next.config.ts)"]:::config
        TailwindConfig["Tailwind Config (tailwind.config.ts)"]:::config
        PostCSSConfig["PostCSS Config (postcss.config.mjs)"]:::config
        TSConfig["TypeScript Config (tsconfig.json)"]:::config
    end

    %% Details within Genkit Flow Server
    subgraph "Genkit Flow Server"
        direction TB
        GenkitInit["Genkit Init (src/ai/genkit.ts)"]:::backend
        ValidateFlow["Validate Flow (src/ai/flows/validate-laptop-specs.ts)"]:::backend
        PredictFlow["Predict Flow (src/ai/flows/predict-laptop-price-flow.ts)"]:::backend
        DevHelper["Dev Helper (src/ai/dev.ts)"]:::backend
    end

    %% Static Assets
    StaticAssets -->|serves assets| Browser

    %% Interactions
    Browser -->|"submit specs"| NextJS
    NextJS -->|"calls flows"| GenkitServer
    GenkitServer -->|"uses LLM for validation"| LLMProvider
    GenkitServer -->|"calls ML API"| MLAPI
    GenkitServer -->|"returns results"| NextJS
    NextJS -->|"renders result"| Browser

    %% Click Events
    click AppRouter "https://github.com/sujeetgund/laptopwise/tree/main/src/app/"
    click GlobalsCSS "https://github.com/sujeetgund/laptopwise/blob/main/src/app/globals.css"
    click LayoutTSX "https://github.com/sujeetgund/laptopwise/blob/main/src/app/layout.tsx"
    click PageTSX "https://github.com/sujeetgund/laptopwise/blob/main/src/app/page.tsx"
    click ComponentsDir "https://github.com/sujeetgund/laptopwise/tree/main/src/components/"
    click SectionsDir "https://github.com/sujeetgund/laptopwise/tree/main/src/components/sections/"
    click LayoutComponents "https://github.com/sujeetgund/laptopwise/tree/main/src/components/layout/"
    click UIPrimitives "https://github.com/sujeetgund/laptopwise/tree/main/src/components/ui/"
    click HooksDir "https://github.com/sujeetgund/laptopwise/tree/main/src/hooks/"
    click LibUtils "https://github.com/sujeetgund/laptopwise/blob/main/src/lib/utils.ts"
    click LibConst "https://github.com/sujeetgund/laptopwise/blob/main/src/lib/constants.ts"
    click GenkitInit "https://github.com/sujeetgund/laptopwise/blob/main/src/ai/genkit.ts"
    click ValidateFlow "https://github.com/sujeetgund/laptopwise/blob/main/src/ai/flows/validate-laptop-specs.ts"
    click PredictFlow "https://github.com/sujeetgund/laptopwise/blob/main/src/ai/flows/predict-laptop-price-flow.ts"
    click DevHelper "https://github.com/sujeetgund/laptopwise/blob/main/src/ai/dev.ts"
    click StaticAssets "https://github.com/sujeetgund/laptopwise/tree/main/public/"
    click NextConfig "https://github.com/sujeetgund/laptopwise/blob/main/next.config.ts"
    click TailwindConfig "https://github.com/sujeetgund/laptopwise/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/sujeetgund/laptopwise/blob/main/postcss.config.mjs"
    click TSConfig "https://github.com/sujeetgund/laptopwise/blob/main/tsconfig.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#E6F4EA,stroke:#22863A,color:#22863A
    classDef external fill:#FEEFB3,stroke:#B08800,color:#B08800
    classDef service fill:#FFF5D1,stroke:#B08800,color:#735C0F
    classDef config fill:#F0F4F8,stroke:#44546A,color:#44546A
```
