How oraichain/oraiscan-frontend works
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.