# oraichain/oraiscan-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/oraichain/oraiscan-frontend
- Repository: https://github.com/oraichain/oraiscan-frontend

## Overview

##### Main Components
– It is built using React and organized into several layers:
– Presentational/UI Components (found in “src/components” and “public”)
– Container Components (located in “src/containers”) that manage composition and routing.
– State Management/Store (under “src/store/modules”) likely using Redux or a similar pattern.
– Helper functions, hooks (“src/hooks”), and utility libraries (“src/lib” and “src/constants”) that support business logic.
- API Service Layer: Represent the “External Backend API” (configured via REACT_APP_API_PROD) that supplies blockchain data.
- External Integrations:
– Firebase: For push notifications or messaging (as indicated by the firebase.js reference and deployment instructions).
– Wallet Integration: Managed through keplr and-orai wallet integration and configurations in environment variables.
- Deployment and Infrastructure:
– Docker & Kubernetes: Represent the containerization (see Dockerfile and k8s config files) and orchestration used for deployment.
– Firebase Hosting: As explained in the README, used for deploying the frontend.

##### Specify Relationships and Interactions
- The User’s Browser loads and executes the React SPA.
- The SPA’s UI (components/containers) communicates with the application state (store) and uses helper functions/hooks to fetch data.
- API calls (using modules in “src/lib/api.js” and hooks like useFetch/useMultiFetch) are made to the external backend.
- External integrations such as Firebase are optionally loaded (depending on the firebase.js configuration) to support additional services.
- Deployment flows: Code is built (using yarn scripts), containerized (with Docker), deployed to Kubernetes environments, or hosted via Firebase hosting.

##### Architectural Patterns and Principles
- Component-Based UI: The project is highly modularized into reusable components (each located in nested folders such as Account, Dashboard, Proposals, etc.).
- Separation of Concerns: Clear separation between UI components, container components (that handle business logic); state management and helper code.
- Environment-based Configuration: Use of .env files and environment variables (e.g., backend API URLs, wallet version) to separate configuration from code.
- Single Responsibility: Each directory (such as “src/constants”, “src/hooks”, “src/store”) is dedicated to a specific part of the application architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Browser"]:::client
    B["Oraiscan Explorer Frontend"]:::frontend
    C["External Backend API (http://localhost:5000/v1)"]:::external
    D["Firebase Integration"]:::external
    P["Public Assets"]:::frontend

    subgraph "Frontend Modules"
        F1["Presentational/UI Components"]:::frontend
        F2["Container Components"]:::frontend
        F3["State Management Modules"]:::frontend
        F4["Store Configuration"]:::frontend
        F5["Helper Functions"]:::frontend
        F6["Custom Hooks"]:::frontend
        F7["API Utilities"]:::frontend
        F8["API Config"]:::frontend
        F9["Keplr Integration"]:::frontend
        F10["WalletStation"]:::frontend
    end

    subgraph "Deployment & Infrastructure"
        E["Docker"]:::deployment
        F["Kubernetes"]:::deployment
        G["Firebase Hosting"]:::deployment
    end
    H["CI/CD & Deployment Tools"]:::deployment
    I["Environment Configuration"]:::deployment

    %% Main Flow
    A -->|"loads"| B
    B -->|"uses"| F1
    B -->|"includes"| P
    F1 --> F2
    F2 --> F3
    F3 --> F4
    F4 --> F5
    F5 --> F6
    F6 --> F7
    F7 --> F8
    F8 --> F9
    F9 --> F10
    F7 -->|"API_Call"| C
    B -->|"pushNotify"| D

    %% Deployment Flow
    H -->|"build"| E
    E -->|"orchestrate"| F
    F -->|"host"| G
    H -->|"config"| I
    I -->|"envconfig"| B

    %% Click Events for Frontend Application
    click B "https://github.com/oraichain/oraiscan-frontend/blob/master/src/index.js"
    click B "https://github.com/oraichain/oraiscan-frontend/blob/master/src/App.js"
    click F1 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/components"
    click P "https://github.com/oraichain/oraiscan-frontend/tree/master/public"
    click F2 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/containers"
    click F3 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/store/modules"
    click F4 "https://github.com/oraichain/oraiscan-frontend/blob/master/src/store/configure.js"
    click F5 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/helpers"
    click F6 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/hooks"
    click F7 "https://github.com/oraichain/oraiscan-frontend/blob/master/src/lib/api.js"
    click F8 "https://github.com/oraichain/oraiscan-frontend/tree/master/src/lib/config"
    click F9 "https://github.com/oraichain/oraiscan-frontend/blob/master/src/lib/keplr.js"
    click F10 "https://github.com/oraichain/oraiscan-frontend/blob/master/src/lib/walletStation.js"

    %% Click Events for Firebase Integration
    click D "https://github.com/oraichain/oraiscan-frontend/blob/master/firebase.json"
    click D "https://github.com/oraichain/oraiscan-frontend/blob/master/public/firebase-messaging-sw.js"

    %% Click Events for Deployment & Infrastructure
    click E "https://github.com/oraichain/oraiscan-frontend/tree/master/Dockerfile"
    click E "https://github.com/oraichain/oraiscan-frontend/blob/master/.dockerignore"
    click F "https://github.com/oraichain/oraiscan-frontend/tree/master/k8s"
    click H "https://github.com/oraichain/oraiscan-frontend/tree/master/.github/workflows"
    click I "https://github.com/oraichain/oraiscan-frontend/blob/master/.env.example"
    click I "https://github.com/oraichain/oraiscan-frontend/blob/master/.env.test.example"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef deployment fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef client fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
