|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Rocket.Chat React Native mobile client. Single-package React Native app (not a monorepo) using Yarn 1.22.22 (npm won't work). Supports iOS 13.4+ and Android 6.0+. |
| 8 | + |
| 9 | +- React 19, React Native 0.79, Expo 53 |
| 10 | +- TypeScript with strict mode, baseUrl set to `app/` (imports resolve from there) |
| 11 | +- Min Node: 22.14.0 |
| 12 | + |
| 13 | +## Commands |
| 14 | + |
| 15 | +```bash |
| 16 | +# Install & setup |
| 17 | +yarn # Install dependencies (postinstall runs patch-package) |
| 18 | +yarn pod-install # Install iOS CocoaPods (required before iOS builds) |
| 19 | + |
| 20 | +# Run |
| 21 | +yarn start # Start Metro bundler |
| 22 | +yarn ios # Build and run on iOS |
| 23 | +yarn android # Build and run on Android |
| 24 | + |
| 25 | +# Test |
| 26 | +TZ=UTC yarn test # Run Jest unit tests (TZ=UTC is set in script) |
| 27 | +yarn test -- --testPathPattern='path/to/test' # Run a single test file |
| 28 | +yarn test-update # Update snapshots |
| 29 | + |
| 30 | +# Lint & format |
| 31 | +yarn lint # ESLint + TypeScript compiler check |
| 32 | +yarn prettier-lint # Prettier auto-fix + lint |
| 33 | + |
| 34 | +# Storybook |
| 35 | +yarn storybook:start # Start Metro with Storybook UI |
| 36 | +yarn storybook-generate # Generate story snapshots |
| 37 | +``` |
| 38 | + |
| 39 | +## Code Style |
| 40 | + |
| 41 | +- **Prettier**: tabs, single quotes, 130 char width, no trailing commas, arrow parens avoid, bracket same line |
| 42 | +- **ESLint**: `@rocket.chat/eslint-config` base with React, React Native, TypeScript, Jest plugins |
| 43 | +- **Before committing**: Run `yarn prettier-lint` and `TZ=UTC yarn test` for modified files |
| 44 | +- Pre-commit hooks enforce these checks |
| 45 | + |
| 46 | +## Architecture |
| 47 | + |
| 48 | +### State Management: Redux + Redux-Saga |
| 49 | + |
| 50 | +- **Actions** (`app/actions/`) — plain action creators |
| 51 | +- **Reducers** (`app/reducers/`) — state shape (app, login, connect, rooms, encryption, etc.) |
| 52 | +- **Sagas** (`app/sagas/`) — side effects (init, login, rooms, messages, encryption, deepLinking, videoConf) |
| 53 | +- **Selectors** (`app/selectors/`) — memoized with reselect |
| 54 | +- **Store** (`app/lib/store/`) — configures middleware (saga, app state, internet state) |
| 55 | + |
| 56 | +### Navigation: React Navigation 7 |
| 57 | + |
| 58 | +- **Stacks** (`app/stacks/`) — InsideStack (authenticated), OutsideStack (login/register), MasterDetailStack (tablets), ShareExtensionStack |
| 59 | +- **Root** (`app/AppContainer.tsx`) — switches between auth states |
| 60 | +- **Responsive layout** (`app/lib/hooks/useResponsiveLayout/`) — master-detail on tablets vs single stack on phones |
| 61 | + |
| 62 | +### Database: WatermelonDB (offline-first SQLite) |
| 63 | + |
| 64 | +- **Models** (`app/lib/database/model/`) — Message, Room, Subscription, User, Thread, Upload, Server, CustomEmoji, Permission, Role, etc. |
| 65 | +- **Schema** (`app/lib/database/schema/`) |
| 66 | +- Local-first: UI reads from DB, sagas sync with server |
| 67 | + |
| 68 | +### API Layer |
| 69 | + |
| 70 | +- **SDK** (`app/lib/services/sdk.ts`) — Rocket.Chat JS SDK for WebSocket real-time subscriptions |
| 71 | +- **REST** (`app/lib/services/restApi.ts`) — HTTP via fetch |
| 72 | +- **Connect** (`app/lib/services/connect.ts`) — server connection management |
| 73 | + |
| 74 | +### Views & Components |
| 75 | + |
| 76 | +- **Views** (`app/views/`) — 70+ screen components |
| 77 | +- **Containers** (`app/containers/`) — reusable UI components |
| 78 | +- **Theme** (`app/theme.tsx`) — theming context |
| 79 | + |
| 80 | +### Other Key Systems |
| 81 | + |
| 82 | +- **i18n** (`app/i18n/`) — i18n-js with 40+ locales, RTL support |
| 83 | +- **Encryption** (`app/lib/encryption/`) — E2E encryption via @rocket.chat/mobile-crypto |
| 84 | +- **Enterprise** (`app/ee/`) — Omnichannel/livechat features |
| 85 | +- **Definitions** (`app/definitions/`) — shared TypeScript types |
| 86 | +- **VideoConf** (`app/sagas/videoConf.ts`, `app/lib/methods/videoConf.ts`) — server-managed video conferencing (Jitsi); uses Redux actions/reducers/sagas. May be replaced or removed in the future. |
| 87 | +- **VoIP** (`app/lib/services/voip/`) — new WebRTC peer-to-peer audio calls with native CallKit (iOS) and Telecom (Android) integration; uses Zustand stores, not Redux. VoIP and VideoConf are entirely separate features — do not conflate them. |
| 88 | + |
| 89 | +### Entry Points |
| 90 | + |
| 91 | +- `index.js` — registers app, conditionally loads Storybook |
| 92 | +- `app/index.tsx` — Redux provider, theme, navigation, notifications setup |
| 93 | +- `app/AppContainer.tsx` — root navigation container |
0 commit comments