# karanunique/cryptohub architecture

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

- Interactive diagram: https://gitdiagram.com/karanunique/cryptohub
- Repository: https://github.com/karanunique/cryptohub

## Overview

##### Project type and purpose
- CryptoHub is a modern, single-page, full-stack web application built with React and Vite.
- It has no custom backend server code; instead it relies on serverless services (Firebase Authentication, Firestore or Realtime DB) and a third-party market data API (CoinGecko).
- Its purpose is to provide users with real-time cryptocurrency prices, interactive charts, user authentication, a personalized dashboard (portfolio, leaderboard), educational blogs, and subscription-based pricing plans.

##### File structure
- Top level:
- Dockerfile/docker-compose.yml & DOCKER_SETUP.md – containerized development environment.
- vite.config.js, index.html – Vite build config & HTML template.
- README.md, docs/ – documentation and design guides.
- /public – static assets (logo, favicon).
- /src – core application code:
- /components – reusable UI components (Navbar, Footer, charts, forms, PrivateRoute).
- /pages – route-level views (Home, Coin detail, Dashboard) organized in subfolders.
- /context – React Context providers (AuthContext, CoinContext, ThemeContext, ActivityContext, LeaderboardContext).
- /utils – helper modules (api calls, storage, notifications).
- firebase.js – Firebase initialization.
- Configuration files (.env.example, .nvmrc, tailwind.config.js, postcss.config.js, eslint.config.js) confirm a front-end-centric tech stack.

##### Elements
- Clear labels: “User Browser,” “React SPA (Vite),” “Firebase Auth,” “Firestore,” “CoinGecko API,” “Vercel Hosting,” “GitHub Actions.”
- Asset fetch (Browser ← Vercel)
- API calls (SPA → CoinGecko; SPA → Firebase Auth/DB)
- Auth token flow (Firebase → SPA)
- CI/CD flow (GitHub → Actions → Vercel).
- Blue rectangles for client-side (SPA, components, contexts).

