# eshan-b/pennywise architecture

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

- Interactive diagram: https://gitdiagram.com/eshan-b/pennywise
- Repository: https://github.com/eshan-b/pennywise

## Overview

##### Project Type and Purpose
- This is a modern, front-end-focused web application built with Next.js and React. Its main purpose is to allow users to explore penny stocks with features that include viewing historical data, news, trending stocks, risk gauges, and interactive charts.
- The deployed app is hosted on Vercel and leverages modern UI libraries such as NextUI along with Tailwind CSS for styling.

##### File Structure Analysis
- Key Directories:
- The "app" folder: Contains Next.js route pages, dynamic routes (e.g., stocks/[slug]), main layout files (layout.tsx), global styles (globals.css) and error/fallback pages (not-found.tsx).
- The "components" folder: Houses UI components (hero-section, navbar, search-bar, charts, news, and risk sections) used for modular and reusable UI elements.
- The "providers" directory: Includes a UI provider that likely supplies global styling/theme context to the component tree.
- The "utils" directory: Consists of several data-fetching modules (fetch_historical_data, fetch_news_data, fetch_price, fetch_trending) which encapsulate API calls or asynchronous data retrieval logic.
- Additional Files: Configuration files like next.config.mjs, tailwind.config.ts, ESLint settings (.eslintrc.json), and TypeScript configuration (tsconfig.json) are present, pointing to a well-configured modern frontend project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Provider Layer
    subgraph "Provider Layer"
        UIProvider["UI Provider"]:::provider
    end

    %% Client/UI Layer
    subgraph "Client/UI Layer"
        subgraph "Next.js Pages"
            PageHome["Home Page"]:::page
            PageStocks["Stocks Listing Page"]:::page
            PageDetail["Detailed Stock Page"]:::page
        end
        subgraph "UI Components"
            Navbar["Navbar"]:::component
            Hero["Hero Section"]:::component
            Search["Search Bar"]:::component
            HistoricalChart["Historical Chart"]:::component
            SparkChart["Spark Chart"]:::component
            NewsCard["News Card"]:::component
            NewsSection["News Section"]:::component
            RiskCard["Risk Card"]:::component
            RiskGauge["Risk Gauge"]:::component
            TrendingCard["Trending Card"]:::component
            TrendingSection["Trending Section"]:::component
        end
    end

    %% Data/Services Layer
    subgraph "Data/Services Layer"
        FetchHistorical["Historical Data Fetcher"]:::utility
        FetchNews["News Data Fetcher"]:::utility
        FetchPrice["Price Fetcher"]:::utility
        FetchTrending["Trending Stocks Fetcher"]:::utility
    end

    %% External APIs
    ExternalAPIs([External APIs]):::external

    %% Relationships
    UIProvider -->|"wraps"| PageHome
    UIProvider -->|"wraps"| PageStocks
    UIProvider -->|"wraps"| PageDetail
    UIProvider -->|"wraps"| Navbar
    UIProvider -->|"wraps"| Hero
    UIProvider -->|"wraps"| Search
    UIProvider -->|"wraps"| HistoricalChart
    UIProvider -->|"wraps"| SparkChart
    UIProvider -->|"wraps"| NewsSection
    UIProvider -->|"wraps"| TrendingSection

    PageHome -->|"renders"| Navbar
    PageHome -->|"renders"| Hero
    PageHome -->|"renders"| Search
    PageStocks -->|"renders"| NewsSection
    PageDetail -->|"renders"| HistoricalChart

    HistoricalChart -->|"fetches"| FetchHistorical
    SparkChart -->|"fetches"| FetchPrice
    NewsSection -->|"fetches"| FetchNews
    TrendingSection -->|"fetches"| FetchTrending

    FetchHistorical -->|"calls"| ExternalAPIs
    FetchNews -->|"calls"| ExternalAPIs
    FetchPrice -->|"calls"| ExternalAPIs
    FetchTrending -->|"calls"| ExternalAPIs

    %% Click Events
    click UIProvider "https://github.com/eshan-b/pennywise/blob/main/providers/ui-provider.tsx"
    click PageHome "https://github.com/eshan-b/pennywise/blob/main/app/page.tsx"
    click PageStocks "https://github.com/eshan-b/pennywise/blob/main/app/stocks/page.tsx"
    click PageDetail "https://github.com/eshan-b/pennywise/blob/main/app/stocks/[slug]/page.tsx"
    click Navbar "https://github.com/eshan-b/pennywise/blob/main/components/navbar.tsx"
    click Hero "https://github.com/eshan-b/pennywise/blob/main/components/hero-section.tsx"
    click Search "https://github.com/eshan-b/pennywise/blob/main/components/search-bar.tsx"
    click HistoricalChart "https://github.com/eshan-b/pennywise/blob/main/components/historical-chart.tsx"
    click SparkChart "https://github.com/eshan-b/pennywise/blob/main/components/spark-chart.tsx"
    click NewsCard "https://github.com/eshan-b/pennywise/blob/main/components/news-card.tsx"
    click NewsSection "https://github.com/eshan-b/pennywise/blob/main/components/news-section.tsx"
    click RiskCard "https://github.com/eshan-b/pennywise/blob/main/components/risk-card.tsx"
    click RiskGauge "https://github.com/eshan-b/pennywise/blob/main/components/risk-gauge.tsx"
    click TrendingCard "https://github.com/eshan-b/pennywise/blob/main/components/trending-card.tsx"
    click TrendingSection "https://github.com/eshan-b/pennywise/blob/main/components/trending-section.tsx"
    click FetchHistorical "https://github.com/eshan-b/pennywise/blob/main/utils/fetch_historical_data.ts"
    click FetchNews "https://github.com/eshan-b/pennywise/blob/main/utils/fetch_news_data.ts"
    click FetchPrice "https://github.com/eshan-b/pennywise/blob/main/utils/fetch_price.ts"
    click FetchTrending "https://github.com/eshan-b/pennywise/blob/main/utils/fetch_trending.ts"

    %% Styles
    classDef provider fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef page fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef component fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
