How roy-rc/react-native-wallet works
Project Type and Purpose
• This is a full-stack cross-platform mobile wallet app.
• Frontend (mobile): React Native with Expo, Clerk-backed authentication, React Navigation, custom theming, real-time updates.
• Backend: Express.js REST API, PostgreSQL (Neon), Upstash for rate-limiting, scheduled tasks via cron.
File‐Structure Analysis
A. Top-Level
– /mobile: React Native app
– /backend: Express.js server
B. /mobile
– app/ (Expo Router pages, nested by auth vs root flows)
– assets/ (fonts, images, styles)
– components/ (UI building blocks)
– hooks/, lib/ (custom hooks & utilities)
C. /backend/src
– config/ (db.js for Neon Postgres, upstash.js, cron.js)
– middleware/ (rateLimiter.js using Upstash)
– routes/ (transactionsRoute.js) → controllers/ (transactionsController.js)
– server.js (entry point)
Key Architectural Insights from README
• Client uses Clerk for authentication → issues tokens.
• Mobile → HTTP calls to backend REST endpoints (/transactions).
• Backend enforces rate-limits (Upstash), connects to Neon Postgres, and runs scheduled jobs (cron.js).
• Data flow is unidirectional: Mobile ↔ Backend ↔ Database/Cache/External Services.
a. Main Components
1. Mobile App
• Expo/React Native, Clerk SDK, React Navigation
2. Authentication Service
• External: Clerk (OAuth/JWT issuer)
3. API Gateway / Express Server
• Routes → Controllers → DB
• Middleware: rateLimiter
• Scheduled Task Runner (cron.js)
4. Database
• PostgreSQL (Neon)
5. Cache/Rate Limit Store
• Upstash (Redis)
b. Component Relationships
• Mobile App authenticates via Clerk → receives JWT → calls Express API.
• Express Middleware validates JWT, checks rate limit in Upstash.
• Controller logic reads/writes transactions in PostgreSQL.
• Cron jobs (cron.js) trigger periodic summaries or cleanup in DB.
c. Architectural Patterns & Principles
• Layered REST API: Router → Controller → Config/DB
• Single-page mobile flows with nested routing (Expo Router pattern)
• Modular separation of concerns: authentication, rate limiting, business logic, persistence.
• Externalized config for DB & cache.
d. Technologies
• Frontend: React Native, Expo, Clerk, React Navigation, Reanimated
• Backend: Node.js, Express.js, PostgreSQL (Neon), Upstash, Node‐cron