# ericjoel25/gestorprestamos architecture

> Architecture diagram of the GitHub repository ericjoel25/gestorprestamos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ericjoel25/gestorprestamos
- Repository: https://github.com/ericjoel25/gestorprestamos

## Overview

1. **What this repository is**
   - Cobrapp is a **React Native mobile app** for loan management.
   - The architecture is **offline-first**: the core product runs locally on the device, with optional cloud backup/synchronization.

2. **Top-level runtime shape**
   - The app is a single mobile client built with **JavaScript/TypeScript React Native**.
   - Shared UI and logic live in `src/`, while `android/` and `ios/` contain the native shells, app configuration, and platform bootstrap code.

3. **Application entry and bootstrapping**
   - `index.js` and `App.tsx` are the main JavaScript entry points.
   - The app is likely initialized through React context/providers and then handed off to the navigation stack.
   - Tests are set up with Jest and React Native Testing Library style structure (`__tests__/App.test.tsx`).

4. **Navigation and screen composition**
   - `src/navigation/` defines the main route structure:
     - bottom tabs,
     - drawer navigation,
     - stack navigators for home, clients, and expenses.
   - This suggests a **shell-and-feature** model: navigation is the app’s top-level composition layer, and feature modules are embedded as screens.

5. **Feature-centric module structure**
   - The app is split by business capability under `src/modules/`, not by generic UI layers.
   - Main domains include:
     - **home / dashboard**
     - **client management**
     - **loan registration and updates**
     - **collections and payment history**
     - **late payments**
     - **expense control**
     - **notes**
     - **notifications**
     - **settings**
     - **support/tutorials**
     - **premium / ads**
     - **sync / backup**
   - This is the core architecture boundary for most business logic.

6. **Local persistence layer**
   - `src/db/` is the primary data subsystem and appears to be backed by a local relational database, likely SQLite.
   - It is organized by domain tables:
     - clients
     - clients without loans
     - payments
     - expenses
     - late fee
     - notes
     - notifications
     - settings
   - Each domain has create/insert/query/update/delete files, which indicates a **table-centric repository layer** rather than a remote API-driven backend.

7. **Offline data flow**
   - User actions in modules write to the local DB through the corresponding table helpers.
   - Screens then read from the same local DB to render current state, histories, summaries, and reports.
   - The app therefore uses the device database as the **system of record** for day-to-day operation.

8. **Shared state and cross-cutting hooks**
   - `src/hooks/` contains shared state and computed loan logic.
   - This layer likely bridges UI modules with the database and derived calculations, such as loan balance, payment schedule, or summary state.
   - It acts as the main boundary for reusable business state that multiple screens need.

9. **Common utilities and app-wide services**
   - `src/utils/` contains reusable services for:
     - formatting numbers, phone numbers, locale-aware text,
     - encryption,
     - responsive layout,
     - colors, typography, animation,
     - print/share helpers,
     - toast and ad-related flows,
     - async storage.
   - These utilities are shared infrastructure rather than feature logic.

10. **Documents, PDF, and export flows**
    - The collection and payment modules include HTML templates and PDF/share helpers.
    - The app can generate contracts, receipts, and payment documents, then share or print them.
    - This is a major user-facing output path: database data is transformed into formatted documents for external use.

11. **Synchronization and backup**
    - `src/modules/synchronizeData/` contains background fetch, backup upload/download, and database merge logic.
    - There is a Google Drive storage submodule, so cloud sync is an **optional external service integration**, not the core app runtime.
    - This subsystem likely handles reconciling local data with cloud backups when connectivity is available.

12. **Native platform integration**
    - `android/` and `ios/` are standard React Native native projects, but the presence of backup, printing, camera, and notification-related modules suggests the app depends on native capabilities.
    - Android includes a `google-services.json`, indicating Firebase/Google services integration may be present.
    - The native shells mainly provide permissions, build configuration, assets, and platform runtime support.

13. **UI composition and reusable components**
    - `src/components/` holds reusable presentation primitives such as headers, buttons, modals, error boundaries, and alerts.
    - These are shared across feature modules and provide consistent interaction patterns.
    - Modal-heavy UI suggests the app is designed around task flows like registration, confirmation, review, and selection rather than page navigation alone.

14. **Localization and user formatting**
    - `src/locales/` supports at least English, Spanish, and Portuguese.
    - `src/utils/format/` centralizes locale-aware formatting and country-specific behavior.
    - This matters architecturally because many business screens depend on localized labels, date/phone formatting, and currency-like display rules.

15. **Non-functional concerns**
    - `src/components/ErrorBoundary/` and toast/ads helpers show attention to app stability and monetization/support flows.
    - The repository includes linting, formatting, Babel/Metro, and platform build configuration, but the main architectural story is still a **self-contained offline mobile system with local data, document generation, and optional cloud backup**.

