Overview
The SFLUV frontend is a modern React application built with:- Next.js 15 - App Router, Server Components, Turbo mode
- React 19 - Latest React features
- Tailwind CSS - Utility-first styling
- Radix UI - Accessible component primitives
- Privy - Wallet and authentication
- Permissionless SDK - Account abstraction (smart wallets)
- viem - Ethereum interactions
Project Structure
Tech Stack
Core Dependencies
frontend/package.json:11-75
Key Libraries
- Privy - Embedded wallet creation, social login, JWT authentication
- Permissionless - ERC-4337 account abstraction (smart wallets)
- viem - Modern Ethereum library (faster than ethers)
- Radix UI - Accessible, unstyled component primitives
- React Hook Form + Zod - Form validation
- Google Maps React - Merchant location map
App Router Structure
Pages by Role
Route Protection
Pages check role flags fromAppProvider and redirect if unauthorized:
Authentication Flow
1. User Logs In (Privy)
frontend/context/AppProvider.tsx:614-631
- Email/SMS login
- Social login (Google, Twitter, Discord)
- Wallet connection (MetaMask, Coinbase, etc.)
- Embedded wallet creation
2. Frontend Initializes User
frontend/context/AppProvider.tsx:284-313
3. API Calls Use authFetch
frontend/context/AppProvider.tsx:330-339
Wallet Management
SFLUV supports both EOA (externally owned accounts) and smart wallets.Wallet Initialization
frontend/context/AppProvider.tsx:394-450
AppWallet Class
frontend/lib/wallets/wallets.ts
State Management
Global State (Context)
All global state managed via React Context:- AppProvider - User, auth, wallets
- LocationProvider - Merchant locations
- ContactsProvider - User contacts
- TransactionProvider - Transaction history
Local State (useState)
Component-level state for UI:Styling
Tailwind CSS
Utility-first CSS framework:Radix UI Components
Accessible primitives styled with Tailwind:Component Patterns
Reusable components incomponents/ui/:
Button- Styled button with variantsInput- Form inputDialog- Modal dialogsSelect- Dropdown selectCard- Container with shadow/borderBadge- Status badges
Next Steps
React Context
Deep dive into AppProvider and LocationProvider
Components
Component structure and patterns
Testing
Frontend testing setup