# pulkitj0906/glance architecture

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

- Interactive diagram: https://gitdiagram.com/pulkitj0906/glance
- Repository: https://github.com/pulkitj0906/glance

## Overview

##### Main Components
- Frontend – Represented by the “app” folder. This includes:
- Static pages such as the homepage (app/page.tsx), login (app/login/page.tsx), and signup (app/signup/page.tsx).
- Dynamic routes (the “app/[slug]” folder) that likely serve customized user profiles.
- UI components that are shared across pages (in app/_ui-components).
- Specialized profile components (in app/[slug]/_profile-components) and sub-components (in nested _item-components).
- API Layer – Found under “app/api”. This layer is organized into:
- Grid endpoints (for managing links, updating profile pictures, spans and fetching Leetcode stats).
- User endpoints (for login, logout, signup, and email/identity verification).
- Utilities – In the “util” directory, likely responsible for shared functions (like checking access permissions, client configuration, and common helper functions).

##### Relationships and Interactions
- The client-side pages interact with various UI and profile components to render dynamic content.
- The frontend components make RESTful calls (or Next.js route calls) to the corresponding API endpoints for user actions (login, signup, etc.) and grid operations (adding, deleting or updating links, fetching external statistics such as Leetcode stats).
- The API endpoints, serving as serverless functions, may use the utilities in “util” to perform business logic or access control.
- Global styling and configuration (in globals.css, tailwind.config.ts, and next.config.mjs) tie in with both layout and functionality.

##### Architectural Patterns and Design Principles
- Route-Based Structure: Leveraging Next.js’s “app” directory structure, including dynamic routes (i.e., [slug]) for personalized content.
- Separation of Concerns: Distinct separation between view components (UI, profile components) and serverless API routes. This design ensures readability and maintainability.
- Component Reusability: The existence of underscore-prefixed components (_components, _profile-components, and even further nested _item-components) suggests an attempt to keep presentation logic modular.
- Full-Stack Integration: Using Next.js as a unified framework for both the frontend and backend API endpoints.

##### Relevant Technologies, Frameworks, or Libraries
- Next.js framework (with its App Router)
- React (for creating interactive UI components)
- Tailwind CSS (global styling via globals.css and tailwind.config.ts)
- Serverless functions defined within Next.js API endpoints that manage user and grid operations
- Miscellaneous utilities in “util” for common tasks

