Skip to content

Commit dc9e5aa

Browse files
authored
Merge pull request #2 from openSVM/openSVM_opensvm-mobile_issue_1_0d2a9234
Fix docs (Run ID: openSVM_opensvm-mobile_issue_1_0d2a9234)
2 parents f14e4c4 + 119792b commit dc9e5aa

File tree

6 files changed

+1303
-0
lines changed

6 files changed

+1303
-0
lines changed

ARCHITECTURE.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# OpenSVM Mobile Architecture
2+
3+
This document provides a detailed overview of the OpenSVM Mobile application architecture, explaining the project structure, key components, data flow, and design patterns.
4+
5+
## Application Architecture
6+
7+
OpenSVM Mobile follows a modular architecture with clear separation of concerns:
8+
9+
```mermaid
10+
graph TD
11+
A[App Entry] --> B[Navigation]
12+
B --> C[Screens]
13+
C --> D[Components]
14+
D --> E[Hooks]
15+
E --> F[Stores]
16+
F --> G[API/WebSocket]
17+
```
18+
19+
### Key Architectural Components
20+
21+
1. **Navigation (Expo Router)**: Handles routing and navigation between screens
22+
2. **Screens**: Main UI views for different app sections
23+
3. **Components**: Reusable UI elements
24+
4. **Hooks**: Custom React hooks for business logic and data fetching
25+
5. **Stores**: Global state management using Zustand
26+
6. **API/WebSocket**: Communication with backend services
27+
28+
## Directory Structure
29+
30+
### `/app` Directory
31+
32+
The `/app` directory uses Expo Router's file-based routing system:
33+
34+
- `_layout.tsx`: Root layout component with global styling and navigation setup
35+
- `(tabs)/_layout.tsx`: Tab-based navigation configuration
36+
- `(tabs)/index.tsx`: Explorer screen (home)
37+
- `(tabs)/validators.tsx`: Validator monitoring screen
38+
- `(tabs)/solanow.tsx`: SIMD-0228 proposal screen
39+
- `(tabs)/wallet.tsx`: Wallet management screen
40+
- `(tabs)/ai.tsx`: AI Assistant screen
41+
- `account/[id].tsx`: Dynamic route for account details
42+
- `transaction/[id].tsx`: Dynamic route for transaction details
43+
44+
### `/components` Directory
45+
46+
Reusable UI components organized by functionality:
47+
48+
- `NetworkStats.tsx`: Displays blockchain network statistics
49+
- `ValidatorAnalytics.tsx`: Shows validator performance metrics
50+
- `AIAssistant.tsx`: AI chat interface for user assistance
51+
- `SearchBar.tsx`: Search functionality for blockchain data
52+
- `WalletButton.tsx`: Wallet connection button
53+
- `charts/`: Visualization components for data display
54+
- `LineChart.tsx`: Line chart for time-series data
55+
- `GlobeVisualization.tsx`: Global map of validator distribution
56+
- `MetricsGrid.tsx`: Grid display of performance metrics
57+
58+
### `/hooks` Directory
59+
60+
Custom React hooks for data fetching and business logic:
61+
62+
- `use-validator-metrics.ts`: Fetches and processes validator performance data
63+
- `use-network-stats.ts`: Retrieves blockchain network statistics
64+
- `use-websocket.ts`: WebSocket connection management
65+
- `use-github-discussions.ts`: Fetches GitHub discussion data for SIMD proposal
66+
67+
### `/stores` Directory
68+
69+
Zustand stores for global state management:
70+
71+
- `wallet-store.ts`: Manages wallet connection state and address
72+
- `theme-store.ts`: Handles application theme settings
73+
74+
### `/constants` Directory
75+
76+
Application-wide constants:
77+
78+
- `colors.ts`: Color palette for UI elements
79+
- `typography.ts`: Typography settings
80+
81+
### `/utils` Directory
82+
83+
Utility functions:
84+
85+
- `address-utils.ts`: Helper functions for Solana address formatting
86+
87+
### `/types` Directory
88+
89+
TypeScript type definitions:
90+
91+
- `blockchain.ts`: Types for blockchain data structures
92+
93+
### `/mocks` Directory
94+
95+
Mock data for development and testing:
96+
97+
- `github-thread.ts`: Mock GitHub discussion data
98+
99+
## Data Flow
100+
101+
### Validator Monitoring Flow
102+
103+
```mermaid
104+
sequenceDiagram
105+
participant User
106+
participant UI as Validator Screen
107+
participant Hook as useValidatorMetrics
108+
participant WebSocket
109+
participant Store as State Store
110+
111+
User->>UI: Open Validators Tab
112+
UI->>Hook: Request Validator Data
113+
Hook->>WebSocket: Connect to WebSocket
114+
WebSocket-->>Hook: Stream Validator Updates
115+
Hook-->>Store: Update Validator State
116+
Store-->>UI: Render Updated Data
117+
User->>UI: Select Validator
118+
UI->>Hook: Get Validator Details
119+
Hook-->>UI: Return Detailed Data
120+
UI-->>User: Display Validator Details
121+
```
122+
123+
### Wallet Connection Flow
124+
125+
```mermaid
126+
sequenceDiagram
127+
participant User
128+
participant UI as Wallet Screen
129+
participant Store as Wallet Store
130+
participant Storage as AsyncStorage
131+
132+
User->>UI: Open Wallet Tab
133+
UI->>Store: Check Connection Status
134+
Store->>Storage: Retrieve Saved State
135+
Storage-->>Store: Return Saved State
136+
Store-->>UI: Display Connection Status
137+
User->>UI: Press Connect Button
138+
UI->>Store: Call connect()
139+
Store->>Storage: Save Connection State
140+
Store-->>UI: Update UI with Connected State
141+
UI-->>User: Show Wallet Details
142+
```
143+
144+
## State Management
145+
146+
The application uses Zustand for state management with the following stores:
147+
148+
1. **Wallet Store**: Manages wallet connection state
149+
- `isConnected`: Boolean indicating connection status
150+
- `address`: Connected wallet address
151+
- `connect()`: Function to connect wallet
152+
- `disconnect()`: Function to disconnect wallet
153+
154+
2. **Theme Store**: Manages application theme
155+
- `theme`: Current theme (light/dark)
156+
- `setTheme()`: Function to change theme
157+
158+
## UI Component Hierarchy
159+
160+
```mermaid
161+
graph TD
162+
A[App Layout] --> B[Tab Navigation]
163+
B --> C1[Explorer Screen]
164+
B --> C2[Validators Screen]
165+
B --> C3[SIMD Screen]
166+
B --> C4[Wallet Screen]
167+
B --> C5[AI Screen]
168+
169+
C1 --> D1[SearchBar]
170+
C1 --> D2[NetworkStats]
171+
C1 --> D3[ValidatorAnalytics]
172+
C1 --> D4[RecentBlocks]
173+
C1 --> D5[AIAssistant]
174+
175+
C2 --> E1[MetricsGrid]
176+
C2 --> E2[GlobeVisualization]
177+
C2 --> E3[LineChart]
178+
C2 --> E4[ValidatorListItem]
179+
180+
C3 --> F1[TabNavigation]
181+
F1 --> F2[EmissionMechanism]
182+
F1 --> F3[StakingCalculator]
183+
F1 --> F4[Discussion]
184+
185+
C4 --> G1[WalletConnect]
186+
C4 --> G2[WalletDetails]
187+
188+
C5 --> H1[AIAssistant]
189+
```
190+
191+
## Key Features Implementation
192+
193+
### Blockchain Explorer
194+
195+
The Explorer screen (`app/(tabs)/index.tsx`) provides a search interface for blockchain data and displays network statistics. It uses the `SearchBar` component for queries and `NetworkStats` to show current blockchain metrics.
196+
197+
### Validator Monitoring
198+
199+
The Validators screen (`app/(tabs)/validators.tsx`) displays real-time validator performance metrics. It uses the `useValidatorMetrics` hook to fetch and process validator data, and visualizes it using various chart components.
200+
201+
### SIMD-0228 Proposal
202+
203+
The SIMD screen (`app/(tabs)/solanow.tsx`) provides an interactive simulation of the proposed market-based emission mechanism. It includes formula visualization, interactive sliders, and a staking calculator.
204+
205+
### Wallet Management
206+
207+
The Wallet screen (`app/(tabs)/wallet.tsx`) allows users to connect their Solana wallet and view their address. It uses the `useWalletStore` for state management and persists connection state using AsyncStorage.
208+
209+
### AI Assistant
210+
211+
The AI Assistant (`app/(tabs)/ai.tsx` and `components/AIAssistant.tsx`) provides a chat interface for users to ask questions about Solana and receive assistance with using the application.
212+
213+
## Future Architecture Considerations
214+
215+
1. **Real API Integration**: Replace mock data with real API endpoints for blockchain data
216+
2. **Wallet SDK Integration**: Integrate with Solana wallet SDKs for full wallet functionality
217+
3. **Offline Support**: Implement caching and offline capabilities
218+
4. **Performance Optimization**: Optimize rendering and data processing for large datasets
219+
5. **Testing Strategy**: Implement comprehensive testing for components and business logic

0 commit comments

Comments
 (0)