# wenjuinchuah/stock_view_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/wenjuinchuah/stock_view_frontend
- Repository: https://github.com/wenjuinchuah/stock_view_frontend

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) built with Vue 3 and Vite.
- It serves as the frontend for “Stock View,” retrieving and displaying stock data, letting users configure screeners and chart settings, and managing real-time notifications.

##### File structure
- Top-level:
– public/ (static assets: GIFs, SVGs, HTML entry)
– src/ (application code)
– Dockerfile, config files (.eslintrc, .prettierrc, tsconfig, vite.config.ts)
- src/ breakdown:
– main.ts, App.vue, index.html (bootstrapping)
– components/ (reusable UI components)
– views/ (page-level view: DashboardView.vue)
– stores/ (Pinia stores for each feature)
– services/ (FormatService, HttpService for cross-cutting concerns)
– classes/ (domain models: Stock, StockDetails, Notification, etc.)
– enums/ (shared enums for HTTP statuses, indicators, intervals)

##### Extract insights from the README
- Confirms it’s purely frontend, run via `npm run dev` or built for production.
- No mention of internal database – it relies on an external backend API.

##### Main components (to include
a. UI Layer
– Components (AddRule, StockChart, StockScreener, etc.)
– Views (DashboardView)
– Assets (public folder)
b. State Management Layer
– Pinia Stores (e.g., StockScreenerStore, NotificationStore)
c. Domain Model Layer
– Classes (Stock, StockIndicator, StockScreener, etc.)
d. Service Layer
– HttpService (handles API calls to backend)
– FormatService (normalizes data into domain models)
e. External Systems
– Backend API (stock data provider)
– Optional: Notification service if separate

##### Relationships & data flows
- User → UI Component → Store Action
- Store Action → HttpService → Backend API
- API Response → HttpService → FormatService → Domain Class instance
- Domain instance → Store Mutation → UI updates via reactive bindings
- Notification events propagate from service/store → NotificationToast component

##### Architectural patterns & design principles
- Component-based MVVM (Vue components bound to Pinia stores)
- Single source of truth via Pinia state management
- Separation of concerns:
– Presentation (components/views)
– Business logic (stores, classes)
– Data access (services)
- Dependency inversion: UI doesn’t call fetch directly – it goes through HttpService.

##### Details but avoid clutter
- One representative component per feature (e.g., StockChart → StockChartStore → Stock → HttpService).
- Major folder from src/ is visibly represented in the correct layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AddRule["AddRule Component"]:::frontend
        click AddRule "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/components/AddRule.vue"
        StockChart["StockChart Component"]:::frontend
        click StockChart "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/components/StockChart.vue"
        StockScreener["StockScreener Component"]:::frontend
        click StockScreener "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/components/StockScreener.vue"
        NotificationToast["NotificationToast Component"]:::frontend
        click NotificationToast "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/components/NotificationToast.vue"
        DashboardView["Dashboard View"]:::frontend
        click DashboardView "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/views/DashboardView.vue"
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        StockScreenerStore["StockScreenerStore"]:::store
        click StockScreenerStore "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/stores/StockScreenerStore.ts"
        StockChartStore["StockChartStore"]:::store
        click StockChartStore "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/stores/StockChartStore.ts"
        NotificationStore["NotificationStore"]:::store
        click NotificationStore "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/stores/NotificationStore.ts"
        ChartSettingsStore["ChartSettingsStore"]:::store
        click ChartSettingsStore "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/stores/ChartSettingsStore.ts"
        DashboardViewStore["DashboardViewStore"]:::store
        click DashboardViewStore "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/stores/DashboardViewStore.ts"
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        direction TB
        Stock["Stock Model"]:::domain
        click Stock "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/classes/Stock.ts"
        StockDetails["StockDetails Model"]:::domain
        click StockDetails "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/classes/StockDetails.ts"
        StockIndicator["StockIndicator Model"]:::domain
        click StockIndicator "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/classes/StockIndicator.ts"
        StockScreenerModel["StockScreener Model"]:::domain
        click StockScreenerModel "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/classes/StockScreener.ts"
        NotificationModel["Notification Model"]:::domain
        click NotificationModel "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/classes/Notification.ts"
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        HttpService["HttpService"]:::service
        click HttpService "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/services/HttpService.ts"
        FormatService["FormatService"]:::service
        click FormatService "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/services/FormatService.ts"
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        BackendAPI["Backend API"]:::external
    end

    %% Bootstrapping & Config
    subgraph "Build & Config"
        direction TB
        MainTS["main.ts"]:::config
        click MainTS "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/main.ts"
        AppVue["App.vue"]:::config
        click AppVue "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/src/App.vue"
        IndexHTML["index.html"]:::config
        click IndexHTML "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/index.html"
        ViteConfig["vite.config.ts"]:::config
        click ViteConfig "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/vite.config.ts"
        ESLint[".eslintrc.cjs"]:::config
        click ESLint "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/.eslintrc.cjs"
        Prettier[".prettierrc.json"]:::config
        click Prettier "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/.prettierrc.json"
        TSConfig["tsconfig.json"]:::config
        click TSConfig "https://github.com/wenjuinchuah/stock_view_frontend/blob/main/tsconfig.json"
        Dockerfile["Dockerfile"]:::config
        click Dockerfile "https://github.com/wenjuinchuah/stock_view_frontend/tree/main/Dockerfile"
    end

    %% Data Flows
    StockChart -->|"uses"| StockChartStore
    StockScreener -->|"uses"| StockScreenerStore
    NotificationToast -->|"listens to"| NotificationStore
    DashboardView -->|"dispatches actions"| DashboardViewStore

    StockChartStore -->|"fetchStockData()"| HttpService
    StockScreenerStore -->|"fetchScreener()"| HttpService

    HttpService -->|"GET /stocks"| BackendAPI
    BackendAPI -->|"response"| HttpService

    HttpService -->|"format()"| FormatService
    FormatService -->|"→ Stock instance"| Stock

    Stock -->|"updateState"| StockChartStore
    StockChartStore -->|"reactive update"| StockChart

    %% Supporting flows
    StockScreenerStore -->|"format()→StockScreener"| FormatService
    FormatService -->|"→ StockScreener instance"| StockScreenerModel
    StockScreenerModel -->|"updateState"| StockScreenerStore

    NotificationStore -->|"notify()"| NotificationModel
    NotificationModel -->|"updateState"| NotificationStore
    NotificationStore -->|"reactive update"| NotificationToast

    %% Bootstrapping flow
    MainTS -->|"mounts"| AppVue
    AppVue -->|"renders"| DashboardView

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#3178C6,color:#000
    classDef store fill:#DFFFE0,stroke:#3C9D14,color:#000
    classDef domain fill:#FFF5CC,stroke:#D4A017,color:#000
    classDef service fill:#FFE0E0,stroke:#D13212,color:#000
    classDef external fill:#ECECEC,stroke:#888888,color:#000
    classDef config fill:#E8E8F0,stroke:#666699,color:#000
```