Main entry points: [`src/navigation`](https://github.com/ericjoel25/gestorprestamos/tree/main/src/navigation) (Navigation), [`src/db`](https://github.com/ericjoel25/gestorprestamos/tree/main/src/db) (Local DB), [`src/modules/collection`](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/collection) (Collections), [`App.tsx`](https://github.com/ericjoel25/gestorprestamos/blob/main/App.tsx) (App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App shell"]
  node_node_index["index.js<br/>RN entry<br/>[index.js]"]
  node_node_app["App<br/>root UI<br/>[App.tsx]"]
  node_node_nav{{"Navigation<br/>route shell"}}
end

subgraph group_group_features["Feature modules"]
  node_node_home["Home<br/>dashboard"]
  node_node_clients["Clients<br/>client mgmt"]
  node_node_register["Loan register<br/>loan flow"]
  node_node_collection["Collections<br/>payments"]
  node_node_expenses["Expenses<br/>expense tracking"]
  node_node_notes["Notes"]
  node_node_notifications["Notifications<br/>alerts"]
  node_node_settings["Settings<br/>preferences"]
  node_node_support["Support<br/>help"]
end

subgraph group_group_data["Data layer"]
  node_node_sync{{"Sync backup<br/>cloud sync"}}
  node_node_db[("Local DB<br/>sqlite store")]
end

subgraph group_group_shared["Shared infrastructure"]
  node_node_hooks["Shared hooks<br/>state/logic"]
  node_node_components["UI components<br/>shared UI"]
  node_node_utils["Utilities<br/>shared services"]
  node_node_locales["Locales<br/>i18n"]
end

subgraph group_group_native["Native platforms"]
  node_node_android["Android<br/>native shell"]
  node_node_ios["iOS<br/>native shell"]
end

node_node_index -->|"boots"| node_node_app
node_node_app -->|"composes"| node_node_nav
node_node_nav -->|"routes to"| node_node_home
node_node_nav -->|"routes to"| node_node_clients
node_node_nav -->|"routes to"| node_node_register
node_node_nav -->|"routes to"| node_node_collection
node_node_nav -->|"routes to"| node_node_expenses
node_node_nav -->|"routes to"| node_node_notes
node_node_nav -->|"routes to"| node_node_notifications
node_node_nav -->|"routes to"| node_node_settings
node_node_nav -->|"routes to"| node_node_support
node_node_home -->|"reads state"| node_node_hooks
node_node_clients -->|"reads/writes"| node_node_db
node_node_register -->|"reads/writes"| node_node_db
node_node_collection -->|"reads/writes"| node_node_db
node_node_collection -->|"exports docs"| node_node_utils
node_node_expenses -->|"reads/writes"| node_node_db
node_node_notes -->|"reads/writes"| node_node_db
node_node_notifications -->|"reads/writes"| node_node_db
node_node_settings -->|"uses"| node_node_utils
node_node_hooks -->|"derives from"| node_node_db
node_node_sync -->|"merges"| node_node_db
node_node_sync -->|"uses"| node_node_utils
node_node_sync -->|"supports"| node_node_collection
node_node_components -->|"supports UI"| node_node_home
node_node_components -->|"supports UI"| node_node_collection
node_node_components -->|"supports UI"| node_node_expenses
node_node_utils -->|"formats for"| node_node_locales
node_node_android -->|"hosts"| node_node_app
node_node_ios -->|"hosts"| node_node_app

click node_node_index "https://github.com/ericjoel25/gestorprestamos/blob/main/index.js"
click node_node_app "https://github.com/ericjoel25/gestorprestamos/blob/main/App.tsx"
click node_node_nav "https://github.com/ericjoel25/gestorprestamos/tree/main/src/navigation"
click node_node_home "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/home"
click node_node_clients "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/clientsNoLoan"
click node_node_register "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/registerLoan"
click node_node_collection "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/collection"
click node_node_expenses "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/expenseControl"
click node_node_notes "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/note"
click node_node_notifications "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/notification"
click node_node_settings "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/settings"
click node_node_support "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/support"
click node_node_sync "https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/synchronizeData"
click node_node_db "https://github.com/ericjoel25/gestorprestamos/tree/main/src/db"
click node_node_hooks "https://github.com/ericjoel25/gestorprestamos/tree/main/src/hooks"
click node_node_components "https://github.com/ericjoel25/gestorprestamos/tree/main/src/components"
click node_node_utils "https://github.com/ericjoel25/gestorprestamos/tree/main/src/utils"
click node_node_locales "https://github.com/ericjoel25/gestorprestamos/tree/main/src/locales"
click node_node_android "https://github.com/ericjoel25/gestorprestamos/tree/main/android"
click node_node_ios "https://github.com/ericjoel25/gestorprestamos/tree/main/ios"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_index,node_node_app,node_node_nav toneBlue
class node_node_home,node_node_clients,node_node_register,node_node_collection,node_node_expenses,node_node_notes,node_node_notifications,node_node_settings,node_node_support toneAmber
class node_node_sync,node_node_db toneMint
class node_node_hooks,node_node_components,node_node_utils,node_node_locales toneRose
class node_node_android,node_node_ios toneIndigo
```

## Components

### App shell

Entry points and navigation composition

- [index.js](https://github.com/ericjoel25/gestorprestamos/blob/main/index.js): RN entry · JavaScript bootstrap for the mobile app · `index.js`
- [App](https://github.com/ericjoel25/gestorprestamos/blob/main/App.tsx): root UI · Top-level React Native app composition · `App.tsx`
- [Navigation](https://github.com/ericjoel25/gestorprestamos/tree/main/src/navigation): route shell · Bottom tabs, drawer, and stack navigators · `src/navigation`

### Feature modules

Loan-management screens and business workflows

- [Home](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/home): dashboard · Main landing and tutorial/update surface · `src/modules/home`
- [Clients](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/clientsNoLoan): client mgmt · Client list and client-without-loan workflows · `src/modules/clientsNoLoan`
- [Loan register](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/registerLoan): loan flow · Register and update loan records · `src/modules/registerLoan`
- [Collections](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/collection): payments · Payments, receipts, amortization, and PDF output · `src/modules/collection`
- [Expenses](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/expenseControl): expense tracking · Expense entry, history, and reports · `src/modules/expenseControl`
- [Notes](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/note): notes · Note creation and display flows · `src/modules/note`
- [Notifications](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/notification): alerts · Notification creation and rendering · `src/modules/notification`
- [Settings](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/settings): preferences · App configuration and PIN settings · `src/modules/settings`
- [Support](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/support): help · Tutorials and support video flows · `src/modules/support`

### Data layer

Local database and synchronization

- [Sync backup](https://github.com/ericjoel25/gestorprestamos/tree/main/src/modules/synchronizeData): cloud sync · Backup upload, download, and database merge · `src/modules/synchronizeData`
- [Local DB](https://github.com/ericjoel25/gestorprestamos/tree/main/src/db): sqlite store · Table-centric local persistence for all core domains · `src/db`

### Shared infrastructure

Reusable UI, hooks, utilities, and locale support

- [Shared hooks](https://github.com/ericjoel25/gestorprestamos/tree/main/src/hooks): state/logic · Cross-screen loan state and derived calculations · `src/hooks`
- [UI components](https://github.com/ericjoel25/gestorprestamos/tree/main/src/components): shared UI · Reusable headers, buttons, modals, and error boundaries · `src/components`
- [Utilities](https://github.com/ericjoel25/gestorprestamos/tree/main/src/utils): shared services · Formatting, encryption, storage, print, toast, and animation helpers · `src/utils`
- [Locales](https://github.com/ericjoel25/gestorprestamos/tree/main/src/locales): i18n · English, Spanish, and Portuguese translation resources · `src/locales`

### Native platforms

Android and iOS bootstrap shells

- [Android](https://github.com/ericjoel25/gestorprestamos/tree/main/android): native shell · Android app bootstrap, permissions, and build configuration · `android`
- [iOS](https://github.com/ericjoel25/gestorprestamos/tree/main/ios): native shell · iOS app bootstrap, permissions, and build configuration · `ios`

## Connections

- index.js → App: boots · Starts the root React Native component
- App → Navigation: composes · Hands off control to app navigation
- Navigation → Home: routes to · Primary dashboard and home flows
- Navigation → Clients: routes to · Client management screens
- Navigation → Loan register: routes to · Loan registration and update screens
- Navigation → Collections: routes to · Collection and payment screens
- Navigation → Expenses: routes to · Expense workflows
- Navigation → Notes: routes to · Notes screens
- Navigation → Notifications: routes to · Notification screens
- Navigation → Settings: routes to · Settings and PIN screens
- Navigation → Support: routes to · Help and tutorial screens
- Home → Shared hooks: reads state · Uses shared computed loan state
- Clients → Local DB: reads/writes · Persists client records locally
- Loan register → Local DB: reads/writes · Stores and updates loan data
- Collections → Local DB: reads/writes · Uses local payments and client data
- Collections → Utilities: exports docs · Generates and shares PDFs and receipts
- Expenses → Local DB: reads/writes · Persists expense records locally
- Notes → Local DB: reads/writes · Stores notes in the local database
- Notifications → Local DB: reads/writes · Persists notification data locally
- Settings → Utilities: uses · Relies on storage, encryption, and formatting helpers
- Shared hooks → Local DB: derives from · Computes shared state from persisted data
- Sync backup → Local DB: merges · Reconciles backup data with local database
- Sync backup → Utilities: uses · Uses storage and upload/download helpers
- Sync backup → Collections: supports · Keeps payment-related data available offline and in backup
- UI components → Home: supports UI · Shared presentation primitives used across screens
- UI components → Collections: supports UI · Modals and controls used in collection flows
- UI components → Expenses: supports UI · Shared UI primitives used in expense flows
- Utilities → Locales: formats for · Locale-aware text and numeric formatting
- Android → App: hosts · Android native runtime for the app
- iOS → App: hosts · iOS native runtime for the app
