# atif409/url-shortner-frontend architecture

> Architecture diagram of the GitHub repository atif409/url-shortner-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atif409/url-shortner-frontend
- Repository: https://github.com/atif409/url-shortner-frontend

## Overview

##### Project type and purpose
- This is the **frontend** of a **full-stack URL shortening service** built with React, Vite and Tailwind CSS.
- Its purpose is to provide a user interface for:
- Authentication (Sign Up, Login, Forgot/Change Password)
- Creating and managing shortened URLs (including smart links and custom aliases)
- Generating QR codes
- Viewing analytics (frontend stubs pending backend integration)
- Profile settings and other dashboard pages

##### File structure
- Top-level configs: .eslintrc.json, .prettierrc, tailwind.config.js, vite.config.mjs
- src/
- index.html + main.jsx: application entry
- components/: reusable UI building blocks (Buttons, Modals, Tables, etc.)
- pages/: route-level React components (Dashboard, CreateLinks, Analytics, etc.)
- routes/: routing setup with ProtectedRoute/PublicRoute wrappers
- services/: API client modules (user.api.js, link.api.js)
- context/: global state (themeContext)
- hooks/: custom hooks (useAuth, useThemeStorage)
- layout/: page layout wrapper (AppPageLayout)
- assets/, themes/, utils/: static assets, theming files, utility functions

##### README for insights
- Features listed confirm front-end responsibilities and integration points with backend endpoints for auth, link creation/management, QR code generation, analytics.
- No mention of direct database interactions on the front-end; all data is fetched via REST or HTTP APIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User"]:::external
    User -->|"Interacts with UI"| Client

    %% Client Subsystem
    subgraph "Client (React SPA)" 
        direction TB

        subgraph "Entry Point" 
            direction TB
            Index["index.html"]:::ui
            Main["main.jsx"]:::ui
        end

        subgraph "Routing Layer"
            direction TB
            Root["root.jsx"]:::ui
            Protected["ProtectedRoute.jsx"]:::ui
            Public["PublicRoute.jsx"]:::ui
        end

        subgraph "UI Components"
            Components["src/components/"]:::ui
        end

        subgraph "Pages & Layout"
            direction TB
            Pages["src/pages/"]:::ui
            Layout["AppPageLayout.jsx"]:::ui
        end

        subgraph "State & Context"
            ThemeCtx["themeContext.jsx"]:::service
        end

        subgraph "Custom Hooks"
            AuthHook["useAuth.js"]:::service
            ThemeHook["useThemeStorage.js"]:::service
        end

        subgraph "API Service Layer"
            UserAPI["user.api.js"]:::service
            LinkAPI["link.api.js"]:::service
        end

        subgraph "Theming"
            Themes["src/themes/"]:::service
        end

        subgraph "Assets"
            Assets["src/assets/"]:::storage
        end

        subgraph "Utilities"
            Utils["src/utils/"]:::service
        end

        subgraph "Browser Storage"
            Storage["localStorage/sessionStorage"]:::storage
        end

        %% Internal Connections
        Index --> Main
        Main --> Root
        Root --> Protected
        Root --> Public
        Protected --> Pages
        Public --> Pages
        Pages --> Layout
        Pages --> Components
        Components --> Utils
        Layout --> ThemeCtx
        ThemeCtx --> Themes
        ThemeCtx --> Storage
        AuthHook --> UserAPI
        ThemeHook --> Utils
        Pages -->|"calls"| UserAPI
        Pages -->|"calls"| LinkAPI
        UserAPI --> Storage
        LinkAPI --> Storage
    end

    %% Backend Subsystem
    subgraph "Backend API Services"
        direction TB
        AuthS["Authentication Service"]:::backend
        LinkS["Link Service"]:::backend
        AnalyticsS["Analytics Service"]:::backend
        QRS["QR Code Service"]:::backend
        Email["Email Service"]:::external
        DB["Database"]:::storage
    end

    %% Client to Backend Interactions
    Client -->|"POST/GET /api/auth"| AuthS
    Client -->|"POST/GET /api/links"| LinkS
    Client -.->|"(future) GET /api/analytics"| AnalyticsS
    Client -->|"GET /api/qrcode"| QRS

    %% Backend Relationships
    AuthS --> DB
    LinkS --> DB
    AnalyticsS --> DB
    QRS --> DB
    AuthS --> Email

    %% Click Events
    click Index "https://github.com/atif409/url-shortner-frontend/blob/main/index.html"
    click Main "https://github.com/atif409/url-shortner-frontend/blob/main/src/main.jsx"
    click Root "https://github.com/atif409/url-shortner-frontend/blob/main/src/routes/root.jsx"
    click Protected "https://github.com/atif409/url-shortner-frontend/blob/main/src/components/ProtectedRoute.jsx"
    click Public "https://github.com/atif409/url-shortner-frontend/blob/main/src/components/PublicRoute.jsx"
    click Components "https://github.com/atif409/url-shortner-frontend/tree/main/src/components/"
    click Pages "https://github.com/atif409/url-shortner-frontend/tree/main/src/pages/"
    click Layout "https://github.com/atif409/url-shortner-frontend/blob/main/src/layout/AppPageLayout.jsx"
    click ThemeCtx "https://github.com/atif409/url-shortner-frontend/blob/main/src/context/themeContext.jsx"
    click AuthHook "https://github.com/atif409/url-shortner-frontend/blob/main/src/hooks/useAuth.js"
    click ThemeHook "https://github.com/atif409/url-shortner-frontend/blob/main/src/hooks/useThemeStorage.js"
    click UserAPI "https://github.com/atif409/url-shortner-frontend/blob/main/src/services/user.api.js"
    click LinkAPI "https://github.com/atif409/url-shortner-frontend/blob/main/src/services/link.api.js"
    click Themes "https://github.com/atif409/url-shortner-frontend/tree/main/src/themes/"
    click Assets "https://github.com/atif409/url-shortner-frontend/tree/main/src/assets/"
    click Utils "https://github.com/atif409/url-shortner-frontend/tree/main/src/utils/"

    %% Styles
    classDef ui fill:#E0F2FE,stroke:#0369A1,color:#0369A1
    classDef service fill:#DCFCE7,stroke:#166534,color:#166534
    classDef backend fill:#FEF3C7,stroke:#B45309,color:#B45309
    classDef storage fill:#F3F4F6,stroke:#4B5563,color:#4B5563
    classDef external fill:#F5F3FF,stroke:#7C3AED,color:#7C3AED
```
