# kirtygupta/investrix architecture

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

- Interactive diagram: https://gitdiagram.com/kirtygupta/investrix
- Repository: https://github.com/kirtygupta/investrix

## Overview

##### Project type and purpose
- This is a full-stack web application (“Investrix”) whose goal is to match investors and SMEs, facilitate AI-powered document verification, and execute a bidding/payments system on the Aptos blockchain.
- The frontend is built in Next.js/React with TailwindCSS. There’s a backend service (Python/Express/GraphQL style), Firebase for auth & data, Gemini AI integration for KYC/document checks, and an Aptos Move module under `payment/`.

##### File structure
- Top level:
- `.env.example`, `.gitignore`, `README.md` – global configs.
- `frontend/` – Next.js app, API routes (`src/app/api/edgestore`), UI components, page routes under `src/app/dashboard`, `login`, `signup`.
- `backend/` – single service in `app.py` with dependencies in `requirements.txt`.
- `payment/` – Aptos Move smart contract module.
- Patterns & responsibilities:
- Frontend follows Next.js App Router (server and client components, API routes).
- Backend likely exposes GraphQL/REST endpoints for business logic not handled by Next.js APIs.
- Firebase config and NextAuth reside in `frontend/src/app/...` and `clientProviders.tsx`.
- The Move module in `payment/sources` implements on-chain bidding logic.

##### README for architectural clues
- Confirms tech stack: Next.js (frontend), Node/Express/GraphQL (backend), Firebase (DB & Auth), Gemini API (AI service), Aptos blockchain (payments).
- Describes authentication, matching engine, bidding, verification, and transaction recording steps.

a. Main components
- User’s Browser / Client (React UI)
- Next.js Frontend (Pages + API routes)
- Backend Service (app.py – business logic & GraphQL/REST)
- Firebase (Authentication, Firestore/Realtime DB)
- Gemini AI Service (external API)
- Aptos Blockchain (Move Module)
b. Relationships & interactions
- Browser ↔ Next.js: SSR/CSR pages, client calls to Next.js API routes.
- Next.js API routes ↔ Backend: internal HTTP/GraphQL calls for matchmaking & bidding orchestration.
- Backend ↔ Firebase: read/write user data, profiles, bid history.
- Backend ↔ Gemini API: document verification requests & results.
- Backend ↔ Aptos Node / Payment Module: submit on-chain transactions for bids/funding.
c. Architectural patterns & principles
- Layered architecture: Presentation (Next.js), Application (API, backend), Data (Firebase, blockchain).
- Separation of concerns: Authentication & real-time data in Firebase, heavy logic in backend, UI in frontend.
- Extensibility points: Next.js API routes for edge handling, backend plugins for new AI services, Move contracts for new payment flows.
d. Key technologies
- Next.js App Router, TailwindCSS, React components
- Firebase SDK & NextAuth
- Python/Express/GraphQL in `backend/app.py`
- Gemini AI (external REST API)
- Aptos Move (`payment/sources/MyPaymentModule.move`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["User Browser"]:::presentation
        NextJSFrontend["Next.js Frontend"]:::presentation
        UIComp["UI Components & Providers"]:::presentation
        FirebaseConfig["Firebase Config"]:::presentation
        subgraph "Frontend Utilities"
            direction TB
            Contracts["contracts.ts"]:::presentation
            EdgestoreLib["edgestore.ts"]:::presentation
            VerificationLib["verification.ts"]:::presentation
        end
        API["API Routes"]:::presentation
    end

    %% Application Layer
    subgraph "Backend Layer"
        direction TB
        BackendService["Backend Service (app.py)"]:::application
        BackendDeps["Backend Dependencies"]:::application
    end

    %% Data & External Layer
    subgraph "Data & External"
        direction TB
        Firebase["Firebase (Auth & DB)"]:::data
        Gemini["Gemini AI Service"]:::data
        Aptos["Aptos Blockchain"]:::data
        MoveModule["Move Module"]:::data
    end

    %% Connections
    Browser -->|"renders UI"| NextJSFrontend
    NextJSFrontend -->|"uses UI components"| UIComp
    NextJSFrontend -->|"loads config"| FirebaseConfig
    NextJSFrontend -->|"imports utils"| Contracts
    NextJSFrontend -->|"imports utils"| EdgestoreLib
    NextJSFrontend -->|"imports utils"| VerificationLib
    NextJSFrontend -->|"calls endpoints"| API
    API -->|"HTTPS"| BackendService
    BackendService -->|"requires deps"| BackendDeps
    BackendService -->|"Admin SDK"| Firebase
    BackendService -->|"VerifyDoc() REST API"| Gemini
    BackendService -->|"SubmitTxn() JSON-RPC"| Aptos
    Aptos -->|"contains"| MoveModule

    %% Click Events
    click NextJSFrontend "https://github.com/kirtygupta/investrix/tree/main/frontend/src/app"
    click API "https://github.com/kirtygupta/investrix/blob/main/frontend/src/app/api/edgestore/[...edgestore]/route.ts"
    click UIComp "https://github.com/kirtygupta/investrix/blob/main/frontend/src/components/clientProviders.tsx"
    click Contracts "https://github.com/kirtygupta/investrix/blob/main/frontend/src/lib/contracts.ts"
    click EdgestoreLib "https://github.com/kirtygupta/investrix/blob/main/frontend/src/lib/edgestore.ts"
    click VerificationLib "https://github.com/kirtygupta/investrix/blob/main/frontend/src/lib/verification.ts"
    click FirebaseConfig "https://github.com/kirtygupta/investrix/blob/main/frontend/src/app/firebase.ts"
    click BackendService "https://github.com/kirtygupta/investrix/blob/main/backend/app.py"
    click BackendDeps "https://github.com/kirtygupta/investrix/blob/main/backend/requirements.txt"
    click MoveModule "https://github.com/kirtygupta/investrix/blob/main/payment/sources/MyPaymentModule.move"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#004085,color:#004085
    classDef application fill:#D0FFD6,stroke:#0f5132,color:#0f5132
    classDef data fill:#FFE0B2,stroke:#663c00,color:#663c00
```