##### Summary
- The full separation between the client-side Next.js pages/components and the serverless API endpoints.
- The dynamic route ([slug]) and profile-specific components that handle user-specific presentations.
- The modularity of the UI components and the structured layering of the API endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Next.js Frontend Layer
    subgraph "Next.js Frontend"
        direction TB
        FE_Home("Homepage"):::page
        FE_Login("Login Page"):::page
        FE_Signup("Signup Page"):::page
        subgraph "Dynamic Profile"
            direction TB
            DP_Page("Profile Page"):::page
            DP_ProfileComponents("Profile Components"):::component
            DP_NestedItems("Nested Item Components"):::component
        end
        FE_UI("Shared UI Components"):::component
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        subgraph "User API"
            direction TB
            API_User_Login("Login Endpoint"):::api
            API_User_Logout("Logout Endpoint"):::api
            API_User_Signup("Signup Endpoint"):::api
            API_User_Verify("Verification Endpoint"):::api
        end
        subgraph "Grid API"
            direction TB
            API_Grid_Add("AddLink Endpoint"):::api
            API_Grid_Delete("DeleteLink Endpoint"):::api
            API_Grid_Leetcode("Get Leetcode Stats"):::api
            subgraph "Update Endpoints"
                direction TB
                API_Grid_UpdatePFP("Update Profile Picture"):::api
                API_Grid_UpdateSpan("Update Span"):::api
                API_Grid_Update("General Update"):::api
            end
        end
    end

    %% Utilities & Global Config
    subgraph "Utilities & Config"
        direction TB
        Utils("Utilities"):::util
        Global_Styles("Global Styles"):::config
        Tailwind_Config("Tailwind Config"):::config
        Next_Config("Next.js Config"):::config
    end

    %% External Dependencies
    external("External Dependencies\n(Tailwind CSS, Next.js Optimizations)"):::external

    %% Relationships
    FE_Home -->|"triggers rendering"| DP_Page
    FE_Login -->|"calls"| API_User_Login
    FE_Signup -->|"calls"| API_User_Signup
    DP_Page -->|"fetches grid data"| API_Grid_Leetcode
    DP_Page -->|"verifies user"| API_User_Verify
    FE_UI -->|"used by"| FE_Home
    FE_UI -->|"used by"| FE_Login
    FE_UI -->|"used by"| FE_Signup
    DP_ProfileComponents -->|"composes"| DP_Page
    DP_NestedItems -->|"integrates with"| DP_ProfileComponents

    API_User_Login -->|"uses"| Utils
    API_User_Logout -->|"uses"| Utils
    API_User_Signup -->|"uses"| Utils
    API_User_Verify -->|"uses"| Utils
    API_Grid_Add -->|"uses"| Utils
    API_Grid_Delete -->|"uses"| Utils
    API_Grid_UpdatePFP -->|"uses"| Utils
    API_Grid_UpdateSpan -->|"uses"| Utils
    API_Grid_Update -->|"uses"| Utils
    API_Grid_Leetcode -->|"fetches from"| external

    Global_Styles -->|"styles"| FE_UI
    Tailwind_Config -->|"configures"| FE_UI
    Next_Config -->|"configures"| FE_UI

    %% Click Events for Frontend Pages
    click FE_Home "https://github.com/pulkitj0906/glance/blob/main/app/page.tsx"
    click FE_Login "https://github.com/pulkitj0906/glance/blob/main/app/login/page.tsx"
    click FE_Signup "https://github.com/pulkitj0906/glance/blob/main/app/signup/page.tsx"
    click DP_Page "https://github.com/pulkitj0906/glance/blob/main/app/[slug]/page.tsx"
    click DP_ProfileComponents "https://github.com/pulkitj0906/glance/tree/main/app/[slug]/_profile-components"
    click DP_NestedItems "https://github.com/pulkitj0906/glance/tree/main/app/[slug]/_profile-components/_item-components"
    click FE_UI "https://github.com/pulkitj0906/glance/tree/main/app/_ui-components"
    
    %% Click Events for API - Grid Endpoints
    click API_Grid_Add "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/addLink/route.ts"
    click API_Grid_Delete "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/deleteLink/route.ts"
    click API_Grid_Leetcode "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/getLeetcodeStats/route.ts"
    click API_Grid_UpdatePFP "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/update/pfp/route.ts"
    click API_Grid_UpdateSpan "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/update/span/route.ts"
    click API_Grid_Update "https://github.com/pulkitj0906/glance/blob/main/app/api/grid/update/route.ts"
    
    %% Click Events for API - User Endpoints
    click API_User_Login "https://github.com/pulkitj0906/glance/blob/main/app/api/user/login/route.ts"
    click API_User_Logout "https://github.com/pulkitj0906/glance/blob/main/app/api/user/logout/route.ts"
    click API_User_Signup "https://github.com/pulkitj0906/glance/blob/main/app/api/user/signup/route.ts"
    click API_User_Verify "https://github.com/pulkitj0906/glance/blob/main/app/api/user/verify/route.ts"

    %% Click Events for Utilities & Global Config
    click Utils "https://github.com/pulkitj0906/glance/tree/main/util"
    click Global_Styles "https://github.com/pulkitj0906/glance/blob/main/app/globals.css"
    click Tailwind_Config "https://github.com/pulkitj0906/glance/blob/main/tailwind.config.ts"
    click Next_Config "https://github.com/pulkitj0906/glance/blob/main/next.config.mjs"

    %% Style Definitions
    classDef page fill:#a2d2ff,stroke:#000,stroke-width:1.5px;
    classDef component fill:#ffc6ff,stroke:#000,stroke-width:1.5px;
    classDef api fill:#caffbf,stroke:#000,stroke-width:1.5px;
    classDef util fill:#ffadad,stroke:#000,stroke-width:1.5px;
    classDef config fill:#fdffb6,stroke:#000,stroke-width:1.5px;
    classDef external fill:#9d8189,stroke:#000,stroke-width:1.5px;
```
