# hsankalp/mvvm-pattern-mobx architecture

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

- Interactive diagram: https://gitdiagram.com/hsankalp/mvvm-pattern-mobx
- Repository: https://github.com/hsankalp/mvvm-pattern-mobx

## Overview

##### Main Components Identification

a. Client-Side Layer:
- Next.js Pages (Entry Points)
- React Components (with MVVM pattern)
- Global Store (State Management)
- API Integration

b. Server-Side Layer:
- Next.js API Routes
- Server-Side Rendering (SSR) Infrastructure

**┌─────────────────────────────────────── Client Browser ───────────────────────────────────────┐**

- ┌─────────────────── Next.js Application ───────────────────┐                              │

- ┌─────────────┐    ┌───────────────────────────────┐    │                              │
- Pages     │    │       Components Layer         │    │                              │
- index.tsx  │───▶│  ┌─────────────┐ ┌─────────┐ │    │                              │
- _app.js    │    │  │   History   │ │ Result  │ │    │                              │
- _document.js│    │  │ (MVVM)     │ │         │ │    │                              │
- ┘    │  └─────────────┘ └─────────┘ │    │                              │
- ▲           └───────────────────────────────┘    │                              │
- ▲                      │                              │

- ┌─────────────┐        ┌─────────────────┐            │                              │
- API Routes │        │  Global Store    │            │                              │
- /api/hello │◀─────▶│   (store.ts)     │            │                              │
- ┘        └─────────────────┘            │                              │

- ┘                              │

- ┘

##### Key Architectural Patterns to Highlight

a. MVVM Pattern (History Component):
- Separation between View.tsx and ViewModel.ts
- Data binding flow

b. State Management:
- Store connection to components
- State update flow

c. Next.js Routing:
- Relationship between pages and components
- API routes integration

##### Important Details

a. Component Architecture:
- History component with MVVM implementation
- Result component structure
- Pages structure with _app.js and _document.js

b. Data Flow:
- Client-side routing
- API communication
- State management interactions

##### Technical Stack Indicators
- Next.js framework
- React components
- TypeScript implementation
- API routes
- Global state management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Client Browser"]
        subgraph NextApp["Next.js Application"]
            subgraph Pages["Pages Layer"]
                Index["index.tsx"]:::page
                App["_app.js"]:::page
                Document["_document.js"]:::page
            end

            subgraph Components["Components Layer"]
                subgraph History["History Component (MVVM)"]
                    HistoryView["View.tsx"]:::component
                    HistoryVM["ViewModel.ts"]:::component
                    HistoryIndex["index.tsx"]:::component
                end

                subgraph Result["Result Component"]
                    ResultView["View.tsx"]:::component
                    ResultIndex["index.tsx"]:::component
                end
            end

            subgraph State["State Management"]
                Store["store.ts"]:::store
            end

            subgraph API["API Layer"]
                APIRoutes["api/hello.js"]:::api
            end

            subgraph Config["Configuration"]
                TSConfig["tsconfig.json"]:::config
                NextEnv["next-env.d.ts"]:::config
                Styles["globals.css"]:::styles
            end
        end
    end

    %% Relationships
    Index --> HistoryIndex
    Index --> ResultIndex
    HistoryIndex --> HistoryView
    HistoryIndex --> HistoryVM
    ResultIndex --> ResultView
    
    HistoryVM <--> Store
    ResultView <--> Store
    
    Components <--> APIRoutes

    %% Click Events
    click Index "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/pages/index.tsx"
    click App "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/pages/_app.js"
    click Document "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/pages/_document.js"
    click HistoryView "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/components/History/View.tsx"
    click HistoryVM "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/components/History/ViewModel.ts"
    click HistoryIndex "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/components/History/index.tsx"
    click ResultView "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/components/Result/View.tsx"
    click ResultIndex "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/components/Result/index.tsx"
    click Store "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/store/store.ts"
    click APIRoutes "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/pages/api/hello.js"
    click TSConfig "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/tsconfig.json"
    click NextEnv "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/next-env.d.ts"
    click Styles "https://github.com/hsankalp/MVVM-Pattern-MobX/blob/main/styles/globals.css"

    %% Styling
    classDef page fill:#2196F3,color:white
    classDef component fill:#4CAF50,color:white
    classDef store fill:#FF9800,color:white
    classDef api fill:#9C27B0,color:white
    classDef config fill:#607D8B,color:white
    classDef styles fill:#FF5722,color:white

    %% Legend
    subgraph Legend
        P[Pages]:::page
        C[Components]:::component
        S[State Management]:::store
        A[API Routes]:::api
        CF[Configuration]:::config
        ST[Styles]:::styles
    end
```
