# stringsaeed/brimapp architecture

> Architecture diagram of the GitHub repository stringsaeed/brimapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stringsaeed/brimapp
- Repository: https://github.com/stringsaeed/brimapp

## Overview

##### Main Components
- App Shell & Navigation:
– Represent the main Expo Router structure found under /src/app, which houses the primary screens.
– Highlight authenticated routes (e.g., Dashboard, Notes, User screens) and authentication flows (login, verify) under /src/app/auth.
- Screens & UI:
– Create modules for screens (located in /src/screens) that include Authentication, Dashboard, Notes (with archived, trashed, and detailed note views), and User screens.
– List reusable UI components (found under /src/components) like account-info, auth-layout, note title & toolboxes, bottom sheets, and animated views.
- State Management & Custom Hooks:
– Include a block for React Context providers (in /src/contexts) dedicated to managing app state (authentication, notes, pull-to-action, country-picker, etc.).
– Mark the various custom hooks (in /src/hooks) that support business logic such as note operations, layout management, haptic feedback, and internationalization.
- Services & Integrations:
– Outline the services layer (in /src/services) with sub-components for AI functionalities (grammar and text rephrasing via Google’s Gemini API), analytics (Vexo Analytics), error tracking (Sentry), voice transcription, Supabase (authentication, database operations, realtime subscriptions), and flagsmith.
- Internationalization & Theming:
– Show a module for i18n support (/src/i18n) and theming (/src/themes) controlling language translations and styling (light/dark modes, accent customizations).
- Backend and Database:
– Represent the Supabase setup (living both in the project’s /supabase directory and integrated within the services) which provides authentication, database migrations, and real-time features.

##### Relationships and Data Flow
- UI <-> Navigation:
- UI Components & State Management:
– Illustrate how UI components consume data provided by Contexts and custom hooks.
- API & Service Integration:
– Connect the services layer to the UI, indicating that components (and hooks) call out to AI, analytics, and Supabase backends.
- External Integrations:
– Represent integrations with external tools and services like Sentry for error tracking and Gemini API for AI, ensuring they are clearly marked.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Modular Architecture:
– Indicate the organization into mode-specific folders (screens, components, services, hooks, contexts) to emphasize reusability and clear boundaries.
- Real-Time and Asynchronous Flow:
– Mark areas indicating real-time data flow coming from Supabase and asynchronous API calls (e.g., for voice transcription and grammar fixing).

##### Incorporate Key Technologies, Frameworks, and Patterns
- Clearly label:
– Frontend frameworks: React Native, Expo Router, Tamagui UI components.
– Backend and Integrations: Supabase, Google’s Gemini API, Sentry, Vexo Analytics.
– State management: React Context providers and custom hooks.
– Development tools: Testing with Jest, code formatting (ESLint/Prettier), and build/deployment with EAS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        node1["Expo Router Structure"]
        node2["Authenticated Routes & Authentication Flows"]
        node3["Main Screens (Authentication, Dashboard, Notes, User)"]
        node4["Reusable UI Components"]
    end

    %% Business Logic & State Management
    subgraph "Business Logic & State Management"
        node5["React Context Providers"]
        node6["Custom Hooks"]
    end

    %% Services & Integrations
    subgraph "Services & Integrations"
        node7["AI Functionalities"]
        node8["Analytics"]
        node9["Error Tracking (Sentry)"]
        node10["Voice Transcription"]
        node11["Supabase Services"]
        node12["Flagsmith Integration"]
    end

    %% Support Services
    subgraph "Support Services"
        node13["Internationalization Support"]
        node14["Theming Support"]
    end

    %% Backend and Database
    subgraph "Backend and Database"
        node15["Supabase Database"]
    end

    %% Connections within Presentation Layer
    node1 -->|"routes_to"| node2
    node1 -->|"navigates_to"| node3
    node3 -->|"composes"| node4

    %% Connections from Presentation to Business Logic
    node2 -->|"authenticates"| node5
    node3 -->|"uses_state"| node5
    node4 -->|"uses_hooks"| node6

    %% Connections from Business Logic to Services & Integrations
    node5 -->|"calls_AI"| node7
    node5 -->|"calls_Analytics"| node8
    node5 -->|"calls_Sentry"| node9
    node5 -->|"calls_Voice"| node10
    node5 -->|"calls_Supabase"| node11
    node5 -->|"calls_Flagsmith"| node12
    node6 -->|"calls_Supabase"| node11

    %% Connection from Services to Backend
    node11 -->|"syncs_with"| node15

    %% Support Services connections to Presentation Layer
    node13 -->|"supports"| node3
    node14 -->|"styles"| node4

    %% Click Events
    click node1 "https://github.com/stringsaeed/brimapp/tree/main/src/app"
    click node2 "https://github.com/stringsaeed/brimapp/tree/main/src/app/auth"
    click node3 "https://github.com/stringsaeed/brimapp/tree/main/src/screens"
    click node4 "https://github.com/stringsaeed/brimapp/tree/main/src/components"
    click node5 "https://github.com/stringsaeed/brimapp/tree/main/src/contexts"
    click node6 "https://github.com/stringsaeed/brimapp/tree/main/src/hooks"
    click node7 "https://github.com/stringsaeed/brimapp/tree/main/src/services/ai"
    click node8 "https://github.com/stringsaeed/brimapp/tree/main/src/services/vexo"
    click node9 "https://github.com/stringsaeed/brimapp/tree/main/src/services/sentry"
    click node10 "https://github.com/stringsaeed/brimapp/tree/main/src/services/voice-transcription"
    click node11 "https://github.com/stringsaeed/brimapp/tree/main/src/services/supabase"
    click node12 "https://github.com/stringsaeed/brimapp/tree/main/src/services/flagsmith"
    click node13 "https://github.com/stringsaeed/brimapp/tree/main/src/i18n"
    click node14 "https://github.com/stringsaeed/brimapp/tree/main/src/themes"
    click node15 "https://github.com/stringsaeed/brimapp/tree/main/supabase"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0277BD,stroke-width:2px,color:#000;
    classDef state fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px,color:#000;
    classDef services fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px,color:#000;
    classDef support fill:#F3E5F5,stroke:#8E24AA,stroke-width:2px,color:#000;
    classDef backend fill:#FFEBEE,stroke:#C62828,stroke-width:2px,color:#000;

    class node1,node2,node3,node4 frontend;
    class node5,node6 state;
    class node7,node8,node9,node10,node11,node12 services;
    class node13,node14 support;
    class node15 backend;
```
