# hennyxg/accountabuddy-rn architecture

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

- Interactive diagram: https://gitdiagram.com/hennyxg/accountabuddy-rn
- Repository: https://github.com/hennyxg/accountabuddy-rn

## Overview

##### Project type and purpose
- Accountabuddy is a full-stack mobile application built with Expo/React Native (TypeScript) for iOS and Android.
- It uses Firebase as its primary backend (Auth, Firestore, Storage, Cloud Messaging) and Cloud Functions (HTTP, triggers, scheduled) to host business logic.
- It integrates with external services: Stripe (payments), OpenAI (proof verification), and FCM for push notifications.
- It implements offline-first sync via a local queue (MMKV + custom offline service).

##### File structure
- Top-level:
- App.tsx + app/ folder: Expo Router–driven file-based navigation for authentication, tabs, modals, screens.
- functions/: Firebase Cloud Functions (src/http, scheduled, triggers, notifications, utils).
- src/: Shared code for client: components, services, hooks, stores, schemas, types, utils, unistyles.
- config files: firebase.json, firestore.rules, eas.json, .github/workflows/eas-build.yml.
- tests and e2e/maestro: Jest unit tests and Maestro E2E flows.
- docs/: design docs, flows, snapshots.
- Patterns:
- MVVM/Provider pattern: QueryProvider + Zustand stores for state.
- Service layer: src/services abstracts Firebase and external-API calls.
- Offline sync: services/offline and hooks/useOfflineSync.
- Cloud Functions orchestrate payments, verifications, notifications via triggers and scheduled tasks.

##### README insights
- Minimal (“This is Accountabuddy”), but file tree and docs confirm mission: habit/task accountability, buddy system, proof submission/verification.

