Instruction file imported from anhluu14/chrysos-trading-simulator-app (
.cursor/rules/.mdc). Copyright stays with the author.
๐ PRODUCTION READINESS RULES
- All
console.log,console.warn, andconsole.errorcalls must be removed. - Use centralized constants (e.g.
TRADING_CONFIG) for default values like100000. - Avoid hardcoded color strings; use
theme.colors.*instead. - Input validation is required on all user entry points (text input, trade actions, etc.).
- Ensure that all portfolio operations are transactional and avoid race conditions.
- All critical async operations should have loading indicators and error fallback UIs.
- Add confirmation modals for destructive actions (e.g., portfolio reset, trade sell).
- Trading components must memoize expensive calculations using
useMemoanduseCallback. - Components triggering network or state changes must wrap critical flows in
try/catch. - Ensure cleanup in components using
useEffectto prevent memory leaks (especially withWebView,Chart, orSocket).
๐งฑ ARCHITECTURE & STATE
- Balance logic, calculations, and sync functions should be moved to a shared service (e.g.
BalanceCalculator). - No duplication of portfolio sync logic โ use a single source of truth (
UserSyncService). - Always use
useSelectorwith memoized selectors when accessing Redux state. - Redux actions that affect multiple entities (balance, portfolio) should dispatch atomic updates.
๐ SECURITY & AUTH
- Do not perform any Supabase update without validating
uuid/session token first. - RLS (Row Level Security) must be enforced via Supabase policies.
- Use
Expo SecureStorefor all token or sensitive value storage. - No sensitive values (API keys, tokens) should be hardcoded in source files.
๐ฆ CONFIG & METADATA
app.jsonmust have:"privacy": "public"- valid
description,keywords, and proper permission usage descriptions.
- Ensure
Info.plistandAndroidManifest.xmldeclare necessary permissions with justifications. - Remove unused dependencies:
react-dom,dotenv,@expo/config-plugins,reflect-metadata, etc. - Add missing dependencies like
redux,lint-staged.
๐งช TESTING & STABILITY
- Trading logic must have unit tests in
__tests__/ortests/directory. - All critical screens (trade execution, portfolio view) must have error boundaries.
- Use Sentry/Bugsnag or equivalent for runtime crash reporting in production.
- Offline functionality must be simulated and tested with
NetInfostate toggles.
๐ฒ UI/UX STANDARDS
- Use
theme.colors.*โ never hardcode color strings like"#ffffff". - Use
SafeAreaViewand responsive padding/margin logic. - Show
ActivityIndicatoror skeletons during all async fetches. - Error messages should be user-friendly (not technical stack traces).
๐ DEPLOYMENT BLOCKERS (Critical Checkpoints)
- โ
All
console.logstatements are removed - โ
Privacy policy URL set in
app.json - โ Description & Keywords in metadata
- โ Camera/notification permission descriptions added
- โ Production API domains use HTTPS and certificate pinning
- โ No inline API keys or secrets
- โ RLS enforced + input validation complete
- โ Error boundaries added to all flows
- โ App assets (screenshots, icons, descriptions) are ready
๐ FINAL NOTE
These rules ensure production compliance, store readiness, and long-term maintainability. All rules must be followed before deployment to App Store or Google Play.