# pi-apps/pi-explorer architecture

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

- Interactive diagram: https://gitdiagram.com/pi-apps/pi-explorer
- Repository: https://github.com/pi-apps/pi-explorer

## Overview

##### Main Components

a) Frontend Layer:
- React Application (evident from the src/components structure)
- Key UI Components:
- Layout Components (Header, Footer, SearchBox)
- Blockchain Entity Views (Accounts, Transactions, Operations, Ledgers)
- Shared Components (DataFetching containers, UI elements)
- Internationalization System (languages directory)

b) Backend Integration:
- Horizon API Interface (Pi Blockchain API)
- Network Selector (Multiple network support: Local, Testnet, Public)
- Data Services Layer (src/lib/stellar)

c) Build & Deployment:
- Webpack Configuration
- Docker Container
- Kubernetes Deployment

**[User Browser] → [Frontend Application]**
- ↓
**[Network Selector] → [API Layer] → [Horizon API]**
- ↓
- [Data Services]
- ↓
- [Blockchain Data Display]

##### Key Relationships to Highlight

- Data Flow:
- How blockchain data flows from Horizon API through the application
- Network selection mechanism
- Internationalization system integration

- Component Integration:
- DataFetchingContainer relationships with UI components
- Stellar SDK integration points
- Network switching mechanism

##### Architectural Patterns to Emphasize

- Component-based architecture (React components)
- Container/Presenter pattern (evident in DataFetchingContainer usage)
- Service-oriented integration with blockchain API
- Internationalization architecture

##### Technical Stack Indicators

- React.js (Frontend Framework)
- Stellar SDK (Blockchain Integration)
- Webpack (Build Tool)
- Docker/Kubernetes (Deployment)
- Jest (Testing Framework)

This system design should help developers understand both the overall architecture and the specific implementation details of the Pi Blockchain Explorer.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser
        User[User Browser]
    end

    subgraph Frontend["Frontend Application"]
        App["React App"]:::react
        Layout["Layout Components"]:::component
        BlockchainViews["Blockchain Views"]:::component
        SharedComp["Shared Components"]:::component
        I18n["Internationalization"]:::component
        
        App --> Layout
        App --> BlockchainViews
        App --> SharedComp
        App --> I18n
        
        subgraph LayoutComponents["Layout Layer"]
            Header["Header"]:::ui
            Footer["Footer"]:::ui
            Search["SearchBox"]:::ui
            NetSelect["Network Selector"]:::ui
            LangSelect["Language Selector"]:::ui
            
            Layout --> Header
            Layout --> Footer
            Layout --> Search
            Layout --> NetSelect
            Layout --> LangSelect
        end
        
        subgraph Views["Blockchain Views"]
            Account["Account View"]:::ui
            Transaction["Transaction View"]:::ui
            Operations["Operations View"]:::ui
            Ledger["Ledger View"]:::ui
            
            BlockchainViews --> Account
            BlockchainViews --> Transaction
            BlockchainViews --> Operations
            BlockchainViews --> Ledger
        end
        
        subgraph Shared["Shared Components"]
            DataFetch["Data Fetching Container"]:::component
            Spinner["Loading Spinner"]:::ui
            Error["Error Display"]:::ui
            
            SharedComp --> DataFetch
            SharedComp --> Spinner
            SharedComp --> Error
        end
    end
    
    subgraph Backend["Backend Integration"]
        Network["Network Configuration"]:::service
        Server["Server Interface"]:::service
        StellarSDK["Stellar SDK"]:::service
        
        Network --> Server
        Server --> StellarSDK
    end
    
    subgraph Services["Data Services"]
        Utils["Stellar Utils"]:::service
        DataProc["Data Processing"]:::service
        SearchSvc["Search Service"]:::service
    end
    
    subgraph Infrastructure["Build & Deploy"]
        Webpack["Webpack"]:::infra
        Docker["Docker Container"]:::infra
        K8s["Kubernetes"]:::infra
        
        Webpack --> Docker
        Docker --> K8s
    end
    
    User --> App
    NetSelect --> Network
    DataFetch --> Server
    Server --> Services
    Services --> BlockchainViews
    
    classDef react fill:#61dafb
    classDef component fill:#3498db
    classDef ui fill:#95a5a6
    classDef service fill:#2ecc71
    classDef infra fill:#34495e
    
    click App "https://github.com/pi-apps/pi-explorer/blob/development/src/App.js"
    click Layout "https://github.com/pi-apps/pi-explorer/tree/development/src/components/layout/"
    click Account "https://github.com/pi-apps/pi-explorer/blob/development/src/components/Account.js"
    click Transaction "https://github.com/pi-apps/pi-explorer/blob/development/src/components/Transaction.js"
    click Operations "https://github.com/pi-apps/pi-explorer/tree/development/src/components/operations/"
    click Ledger "https://github.com/pi-apps/pi-explorer/blob/development/src/components/Ledger.js"
    click DataFetch "https://github.com/pi-apps/pi-explorer/blob/development/src/components/shared/DataFetchingContainer.js"
    click Spinner "https://github.com/pi-apps/pi-explorer/blob/development/src/components/shared/Spinner.js"
    click Error "https://github.com/pi-apps/pi-explorer/blob/development/src/components/shared/Error.js"
    click I18n "https://github.com/pi-apps/pi-explorer/tree/development/src/languages/"
    click LangSelect "https://github.com/pi-apps/pi-explorer/blob/development/src/components/layout/LanguageSelector.js"
    click NetSelect "https://github.com/pi-apps/pi-explorer/blob/development/src/components/layout/NetworkSelector.js"
    click StellarSDK "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/stellar/sdk.js"
    click Server "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/stellar/server.js"
    click Network "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/stellar/networks.js"
    click Webpack "https://github.com/pi-apps/pi-explorer/blob/development/config/webpack.config.prod.js"
    click Docker "https://github.com/pi-apps/pi-explorer/tree/development/Dockerfile"
    click K8s "https://github.com/pi-apps/pi-explorer/blob/development/kubernetes/config/app.yaml"
    click Utils "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/stellar/utils.js"
    click DataProc "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/utils.js"
    click SearchSvc "https://github.com/pi-apps/pi-explorer/blob/development/src/lib/search.js"
```
