# fatira-labs/fatira architecture

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

- Interactive diagram: https://gitdiagram.com/fatira-labs/fatira
- Repository: https://github.com/fatira-labs/fatira

## Overview

##### Project type and purpose
- This is a full-stack, blockchain-enabled payment-splitting system (“Fatira”).
- It comprises three main layers:
- A React Native frontend (mobile app) under the “frontend” folder
- A Node.js/Express backend and data models in “database”
- An on-chain Solana program (Anchor smart contract) in “program”

##### File structure
- Top level:
- .gitignore, LICENSE, README.md
- package-lock.json (root-level lockfile suggests combined install scripts)
- “frontend”: React Native screens, navigation, wallet connection (PhantomConnect), app.json, assets
- “database”: Express app –
- index.js (app entry)
- Expense.js, User.js (data models)
- routes/expense.js, routes/user.js (RESTful endpoints)
- utils/solana.js (calls into on-chain program)
- “program”: Solana Anchor project –
- Anchor.toml, Cargo.toml, Rust source in programs/fatira/src
- migrations/deploy.ts
- tests/fatira.ts

##### README for additional insights
- Minimal README: “An onchain payment splitting system.”
- Key implication: split payments logic lives both off-chain (group/expense management) and on-chain (settling balances).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User device
    U["End User (Mobile Device)"]:::user

    %% Frontend Layer
    subgraph "Mobile App (React Native)" 
        direction TB
        MA_App["App.js"]:::frontend
        MA_Phantom["PhantomConnect.js"]:::frontend
        subgraph "Screens & Components"
            direction TB
            MA_Add["AddExpenseScreen.js"]:::frontend
            MA_Split["SplitExpenseScreen.js"]:::frontend
            MA_CreateGrp["CreateGroupScreen.js"]:::frontend
            MA_Groups["GroupsScreen.js"]:::frontend
            MA_GroupMain["GroupMainScreen.js"]:::frontend
            MA_ViewExp["ViewExpenseScreen.js"]:::frontend
            MA_Profile["ProfilePage.js"]:::frontend
            MA_Settings["settingScreen.js"]:::frontend
            MA_BottomNav["BottomNavBar.js"]:::frontend
            MA_MoneyPay["moneyPay.js"]:::frontend
            MA_Color["color.js"]:::frontend
        end
        MA_App --> MA_Phantom
        MA_App --> MA_Add
        MA_App --> MA_Split
        MA_App --> MA_CreateGrp
        MA_App --> MA_Groups
        MA_App --> MA_GroupMain
        MA_App --> MA_ViewExp
        MA_App --> MA_Profile
        MA_App --> MA_Settings
        MA_App --> MA_BottomNav
        MA_App --> MA_MoneyPay
        MA_App --> MA_Color
        click MA_App "https://github.com/fatira-labs/fatira/blob/main/frontend/App.js"
        click MA_Phantom "https://github.com/fatira-labs/fatira/blob/main/frontend/PhantomConnect.js"
        click MA_Add "https://github.com/fatira-labs/fatira/blob/main/frontend/AddExpenseScreen.js"
        click MA_Split "https://github.com/fatira-labs/fatira/blob/main/frontend/SplitExpenseScreen.js"
        click MA_CreateGrp "https://github.com/fatira-labs/fatira/blob/main/frontend/CreateGroupScreen.js"
        click MA_Groups "https://github.com/fatira-labs/fatira/blob/main/frontend/GroupsScreen.js"
        click MA_GroupMain "https://github.com/fatira-labs/fatira/blob/main/frontend/GroupMainScreen.js"
        click MA_ViewExp "https://github.com/fatira-labs/fatira/blob/main/frontend/ViewExpenseScreen.js"
        click MA_Profile "https://github.com/fatira-labs/fatira/blob/main/frontend/ProfilePage.js"
        click MA_Settings "https://github.com/fatira-labs/fatira/blob/main/frontend/settingScreen.js"
        click MA_BottomNav "https://github.com/fatira-labs/fatira/blob/main/frontend/BottomNavBar.js"
        click MA_MoneyPay "https://github.com/fatira-labs/fatira/blob/main/frontend/moneyPay.js"
        click MA_Color "https://github.com/fatira-labs/fatira/blob/main/frontend/color.js"
    end

    %% Backend/API Layer
    subgraph "API Server (Node.js/Express)" 
        direction TB
        API_Index["index.js"]:::backend
        subgraph "Models"
            direction TB
            API_User["User.js"]:::backend
            API_Expense["Expense.js"]:::backend
        end
        subgraph "Routes"
            direction TB
            API_RUser["routes/user.js"]:::backend
            API_RExpense["routes/expense.js"]:::backend
        end
        API_SolanaUtil["utils/solana.js"]:::backend
        API_Pkg["package.json"]:::backend
        API_Index --> API_User
        API_Index --> API_Expense
        API_Index --> API_RUser
        API_Index --> API_RExpense
        API_Index --> API_SolanaUtil
        API_Index --> API_Pkg
        click API_Index "https://github.com/fatira-labs/fatira/blob/main/database/index.js"
        click API_User "https://github.com/fatira-labs/fatira/blob/main/database/User.js"
        click API_Expense "https://github.com/fatira-labs/fatira/blob/main/database/Expense.js"
        click API_RUser "https://github.com/fatira-labs/fatira/blob/main/database/routes/user.js"
        click API_RExpense "https://github.com/fatira-labs/fatira/blob/main/database/routes/expense.js"
        click API_SolanaUtil "https://github.com/fatira-labs/fatira/blob/main/database/utils/solana.js"
        click API_Pkg "https://github.com/fatira-labs/fatira/blob/main/database/package.json"
    end

    %% Database
    DB[(Database)]:::database

    %% Blockchain Layer
    subgraph "Solana Cluster & Smart Contract"
        direction TB
        SC_Cloud["Solana Network"]:::external
        subgraph "Anchor Program (fatira)"
            direction TB
            AP_AnchorToml["Anchor.toml"]:::blockchain
            AP_CargoToml["Cargo.toml"]:::blockchain
            AP_CargoLock["Cargo.lock"]:::blockchain
            AP_Pkg["package.json"]:::blockchain
            AP_TsConfig["tsconfig.json"]:::blockchain
            subgraph "programs/fatira/src"
                direction TB
                AP_Lib["lib.rs"]:::blockchain
                AP_State["state.rs"]:::blockchain
                AP_Error["error.rs"]:::blockchain
                AP_Const["constants.rs"]:::blockchain
            end
            AP_Deploy["migrations/deploy.ts"]:::blockchain
            AP_Tests["tests/fatira.ts"]:::blockchain
        end
        SC_Cloud --> AP_AnchorToml
        SC_Cloud --> AP_CargoToml
        SC_Cloud --> AP_CargoLock
        SC_Cloud --> AP_Pkg
        SC_Cloud --> AP_TsConfig
        SC_Cloud --> AP_Lib
        SC_Cloud --> AP_State
        SC_Cloud --> AP_Error
        SC_Cloud --> AP_Const
        SC_Cloud --> AP_Deploy
        SC_Cloud --> AP_Tests
        click AP_AnchorToml "https://github.com/fatira-labs/fatira/blob/main/program/Anchor.toml"
        click AP_CargoToml "https://github.com/fatira-labs/fatira/blob/main/program/Cargo.toml"
        click AP_CargoLock "https://github.com/fatira-labs/fatira/blob/main/program/Cargo.lock"
        click AP_Pkg "https://github.com/fatira-labs/fatira/blob/main/program/package.json"
        click AP_TsConfig "https://github.com/fatira-labs/fatira/blob/main/program/tsconfig.json"
        click AP_Lib "https://github.com/fatira-labs/fatira/blob/main/program/programs/fatira/src/lib.rs"
        click AP_State "https://github.com/fatira-labs/fatira/blob/main/program/programs/fatira/src/state.rs"
        click AP_Error "https://github.com/fatira-labs/fatira/blob/main/program/programs/fatira/src/error.rs"
        click AP_Const "https://github.com/fatira-labs/fatira/blob/main/program/programs/fatira/src/constants.rs"
        click AP_Deploy "https://github.com/fatira-labs/fatira/blob/main/program/migrations/deploy.ts"
        click AP_Tests "https://github.com/fatira-labs/fatira/blob/main/program/tests/fatira.ts"
    end

    %% Interactions
    U -->|"Touches UI"| MA_App
    MA_Phantom -->|"Wallet Sign"| SC_Cloud
    MA_App -->|REST API| API_Index
    API_Index -->|CRUD| DB
    API_SolanaUtil -->|Anchor RPC Calls| SC_Cloud

    classDef frontend fill:#e0f7e9,stroke:#2e7d32,color:#2e7d32;
    classDef backend fill:#e3f2fd,stroke:#1565c0,color:#1565c0;
    classDef database fill:#fff3e0,stroke:#ef6c00,color:#e65100;
    classDef blockchain fill:#f3e5f5,stroke:#6a1b9a,color:#4a148c;
    classDef external fill:#eceff1,stroke:#90a4ae,color:#546e7a;
    classDef user fill:#f1f8e9,stroke:#7cb342,color:#558b2f;
```
