A personal website with wallet-based authentication using MetaMask and Polkadot wallets.
- Node.js 18+
- pnpm
- MetaMask browser extension (for Ethereum authentication)
- Polkadot.js extension (for Polkadot authentication)
cd ~/node_home/bos-app
pnpm installThe app requires two servers to run during development:
- Frontend (Vite):
pnpm run dev- Runs on port 5173 - API Server: Python FastAPI server with integrated wallet authentication - Runs on port 4000
# Terminal 1 - API server with authentication
~/scripts/run_data_api_server.sh restart
# Terminal 2 - Frontend
pnpm run dev# Start API server first
~/scripts/run_data_api_server.sh restart
# Then start frontend
pnpm run dev~/scripts/manage_node_server.sh restart
~/scripts/run_data_api_server.sh restartThe app supports two authentication systems working together:
- Library: @shawncoe/siws-auth for Substrate-based wallets
- Wallets: Polkadot.js extension
- Usage: Wallet connection and user identity
- Features: Sign-In With Substrate protocol, persistent sessions
- Backend: Python FastAPI server with JWT tokens
- Usage: API authentication for TradingConfig and other components
- Features: Challenge-response authentication, automatic token refresh
- Storage: JWT tokens in localStorage (
accessToken,refreshToken)
- Connect Wallet: Connect your Polkadot wallet (SIWS) or MetaMask (placeholder)
- SIWS Auth: Polkadot wallets authenticate via Sign-In With Substrate
- Auto-Refresh: JWT tokens are automatically refreshed when expired
- ✅ Polkadot SIWS: Fully implemented in ConnectWallet component
- ✅ API JWT: Active in TradingConfig, Portfolio, and other components
- ✅ Token Management: Automatic refresh and localStorage persistence
Authentication endpoints are integrated into the Python API server:
GET /auth/health- Authentication service health check
- ConnectWallet: SIWS authentication for Polkadot wallets
- AuthStatus: JWT-based user status display
- TradingConfig: JWT tokens for API calls
- Portfolio: JWT tokens for API calls
- Ranks: Static API key authentication
- Storage: JWT tokens stored in localStorage (
accessToken,refreshToken) - Expiration: Access tokens expire in 1 hour, refresh tokens last longer
- Auto-refresh: Automatic token refresh on API calls
- Security: Tokens are validated on both client and server
bos-app/
├── src/
│ ├── components/
│ │ ├── ConnectMetaMask.tsx # MetaMask wallet connection (placeholder auth)
│ │ ├── ConnectWallet.tsx # Polkadot wallet connection + SIWS auth
│ │ ├── AuthStatus.tsx # JWT-based authentication status display
│ │ └── ...
│ ├── context/
│ │ ├── AuthContext.tsx # SIWS authentication context (Polkadot)
│ │ └── ...
│ ├── hooks/
│ │ ├── useWalletAuth.ts # JWT-based authentication logic
│ │ └── ...
│ ├── providers/
│ │ ├── WalletAuthProvider.tsx # JWT auth context provider
│ │ ├── MetaMaskProvider.tsx # MetaMask wallet provider
│ │ └── ...
│ └── ...
├── server.cjs # Production Express server
├── vite.config.mjs # Vite config with proxy setup
└── package.json
Note: The app uses dual authentication systems:
- SIWS: For Polkadot wallet authentication and identity
- JWT: For API access tokens in TradingConfig, Portfolio, and other components
- Frontend: Vite dev server (port 5173)
- API Backend: Python FastAPI server with JWT authentication (port 4000)
- Authentication: Dual system - SIWS for wallets, JWT for API access
SIWS System (Wallet Authentication):
- Sign-In With Substrate protocol
- Polkadot.js extension integration
- Used for wallet connection and user identity
JWT System (API Access):
- Challenge-response authentication
- Stateless JWT tokens with automatic refresh
- Used by TradingConfig, Portfolio, and other components for API calls
tmux new -s backtester tmux ls tmux attach -t backtester cd ~/node_home/bos-app cd ~/python_home/data-api-server cd ~/rust_home/rig_buy_sell cd ~/rust_home/backtester kill $(lsof -ti:5173) ~/scripts/run_data_api_server.sh restart ~/scripts/manage_node_server.sh restart