# hac1es/nt219_project architecture

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

- Interactive diagram: https://gitdiagram.com/hac1es/nt219_project
- Repository: https://github.com/hac1es/nt219_project

## Overview

##### Project type and purpose
- This is a distributed, full-stack system for inter-bank credit scoring using multiparty CKKS homomorphic encryption.
- It consists of a Certificate Authority (CA), multiple bank nodes (MSB, ACB), a financial organization node (FE Credit), a protected database (PostgreSQL with TDE), and test/benchmark scripts.

##### File structure
- Top-level directories:
– CA/              → certificate authority service (FastAPI server.py + SSL assets)
– Banks/           → each bank’s modules:
· Certificate/   → certificate request logic
· HEModule/      → key generation, encryption, decryption GUI and scripts
· DBService/     → database query wrapper
· InterbankService/ → REST API (interbankAPI.py), client, and exchange scripts
– FinanceOrg/      → FHE scoring server (HEServer.py) + certificate logic
– Testing/         → proof-of-concept and benchmark scripts + results
- Supporting files: run scripts (.sh), context/req text files, requirements.txt

##### README for additional insights
– Certificate issuance flow
– Multi-party key generation among banks
– Encrypted data flow from Banks → FinanceOrg → Banks
- Workflow steps: certificate creation, FHE key setup, data encryption & storage, score computation, decryption.
- Security: CKKS FHE, ECDSA signatures, TLS1.3, PostgreSQL TDE, certificate-based auth.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Certificate Authority Zone
    subgraph "Certificate Authority Zone"
        direction TB
        CA["Certificate Authority Service (FastAPI)"]:::ca
        CA_Script["runServer.sh"]:::script
    end

    %% Bank Nodes Zone
    subgraph "Bank Nodes Zone"
        direction TB
        subgraph "Bank Node (MSB / ACB)"
            direction TB
            CertMod["Certificate Module<br/>(requestCert.py)"]:::cert
            HEMod["HEModule<br/>(CKKS Key & Encryption)"]:::crypto
            DBServ["DBService<br/>(getCustomerInfo.py)"]:::dbserv
            InterServ["InterbankService<br/>(REST API & Client)"]:::api
        end
    end

    %% Finance Organization Zone
    subgraph "FinanceOrg Zone"
        direction TB
        FO_Cert["Certificate Module<br/>(requestCert.py)"]:::cert
        FHE_SRV["FHE Scoring Server (HEServer.py)"]:::crypto
    end

    %% Database Zone
    subgraph "Database Zone"
        direction TB
        DB["PostgreSQL with TDE"]:::database
    end

    %% Testing Harness Zone
    subgraph "Testing Harness"
        direction TB
        PoC["PoC Script (PoC.py)"]:::test
        Bench["Benchmark Script (PoC_benchmark.py)"]:::test
    end

    %% Connections: Certificate issuance
    CertMod -->|HTTPS Cert Request /response| CA
    FO_Cert -->|HTTPS Cert Request /response| CA

    %% Multi-party key exchange between Banks
    HEMod -->|"interactiveEncrypt / calculateJointKey"| HEMod

    %% Bank to Database
    DBServ -->|SQL/TLS getCustomerInfo| DB

    %% Bank to FinanceOrg encrypted data
    InterServ -->|HTTPS POST /encryptData| FHE_SRV
    FHE_SRV -->|HTTPS POST /returnScore| InterServ

    %% Multi-party decryption among Banks
    HEMod -->|"multipartyDecrypt"| HEMod

    %% Testing flows
    PoC -->|simulate workflows| CertMod
    Bench -->|benchmark scripts| HEMod

    %% Click Events
    click CA "https://github.com/hac1es/nt219_project/blob/main/CA/server.py"
    click CA_Script "https://github.com/hac1es/nt219_project/blob/main/CA/runServer.sh"
    click CertMod "https://github.com/hac1es/nt219_project/blob/main/Banks/Certificate/requestCert.py"
    click HEMod "https://github.com/hac1es/nt219_project/blob/main/Banks/HEModule/keyGenerator.py"
    click DBServ "https://github.com/hac1es/nt219_project/blob/main/Banks/DBService/getCustomerInfo.py"
    click InterServ "https://github.com/hac1es/nt219_project/blob/main/Banks/InterbankService/interbankAPI.py"
    click FO_Cert "https://github.com/hac1es/nt219_project/blob/main/FinanceOrg/Certificate/requestCert.py"
    click FHE_SRV "https://github.com/hac1es/nt219_project/blob/main/FinanceOrg/HEServer.py"
    click PoC "https://github.com/hac1es/nt219_project/blob/main/Testing/PoC.py"
    click Bench "https://github.com/hac1es/nt219_project/blob/main/Testing/PoC_benchmark.py"

    %% Styles
    classDef ca fill:#FFD700,stroke:#333,stroke-width:1px
    classDef script fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef cert fill:#98FB98,stroke:#333,stroke-width:1px
    classDef crypto fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef dbserv fill:#FFA07A,stroke:#333,stroke-width:1px
    classDef api fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef database fill:#FFE4B5,stroke:#333,stroke-width:1px,shape:cylinder
    classDef test fill:#D3D3D3,stroke:#333,stroke-width:1px
```
