# ajagtapdev/capitalx architecture

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

- Interactive diagram: https://gitdiagram.com/ajagtapdev/capitalx
- Repository: https://github.com/ajagtapdev/capitalx

## Overview

##### Main Components
- Frontend Mobile Application:
– Contains various screens (HomeScreen, CartScreen, etc.) and UI components (e.g. CardDetailsModal, ChatInterface) that interact with the user.
- Backend API Server:
– Implemented in Python with Flask (look at backend/server.py).
– Responsible for handling REST API calls, processing requests from the mobile app, and possibly interfacing with the AI models.
- External and Integrated Services:
– AI Models: “Gemma-27B” (the core AI engine for processing card data), Google Cloud Vision, and Gemini 1.5.
– Third-Party APIs: Knot API for payment processing and Knot TransactionLink functionality, Perplexity API for product or insights discovery.
– Authentication & Data Storage: Supabase for secure data storage and possibly authentication.
- Supporting Assets:
– JSON files (amazon_products.json, amazon_products_new.json) that might act as sample data or for product discovery.
– Config and initialization files like app.json, tsconfig.json, and server configuration scripts.

##### Relationships and Interactions
- The backend, in turn, connects with multiple external services:
– Sends image data (from card scans) to Google Cloud Vision.
– Invokes the Gemma-27B model for AI-driven analysis.
– Connects with the Knot API for seamless credit card switching and payment transactions.
– Queries Perplexity for product discovery insights.
- Supabase should be represented as the secure data storage/authentication layer that both the backend (and possibly frontend) depend on.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between the frontend (UI/UX, mobile interactions) and backend (data processing and API handling).
- Integration of AI and External Services: Emphasize that the backend middleware acts as a bridge between in-house features and external services/AI models.
- Service Orientation: The use of REST APIs on the backend suggests a service-oriented design that may be extended or scaled with additional microservices if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Frontend"
        A1("React Native Mobile App"):::frontend
        A2("Mobile Screens"):::frontend
        A3("UI Components"):::frontend
    end

    subgraph "Backend API"
        B1("Flask REST API"):::backend
    end

    subgraph "External Services"
        C1("Gemma-27B AI Engine"):::external
        C2("Google Cloud Vision"):::external
        C3("Gemini 1.5"):::external
        C4("Knot API(Payment)"):::external
        C5("Perplexity API"):::external
        C6("Supabase Auth&Storage"):::external
    end

    subgraph "Supporting Assets"
        D1("amazon_products.json"):::assets
        D2("amazon_products_new.json"):::assets
        D3("App Config(app.json)"):::assets
        D4("TypeScript Config(tsconfig.json)"):::assets
        D5("Package Config(package.json)"):::assets
    end

    A1 -->|"REST_API_call"| B1
    A2 -->|"UserInteraction"| A1
    A3 -->|"UI_Interaction"| A1

    B1 -->|"processes_card_data"| C2
    B1 -->|"AI_analysis"| C1
    B1 -->|"payment_request"| C4
    B1 -->|"insight_query"| C5
    B1 -->|"data_storage"| C6
    B1 -->|"uses_sample_data"| D1
    B1 -->|"uses_sample_data"| D2

    A1 -->|"config_loaded"| D3
    A1 -->|"config_loaded"| D4
    A1 -->|"config_loaded"| D5

    click A1 "https://github.com/ajagtapdev/capitalx/tree/master/frontend/"
    click A2 "https://github.com/ajagtapdev/capitalx/tree/master/frontend/screens/"
    click A3 "https://github.com/ajagtapdev/capitalx/tree/master/frontend/components/"
    click B1 "https://github.com/ajagtapdev/capitalx/blob/master/backend/server.py"
    click D1 "https://github.com/ajagtapdev/capitalx/blob/master/frontend/amazon_products.json"
    click D2 "https://github.com/ajagtapdev/capitalx/blob/master/frontend/amazon_products_new.json"
    click D3 "https://github.com/ajagtapdev/capitalx/blob/master/frontend/app.json"
    click D4 "https://github.com/ajagtapdev/capitalx/blob/master/tsconfig.json"
    click D5 "https://github.com/ajagtapdev/capitalx/blob/master/package.json"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef assets fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
