# ay0788/transparex architecture

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

- Interactive diagram: https://gitdiagram.com/ay0788/transparex
- Repository: https://github.com/ay0788/transparex

## Overview

##### Project type and purpose
- From the README and file tree, TranspareX is a full-stack web application prototype that combines a JavaScript/HTML/CSS frontend, a Python/Flask backend, a SQL database, AI/ML analytics, and a local Ethereum blockchain (Ganache) for secure financial transactions and transparency.

##### File structure
- Top-level directory “TranspareX-protocole” holds:
- Frontend assets: index.html, TX.HTML, style.css
- Dashboard modules: DASHBORD.JS, RealTimeDashboard.js
- Blockchain client code: blockchain.js
- Backend entrypoint & modules: app.py, routes.py, auth.py
- The presence of both static HTML/JS and Flask files suggests an MVC-ish separation:
- View: static HTML + JS
- Controller/API: Flask routes
- Model: Python data access + SQL + blockchain interactions
- No SOL files means smart contracts are likely pre-deployed or stubbed via blockchain.js.

##### README for additional insights
- Key subsystems called out:
- User-friendly interface
- Blockchain-secured transactions
- AI-driven analytics
- Real-time monitoring dashboards
- Smart contracts for fund disbursement
- Tech stack: HTML/CSS/JS frontend, Flask backend, Ethereum (Ganache), Python ML, PostgreSQL/MySQL.

##### Main components and their interactions
a. Frontend UI (Browser)
- Static pages: index.html (landing), TX.HTML (transaction UI), dashboard pages
- JavaScript modules:
– blockchain.js ⇒ handles web3 calls to Ganache
– RealTimeDashboard.js & DASHBORD.JS ⇒ fetch data and render charts/metrics
b. Backend API (Flask)
- app.py ⇒ Flask application factory
- routes.py ⇒ REST endpoints for: user operations, data ingestion, analytics queries
- auth.py ⇒ authentication & session management
- AI/ML modules (not explicitly in tree but invoked by backend for anomaly detection & forecasting)
- Database layer ⇒ SQL ORM or direct queries to Postgres/MySQL
c. Data stores & external systems
- SQL Database (Postgres or MySQL) ⇒ persistent financial records, user profiles
- Ethereum network (Ganache local) ⇒ smart contract calls, transaction ledger
d. Data flow
1. User interacts with UI (HTTP/HTTPS)
2. JS frontend calls Flask REST APIs (XHR/fetch)
3. Flask routes authenticate user (auth.py), read/write to SQL DB, trigger AI/ML analysis, or call blockchain.js wrapper to submit/fetch transactions
4. Analytics results and blockchain receipts are returned to frontend for real-time display

##### Architectural patterns & design principles
- Client-Server separation: distinct frontend (static assets + JS) vs backend API
- MVC / layered architecture:
- Presentation layer: HTML/CSS/JS
- Business logic layer: Flask + Python modules (analytics, auth, blockchain integration)
- Data layer: SQL database + Ethereum ledger
- Real-time & polling: dashboard modules can poll REST endpoints or use WebSockets (extendable)
- Modular services: authentication, analytics, blockchain interactions are separated in dedicated Python modules.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "User & Browser Layer"
        User["User / Browser"]:::user
    end

    subgraph "Presentation Layer"
        Landing["Landing Page (index.html)"]:::frontend
        TransactionUI["Transaction UI (TX.HTML)"]:::frontend
        Styles["Global Stylesheet (style.css)"]:::frontend
        RealTimeDash["Real-Time Dashboard Module (RealTimeDashboard.js)"]:::frontend
        DashboardCtrl["Dashboard Controller (DASHBORD.JS)"]:::frontend
        BlockchainClient["Blockchain Client Wrapper (blockchain.js)"]:::frontend
    end

    subgraph "API/Business Logic Layer"
        AppFactory["Flask App Factory (app.py)"]:::backend
        Auth["Auth & Session Management (auth.py)"]:::backend
        Routes["REST API Routes (routes.py)"]:::backend
        AIMLEngine["AI/ML Engine"]:::backend
    end

    subgraph "Data/Integration Layer"
        SQLDB["SQL Database"]:::data
        Ethereum["Ganache / Ethereum Network"]:::blockchain
    end

    %% Connections
    User -->|"HTTP GET"| Landing
    User -->|"HTTP GET"| TransactionUI

    Landing -->|"loads"| Styles
    Landing -->|"loads"| RealTimeDash
    Landing -->|"loads"| DashboardCtrl
    Landing -->|"loads"| BlockchainClient

    TransactionUI -->|"loads"| Styles
    TransactionUI -->|"loads"| BlockchainClient

    RealTimeDash -->|"REST API (XHR)"| Routes
    DashboardCtrl -->|"REST API (XHR)"| Routes

    BlockchainClient -->|"Web3 RPC"| Ethereum

    Routes -->|"uses"| AppFactory
    Routes -->|"auth check"| Auth
    Routes -->|"SQL queries"| SQLDB
    Routes -->|"invoke analysis"| AIMLEngine
    Routes -->|"RPC calls"| Ethereum

    %% Click Events
    click Landing "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/index.html"
    click TransactionUI "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/TX.HTML"
    click Styles "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/style.css"
    click RealTimeDash "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/RealTimeDashboard.js"
    click DashboardCtrl "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/DASHBORD.JS"
    click BlockchainClient "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/blockchain.js"
    click AppFactory "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/app.py"
    click Auth "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/auth.py"
    click Routes "https://github.com/ay0788/transparex/blob/main/TranspareX-protocole/routes.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
    classDef blockchain fill:#F08080,stroke:#000,stroke-width:1px
    classDef user fill:#D3D3D3,stroke:#000,stroke-width:1px
```