##### Details
- Context Provider as a sub-component of the SPA.
- Related UI pages under the SPA block.
- Which utils handle which API calls (e.g., newsService.js → CoinGecko).
- Protected routes (PrivateRoute) and where JWT/session tokens are stored (storageManager.js).
- Don’t over-segment. Focus on logical layers: UI, state, API, services, hosting & CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Client
    User["User Browser"]:::frontend
    ReactSPA["React SPA<br>(Vite)"]:::frontend
    User -->|loads assets| ReactSPA

    %% React SPA Subgraph
    subgraph "React SPA"
        direction TB
        Entry["Entry Point<br>main.jsx"]:::frontend
        AppShell["App Component<br>App.jsx"]:::frontend

        subgraph "Contexts"
            direction TB
            AuthCtx["AuthContext"]:::frontend
            CoinCtx["CoinContext"]:::frontend
            ThemeCtx["ThemeContext"]:::frontend
            ActivityCtx["ActivityContext"]:::frontend
            LeaderboardCtx["LeaderboardContext"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
            PrivateRoute["PrivateRoute"]:::frontend
            LineChart["LineChart"]:::frontend
        end

        subgraph "Pages"
            direction TB
            HomePage["Home Page"]:::frontend
            CoinDetail["Coin Detail"]:::frontend
            DashboardLayout["Dashboard Layout"]:::frontend
            DashboardContent["Dashboard Content"]:::frontend
            MarketOverview["Market Overview"]:::frontend
        end

        subgraph "Utils"
            direction TB
            StorageMgr["Storage Manager"]:::frontend
            CryptoUtils["cryptoUtils"]:::frontend
            NewsService["newsService"]:::frontend
            Notify["notify"]:::frontend
        end

        Entry --> AppShell
        AppShell --> AuthCtx
        AppShell --> CoinCtx
        AppShell --> ThemeCtx
        AppShell --> ActivityCtx
        AppShell --> LeaderboardCtx
        AppShell --> Navbar
        AppShell --> Footer
        AppShell --> Pages

        AuthCtx --> StorageMgr
        AuthCtx --> FirebaseInit
        CoinCtx --> CryptoUtils
        CoinCtx --> NewsService
        ActivityCtx --> FirebaseInit
        LeaderboardCtx --> FirebaseInit
        PrivateRoute --> AuthCtx
        PrivateRoute --> StorageMgr
    end

    %% Services and APIs
    FirebaseInit["Firebase Init<br>firebase.js"]:::service
    FirebaseAuth["Firebase Auth"]:::service
    FirestoreDB["Firestore DB"]:::database
    CoinGeckoAPI["CoinGecko API"]:::service

    FirebaseInit --> FirebaseAuth
    FirebaseInit --> FirestoreDB

    CryptoUtils --> CoinGeckoAPI
    NewsService --> CoinGeckoAPI

    ReactSPA --> FirebaseAuth
    ReactSPA --> FirestoreDB
    ReactSPA --> CoinGeckoAPI

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GitHub["GitHub"]:::pipeline
        Actions["GitHub Actions"]:::pipeline
        Vercel["Vercel Hosting"]:::pipeline
        DockerReg["Docker Registry"]:::pipeline
    end

    GitHub --> Actions
    Actions --> Vercel
    Actions --> DockerReg
    Vercel --> ReactSPA

    %% Static & Config
    ViteConfig["vite.config.js<br>index.html"]:::frontend
    DockerFiles["Docker Setup"]:::pipeline
    StaticAssets["public/"]:::frontend
    Docs["docs/"]:::frontend

    Vercel --> StaticAssets
    ReactSPA --> ViteConfig
    ReactSPA --> DockerFiles
    ReactSPA --> Docs

    %% Click Events
    click Entry "https://github.com/karanunique/cryptohub/blob/main/src/main.jsx"
    click AppShell "https://github.com/karanunique/cryptohub/blob/main/src/App.jsx"
    click ViteConfig "https://github.com/karanunique/cryptohub/blob/main/vite.config.js"
    click ViteConfig "https://github.com/karanunique/cryptohub/blob/main/index.html"
    click FirebaseInit "https://github.com/karanunique/cryptohub/blob/main/src/firebase.js"
    click AuthCtx "https://github.com/karanunique/cryptohub/blob/main/src/context/AuthContext.jsx"
    click CoinCtx "https://github.com/karanunique/cryptohub/blob/main/src/context/CoinContext.jsx"
    click ThemeCtx "https://github.com/karanunique/cryptohub/blob/main/src/context/ThemeContext.jsx"
    click ActivityCtx "https://github.com/karanunique/cryptohub/blob/main/src/context/ActivityContext.jsx"
    click LeaderboardCtx "https://github.com/karanunique/cryptohub/blob/main/src/context/LeaderboardContext.jsx"
    click PrivateRoute "https://github.com/karanunique/cryptohub/blob/main/src/components/PrivateRoute.jsx"
    click Navbar "https://github.com/karanunique/cryptohub/blob/main/src/components/Navbar.jsx"
    click Footer "https://github.com/karanunique/cryptohub/blob/main/src/components/Footer.jsx"
    click LineChart "https://github.com/karanunique/cryptohub/blob/main/src/components/LineChart.jsx"
    click StorageMgr "https://github.com/karanunique/cryptohub/blob/main/src/utils/storageManager.js"
    click CryptoUtils "https://github.com/karanunique/cryptohub/blob/main/src/utils/cryptoUtils.js"
    click NewsService "https://github.com/karanunique/cryptohub/blob/main/src/utils/newsService.js"
    click Notify "https://github.com/karanunique/cryptohub/blob/main/src/utils/notify.js"
    click HomePage "https://github.com/karanunique/cryptohub/blob/main/src/pages/Home/Home.jsx"
    click CoinDetail "https://github.com/karanunique/cryptohub/blob/main/src/pages/Home/Coin/Coin.jsx"
    click DashboardLayout "https://github.com/karanunique/cryptohub/blob/main/src/pages/Dashboard/DashboardLayout.jsx"
    click DashboardContent "https://github.com/karanunique/cryptohub/blob/main/src/pages/Dashboard/DashboardContent.jsx"
    click MarketOverview "https://github.com/karanunique/cryptohub/blob/main/src/pages/Dashboard/MarketOverview.jsx"
    click DockerFiles "https://github.com/karanunique/cryptohub/tree/main/Dockerfile"
    click DockerFiles "https://github.com/karanunique/cryptohub/blob/main/docker-compose.yml"
    click DockerFiles "https://github.com/karanunique/cryptohub/blob/main/DOCKER_SETUP.md"
    click GitHub "https://github.com/karanunique/cryptohub/tree/main/.github/workflows/"
    click Vercel "https://github.com/karanunique/cryptohub/blob/main/vercel.json"
    click StaticAssets "https://github.com/karanunique/cryptohub/tree/main/public/"
    click Docs "https://github.com/karanunique/cryptohub/tree/main/docs/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef service fill:#FFE4B5,stroke:#d2691e
    classDef database fill:#D5F5E3,stroke:#28a745
    classDef pipeline fill:#F0F0F0,stroke:#888888,stroke-dasharray:5,stroke-width:2px
```
