# sambhavbohra/blockfolio-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sambhavbohra/blockfolio-ai
- Repository: https://github.com/sambhavbohra/blockfolio-ai

## Overview

##### Project Type and Purpose
- It is a front-end web application optimized for desktop and mobile.
- Its main functions are to display cryptocurrency listings, provide market and historical data, and present crypto news articles using the CoinGecko and CryptoCompare APIs.
- It also supports a dark/light mode toggle for user personalization.

##### Analyzing the File Structure
- Key directories/files:
- index.html: The main landing page.
- css/style.css: Styling of the application (responsive design and theme toggling).
- js/ directory contains four JS files:
- latest.js: Handles fetching and displaying the latest cryptocurrency market data.
- market.js: Manages popular cryptocurrency data.
- news.js: Fetches and displays cryptocurrency news.
- toggle.js: Controls the dark/light mode toggle functionality.
- The structure suggests a modular design where each JavaScript file is responsible for a separate functionality of the application.

##### Key Components
a. Frontend UI:
- Landing Page (index.html) that ties all components together.
- The CSS layer (style.css) that ensures a responsive interface and theme toggling.

b. JavaScript Modules:
- latest.js for real-time crypto market data.
- market.js for handling popular cryptocurrency information.
- news.js for fetching and displaying crypto news.
- toggle.js for managing the dark/light mode.

c. Data/Service Layer:
- Integration with external APIs:
- CoinGecko API for real-time market data and historical trends.
- CryptoCompare News API for fetching news headlines and summaries.
- Data flows from these APIs into the corresponding JS modules.

d. Assets:

##### Relationships and Interactions
- The user interacts with the landing page and UI elements (e.g., search bar and toggle button).
- JavaScript components fetch data from the external APIs and populate the UI.
- The dark/light mode toggle alters CSS properties dynamically.
- Data flows from the APIs (CoinGecko and CryptoCompare) to the JS modules, and then is rendered on the webpage.

##### Architectural Patterns and Technologies
- Modular front-end design: each JavaScript file encapsulates a specific functionality.
- API integration pattern: asynchronous calls to external services with handling for API rate limits.
- Responsive design principles managed via CSS and dynamic theming.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top level - User
    U("User"):::user

    %% UI Layer subgraph
    subgraph "UI Layer"
        UI1("Landing Page (index.html)"):::ui
        UI2("CSS Layer (style.css)"):::ui
        UI3("Assets (Icons & Images)"):::ui
    end

    %% Business Logic subgraph
    subgraph "Business Logic"
        L1("Latest Market Module (latest.js)"):::logic
        L2("Popular Market Module (market.js)"):::logic
        L3("News Module (news.js)"):::logic
        L4("Theme Toggle Module (toggle.js)"):::logic
    end

    %% External APIs subgraph
    subgraph "External APIs"
        API1("CoinGecko API"):::api
        API2("CryptoCompare News API"):::api
    end

    %% User interactions initiating UI access
    U -->|"interacts"| UI1
    U -->|"interacts"| UI2

    %% UI components triggering business logic modules
    UI1 -->|"triggers"| L1
    UI1 -->|"triggers"| L2
    UI1 -->|"triggers"| L3
    UI1 -->|"triggers"| L4

    %% External APIs providing data to business logic modules
    API1 -->|"provides_data"| L1
    API1 -->|"provides_data"| L2
    API2 -->|"provides_news"| L3

    %% Business Logic modules updating the UI
    L1 -->|"updates"| UI1
    L2 -->|"updates"| UI1
    L3 -->|"updates"| UI1

    %% Theme toggle module dynamically updates the CSS layer
    L4 -->|"toggles_theme"| UI2

    %% UI landing page loads assets
    UI1 -->|"loads"| UI3

    %% Click Events
    click UI1 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/index.html"
    click UI2 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/css/style.css"
    click L1 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/JS file/latest.js"
    click L2 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/JS file/market.js"
    click L3 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/JS file/news.js"
    click L4 "https://github.com/sambhavbohra/blockfolio-ai/blob/main/JS file/toggle.js"
    click UI3 "https://github.com/sambhavbohra/blockfolio-ai/tree/main/assests"

    %% Styling classes
    classDef ui fill:#bbdefb,stroke:#42a5f5,color:#000,stroke-width:2px;
    classDef logic fill:#ffe0b2,stroke:#ffb74d,color:#000,stroke-width:2px;
    classDef api fill:#c8e6c9,stroke:#66bb6a,color:#000,stroke-width:2px;
    classDef user fill:#d1c4e9,stroke:#7e57c2,color:#000,stroke-width:2px;
```
