# kkashyap3002/trxmmr-url_shortener- architecture

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

- Interactive diagram: https://gitdiagram.com/kkashyap3002/trxmmr-url_shortener-
- Repository: https://github.com/kkashyap3002/trxmmr-url_shortener-

## Overview

##### Main Components

A. Frontend Layer:
- Client Application (React)
- Key UI Components:
- Public Components (Landing, Auth)
- Protected Components (Dashboard, Analytics)
- State Management (Context API)
- Custom Hooks

B. Backend Layer (Supabase):
- Authentication Service
- Database (PostgreSQL)
- Storage Service

**[Client Layer]**
- ↓↑
**[API Layer]**
- ↓↑
**[Backend Services Layer]**
- ↓↑
**[Database Layer]**

##### Component Details

- Split into Public and Protected routes
- Components:
- Authentication (login.jsx, signup.jsx)
- URL Management (create-link.jsx)
- Analytics (device-stats.jsx, location-stats.jsx)
- Core UI Components

- API services from src/db:
- apiAuth.js
- apiClicks.js
- apiUrls.js
- REST endpoints

- Supabase Authentication
- Supabase Real-time subscriptions
- Storage for QR codes

- PostgreSQL Tables:
- Users
- URLs
- Clicks
- Analytics

##### Key Interactions to Highlight

- Authentication flow
- URL shortening process
- Analytics data collection
- QR code generation and storage
- Click tracking and statistics

##### Specific Implementation Details

- Blue: Frontend components
- Green: API layer
- Orange: Supabase services
- Purple: Database entities

##### Additional Elements

- External libraries (react-spinners, recharts, ua-parser-js)
- Authentication middleware
- Environment configurations

##### Notes for Implementation

- Rectangles for components
- Hexagons for external services
- Circles for endpoints

- Related components:
- All UI components under /components
- API services under /db
- Pages under /pages

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["🌐 Client Layer"]
        App["🚀 React App"]:::frontend
        click App "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/App.jsx"
        
        subgraph "🔓 Public Routes"
            Landing["🏠 Landing Page"]:::frontend
            Auth["🔑 Auth Page"]:::frontend
            click Landing "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/pages/landing.jsx"
            click Auth "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/pages/auth.jsx"
        end
        
        subgraph "🔒 Protected Routes"
            Dashboard["📊 Dashboard"]:::frontend
            LinkMgmt["🔗 Link Management"]:::frontend
            click Dashboard "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/pages/dashboard.jsx"
            click LinkMgmt "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/pages/link.jsx"
        end
        
        subgraph "🔐 Auth Components"
            Login["👤 Login"]:::frontend
            Signup["📝 Signup"]:::frontend
            RequireAuth["🛡️ Auth Protection"]:::frontend
            click Login "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/login.jsx"
            click Signup "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/signup.jsx"
            click RequireAuth "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/require-auth.jsx"
        end
        
        subgraph "📈 Analytics Components"
            DeviceStats["📱 Device Statistics"]:::frontend
            LocationStats["🌍 Location Statistics"]:::frontend
            click DeviceStats "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/device-stats.jsx"
            click LocationStats "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/location-stats.jsx"
        end
        
        subgraph "🔗 URL Components"
            CreateLink["➕ Create Link"]:::frontend
            LinkCard["📇 Link Card"]:::frontend
            RedirectHandler["↪️ Redirect Handler"]:::frontend
            click CreateLink "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/create-link.jsx"
            click LinkCard "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/components/link-card.jsx"
            click RedirectHandler "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/pages/redirect-link.jsx"
        end
    end
    
    subgraph "🔌 API Integration"
        AuthAPI["🔑 Auth API"]:::api
        URLsAPI["🔗 URLs API"]:::api
        ClicksAPI["👆 Clicks API"]:::api
        SupabaseClient["⚡ Supabase Client"]:::api
        click AuthAPI "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/db/apiAuth.js"
        click URLsAPI "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/db/apiUrls.js"
        click ClicksAPI "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/db/apiClicks.js"
        click SupabaseClient "https://github.com/Kkashyap3002/TrXmmr-URL_Shortener-/blob/main/src/db/supabase.js"
    end
    
    subgraph "🏢 Backend Services"
        Auth["🔐 Supabase Auth"]:::backend
        DB[(💾 PostgreSQL DB)]:::backend
        Storage["📦 Storage Service"]:::backend
    end
    
    %% Connections with curved lines
    App -..-> |Uses| StateContext
    App ==> |Uses| CustomHooks
    App -.-> |Uses| AppLayout
    
    %% Auth Flow with gradient
    Auth --> AuthAPI
    Login ==> AuthAPI
    Signup -.-> AuthAPI
    AuthAPI --> SupabaseClient
    SupabaseClient ==> Auth
    
    %% URL Management Flow
    CreateLink -.-> URLsAPI
    LinkCard ==> URLsAPI
    URLsAPI --> SupabaseClient
    SupabaseClient -.-> DB
    
    %% Analytics Flow
    DeviceStats ==> ClicksAPI
    LocationStats -.-> ClicksAPI
    ClicksAPI --> SupabaseClient
    RedirectHandler ==> ClicksAPI
    
    %% Storage Flow
    CreateLink -.-> Storage
    
    %% Enhanced Styles
    classDef frontend fill:#a5b4fc,stroke:#4f46e5,color:#312e81
    classDef api fill:#86efac,stroke:#16a34a,color:#166534
    classDef backend fill:#fde68a,stroke:#d97706,color:#92400e
    
    %% Legend with gradients
    subgraph "📚 Legend"
        Frontend["Frontend Component"]:::frontend
        APILayer["API Component"]:::api
        BackendService["Backend Service"]:::backend
    end

    %% Background styling
    style Client fill:#f8fafc,stroke:#cbd5e1
    style API Integration fill:#f1f5f9,stroke:#cbd5e1
    style Backend Services fill:#f8fafc,stroke:#cbd5e1
    style Legend fill:#f1f5f9,stroke:#cbd5e1
```
