How saumyaborwankar/shipi works
Purpose and Deployable Surfaces
This repository implements a vault-based note/file system across three clients and a shared API: a NestJS backend, an Expo mobile app, and an Electron desktop app. The client products center on editable Markdown, vault navigation, local persistence, and synchronization.
Entry points:
• API bootstrap: backend/src/main.ts
• Mobile route layout and initial route: mobile-app/src/app/_layout.tsx, mobile-app/src/app/index.tsx
• Desktop Electron main process and renderer: native-app/src/main/index.ts, native-app/src/renderer.tsx
Backend API Composition
The backend is a NestJS application whose root module assembles authentication, vault, and file domains: backend/src/app.module.ts. HTTP controllers expose domain operations while services contain business/data access logic:
• Authentication: backend/src/auth/auth.controller.ts, backend/src/auth/auth.service.ts
• Vault lifecycle: backend/src/vaults/vaults.controller.ts, backend/src/vaults/vaults.service.ts
• File and version operations: backend/src/files/files.controller.ts, backend/src/files/files.service.ts
This is the server-side authority for accounts, vault metadata, file metadata, and synchronized file versions.
Identity and Access Boundary
Authentication is isolated in the auth module. Registration/login DTOs define the public credential contract, and JWT protection plus a current-user decorator establish authenticated request context:
• backend/src/auth/auth.module.ts
• backend/src/auth/jwt-auth.guard.ts
• backend/src/auth/current-user.decorator.ts
Vault and file controllers should consume this identity boundary rather than accepting user identity from clients directly. User persistence is represented by backend/src/auth/user.entity.ts.
Persistence, Versioning, and Blob Storage
TypeORM-backed entities model vaults, files, and immutable or historical file versions:
• backend/src/vaults/vault.entity.ts
• backend/src/files/file.entity.ts
• backend/src/files/file-version.entity.ts
The files domain separates file/version metadata from blob payload storage through a storage-service abstraction and PostgreSQL implementation: backend/src/files/blob-storage.service.ts, backend/src/files/postgres-blob-storage.service.ts. Database setup and schema evolution are centralized in backend/src/config/database.config.ts and backend/src/migrations/1786026382578-InitTables.ts.
Mobile Client Flow
The mobile app is an Expo/React Native route-based client. It presents vault content and an editor, with application state and local vault/storage primitives beneath the UI:
• Routes: mobile-app/src/app/index.tsx, mobile-app/src/app/editor.tsx
• State and vault model: mobile-app/src/store.ts, mobile-app/src/lib/vault.ts
• Local persistence, cryptography, and synchronization: mobile-app/src/lib/storage.ts, mobile-app/src/lib/crypto.ts, mobile-app/src/lib/sync.ts
The editor and sync panel are UI boundaries over these local-first capabilities: mobile-app/src/components/shipi/MarkdownEditor.tsx, mobile-app/src/components/shipi/SyncPanel.tsx.
Desktop Client Process Boundary
The native app is an Electron Forge application with a privileged main process and isolated React renderer. Filesystem, vault, and sync behavior reside in the main process; IPC/preload form the security and control boundary:
• Main services: native-app/src/main/fsService.ts, native-app/src/main/vault.ts, native-app/src/main/sync.ts
• IPC bridge: native-app/src/main/ipc.ts, native-app/src/preload.ts, native-app/src/shared/ipc.ts
• Renderer state/UI: native-app/src/renderer/state/store.ts, native-app/src/renderer/App.tsx
The renderer owns editor/sidebar/sync presentation but should request filesystem or synchronization actions through IPC, not Node APIs directly.
Cross-Client Synchronization
Both clients maintain local vault state and expose a sync UI, while the backend stores authenticated vault/file/version records and blob data. The expected control flow is: local edit → local persistence and version/sync metadata → authenticated API synchronization → backend metadata/blob persistence → later pull/reconciliation on another client.
Relevant synchronization contracts are split by runtime:
• Mobile: mobile-app/src/lib/sync.ts
• Desktop: native-app/src/main/sync.ts, native-app/src/shared/sync.ts
• Server: backend/src/files/files.service.ts, backend/src/files/postgres-blob-storage.service.ts
Main entry points: files.service.ts Files API · app.module.ts App Module · auth.module.ts Auth Boundary · vault.ts Local Vault State
Components 19
NestJS API
Authenticated authority for synchronized vault data.
- API Bootstrap
backend/src/main.ts - App Module · Assembles auth, vault, and file domains.
backend/src/app.module.ts - Auth Boundary · Establishes trusted current-user context.
backend/src/auth/auth.module.ts - Users
backend/src/auth/user.entity.ts - Vault API · Vault lifecycle and metadata operations.
backend/src/vaults/vaults.controller.ts - Files API · File and version synchronization operations.
backend/src/files/files.service.ts - Vault Records
backend/src/vaults/vault.entity.ts - File Versions · File metadata and historical versions.
backend/src/files/file-version.entity.ts - Blob Storage · Stores file payloads separately from metadata.
backend/src/files/postgres-blob-storage.service.ts
Expo Mobile
Local-first mobile vault client.
- Mobile Routes · Vault and editor screens.
mobile-app/src/app/index.tsx - Markdown Editor
mobile-app/src/components/shipi/MarkdownEditor.tsx - Local Vault State · Local-first vault state and navigation.
mobile-app/src/lib/vault.ts - Mobile Local Storage · Persists and protects local vault content.
mobile-app/src/lib/storage.ts
Electron Desktop
Privileged main process behind an IPC boundary.
- Electron Main · Owns filesystem, vault, and sync privileges.
native-app/src/main/index.ts - Desktop Vault Services · Filesystem-backed vault behavior.
native-app/src/main/vault.ts - IPC / Preload Bridge · Exposes approved main-process actions to the renderer.
native-app/src/preload.ts - Desktop Renderer · Editor, sidebar, and sync presentation.
native-app/src/renderer/App.tsx
Sync Boundary
Cross-runtime synchronization flow.
- Mobile Sync
mobile-app/src/lib/sync.ts - Desktop Sync
native-app/src/main/sync.ts
Connections 22
- API Bootstrap → App Module: boots
- App Module → Auth Boundary: includes
- App Module → Vault API: includes
- App Module → Files API: includes
- Auth Boundary → Users: persists accounts
- Auth Boundary → Vault API: authenticated user
- Auth Boundary → Files API: authenticated user
- Vault API → Vault Records: manages
- Files API → File Versions: manages
- Files API → Blob Storage: stores payloads
- Mobile Routes → Markdown Editor: opens
- Markdown Editor → Local Vault State: edits
- Local Vault State → Mobile Local Storage: persists locally
- Local Vault State → Mobile Sync: sync metadata
- Desktop Renderer → IPC / Preload Bridge: requests privileged actions
- IPC / Preload Bridge → Electron Main: invokes
- Electron Main → Desktop Vault Services: hosts
- Desktop Vault Services → Desktop Sync: provides local vault
- Mobile Sync → Files API: authenticated API sync
- Desktop Sync → Files API: authenticated API sync
- Files API → Mobile Sync: pull versions
- Files API → Desktop Sync: pull versions