##### Don’t over-complicate
- Every subsystem at a high level
- Payment pipeline
- Proof verification pipeline
- Offline sync pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Mobile)" 
        direction TB
        MobileApp["Mobile App\n(Expo/React Native)"]:::client
        LocalStorage["Offline Sync\n(MMKV & Queue)"]:::storage
        FirebaseSDK["Firebase Client SDK\n(Auth, Firestore, Storage, Messaging)"]:::firebase
        StateMgmt["State Management\n(Zustand & QueryProvider)"]:::state
        ServiceLayer["Service Layer\n(Abstract Firebase & APIs)"]:::service
    end

    %% Firebase Backend
    subgraph "Firebase Backend"
        direction TB
        subgraph "Cloud Functions"
            direction TB
            subgraph "HTTP Endpoints"
                direction TB
                CreatePayment["createPaymentIntent"]:::http
                CreateSetup["createSetupIntent"]:::http
                StripeWebhook["stripeWebhook"]:::http
                VerifyProof["verifyProofOpenAI"]:::http
            end
            subgraph "Triggers"
                direction TB
                OnProof["onProofCreated"]:::trigger
                OnShare["onShareRequestCreated"]:::trigger
                OnStreak["onStreakMilestone"]:::trigger
            end
            subgraph "Scheduled Tasks"
                direction TB
                CapturePayments["capturePayments"]:::scheduled
                ExpireInvites["expireInvites"]:::scheduled
                DailyCompletions["generateDailyCompletions"]:::scheduled
            end
            subgraph "Notification Resolvers"
                direction TB
                ResolveProof["resolveOnProofVerification"]:::notification
                ResolveBuddy["resolveOnBuddyRequest"]:::notification
                ResolveShare["resolveOnShareRequest"]:::notification
            end
        end
        FirestoreDB["Firestore Database"]:::firebase
        FirebaseStorage["Firebase Storage"]:::firebase
        FirebaseAuth["Firebase Auth"]:::firebase
        FirebaseMessaging["Firebase Messaging"]:::firebase
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Stripe["Stripe API"]:::external
        OpenAI["OpenAI API"]:::external
    end

    %% Client to Firebase SDK
    MobileApp -->|"uses SDK"| FirebaseSDK
    StateMgmt -->|"manages state via"| FirebaseSDK
    ServiceLayer -->|"calls"| FirebaseSDK

    %% Client to Offline
    MobileApp <-->|"reads/writes"| LocalStorage
    LocalStorage -->|"sync queue"| FirestoreDB

    %% Client to Cloud Functions
    MobileApp -->|"HTTP Calls"| CreatePayment
    MobileApp -->|"HTTP Calls"| CreateSetup
    MobileApp -->|"HTTP Calls"| VerifyProof

    %% Cloud Functions interactions
    CreatePayment -->|"calls"| Stripe
    StripeWebhook -->|"webhook"| Stripe
    VerifyProof -->|"calls"| OpenAI
    CreatePayment -->|"writes"| FirestoreDB
    OnProof -.->|"trigger on write"| OnProof
    OnProof -->|"updates"| FirestoreDB
    OnProof -->|"sends"| FirebaseMessaging
    CapturePayments -->|"reads/writes"| FirestoreDB
    CapturePayments -->|"sends"| FirebaseMessaging

    %% Firestore, Auth, Storage, Messaging usage
    MobileApp -->|"auth/signin"| FirebaseAuth
    MobileApp -->|"data streams"| FirestoreDB
    MobileApp -->|"uploads/downloads"| FirebaseStorage
    FirebaseMessaging -->|"push"| MobileApp

    %% External via Service Layer
    ServiceLayer -->|"stripe ops"| Stripe
    ServiceLayer -->|"verification"| OpenAI

    %% Click Events - Client
    click MobileApp "https://github.com/hennyxg/accountabuddy-rn/blob/main/App.tsx"
    click MobileApp "https://github.com/hennyxg/accountabuddy-rn/tree/main/app/"
    click LocalStorage "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/utils/mmkv.ts"
    click LocalStorage "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/offline/config.ts"
    click LocalStorage "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/offline/proofQueue.ts"
    click LocalStorage "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/hooks/useOfflineSync.ts"
    click FirebaseSDK "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/firebase/auth.ts"
    click FirebaseSDK "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/firebase/firestore.ts"
    click FirebaseSDK "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/firebase/storage.ts"
    click FirebaseSDK "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/firebase/config.ts"
    click StateMgmt "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/providers/QueryProvider.tsx"
    click StateMgmt "https://github.com/hennyxg/accountabuddy-rn/tree/main/src/stores/"
    click StateMgmt "https://github.com/hennyxg/accountabuddy-rn/tree/main/src/hooks/queries/"
    click ServiceLayer "https://github.com/hennyxg/accountabuddy-rn/tree/main/src/services/"
    click ServiceLayer "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/stripe.ts"
    click ServiceLayer "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/verificationEngine.ts"
    click ServiceLayer "https://github.com/hennyxg/accountabuddy-rn/tree/main/src/services/verification/"

    %% Click Events - Cloud Functions HTTP
    click CreatePayment "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/http/createPaymentIntent.ts"
    click CreateSetup "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/http/createSetupIntent.ts"
    click StripeWebhook "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/http/stripeWebhook.ts"
    click VerifyProof "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/http/verifyProofOpenAI.ts"

    %% Click Events - Triggers
    click OnProof "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/triggers/onProofCreated.ts"
    click OnShare "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/triggers/onShareRequestCreated.ts"
    click OnStreak "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/triggers/onStreakMilestone.ts"

    %% Click Events - Scheduled
    click CapturePayments "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/scheduled/capturePayments.ts"
    click ExpireInvites "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/scheduled/expireInvites.ts"
    click DailyCompletions "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/scheduled/generateDailyCompletions.ts"

    %% Click Events - Notifications
    click ResolveProof "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/notifications/resolveOnProofVerification.ts"
    click ResolveBuddy "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/notifications/resolveOnBuddyRequest.ts"
    click ResolveShare "https://github.com/hennyxg/accountabuddy-rn/blob/main/functions/src/notifications/resolveOnShareRequest.ts"

    %% Click Events - Firestore & Config
    click FirestoreDB "https://github.com/hennyxg/accountabuddy-rn/blob/main/firestore.rules"
    click FirestoreDB "https://github.com/hennyxg/accountabuddy-rn/blob/main/firestore.indexes.json"
    click FirestoreAuth "https://github.com/hennyxg/accountabuddy-rn/blob/main/firebase.json"
    click FirebaseStorage "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/firebase/storage.ts"

    %% External Services Clicks
    click Stripe "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/stripe.ts"
    click OpenAI "https://github.com/hennyxg/accountabuddy-rn/blob/main/src/services/verification/systemVerifier.ts"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#333
    classDef storage fill:#E0F7FA,stroke:#333
    classDef firebase fill:#FFE0B2,stroke:#333
    classDef http fill:#C8E6C9,stroke:#333
    classDef trigger fill:#FFF9C4,stroke:#333
    classDef scheduled fill:#D1C4E9,stroke:#333
    classDef notification fill:#FFCCBC,stroke:#333
    classDef external fill:#CFD8DC,stroke:#333
    classDef state fill:#F8BBD0,stroke:#333
    classDef service fill:#DCEDC8,stroke:#333
```
