# satyajit1910/ptjsp architecture

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

- Interactive diagram: https://gitdiagram.com/satyajit1910/ptjsp
- Repository: https://github.com/satyajit1910/ptjsp

## Overview

The project is a Hyperledger Fabric based blockchain application – a full-stack solution that implements a privacy-preserving job search portal (called ChainHire) using an enterprise-level permissioned blockchain network. The purpose is to allow various stakeholders (HR personnel, job seekers, admin users) to interact with the network securely via chaincode smart contracts. A mix of blockchain network setup, smart contract logic, client interaction interfaces, and performance benchmarking is evident from the file tree and README.

##### Main Components
- Blockchain Network:
– The Fabric binaries (in the “bin” folder) and the test-network configuration (in “test-network” and “chaincode-docker-devmode”) indicate that the project uses Hyperledger Fabric’s components.
– Include key blockchain elements: Orderer, Peer nodes, Certificate Authorities (Fabric CA), and ledger elements.

- Chaincode (Smart Contracts):
– The “chaincode/PTJSP/javascript” directory contains the smart contracts (e.g., HR-contract.js, admin-contract.js, jobposting.js, jobseeker.js, primary-contract.js) which are deployed on the peers to enforce business logic.

- Client Application (User Interface Layer):
– The “client/javascript” folder holds the client side code. This includes the application logic (e.g., enrollAdmin.js, registerUser.js), static web pages, view templates (EJS), and route definitions for different roles such as admin, HR, and jobseeker.

- Benchmarking and Performance Testing:
– The “caliper-benchmarks” folder indicates the use of Hyperledger Caliper for performance evaluation. This is used to run various benchmarks and generate reports.

- CI/CD & Deployment Scripting:
– The “ci” folder contains deployment and testing scripts that support continuous integration workflows using Azure pipelines and other test-network automation scripts.

##### Relationships and Interactions
- The Client Application interacts with the blockchain network through a RESTful API or a NodeJS fabric SDK.

- Within the blockchain network, transaction proposals are sent to Peer nodes hosting the chaincode.

- The Fabric Certificate Authorities (CAs) manage identities for network participants (admin, HR, jobseeker).
– Show a side module for CA that issues certificates to both blockchain network nodes and client identities.

- The benchmarking component (Caliper) interacts with the deployed network by initiating transactions, measuring performance, and generating reports.

##### Architectural Patterns and Design Principles
- Microservices-ish Approach for the Blockchain Network:
– Separate components such as orderers, peers, and CAs are being deployed (often via Docker containers) that encapsulate specific responsibilities.

- Separation of Concerns:
– The project distinguishes between blockchain logic (chaincode), network setup (test-network, chaincode-docker-devmode), and client interaction (client folder).

- Integration and Extensibility:
– Performance benchmarks (Caliper) allow one to extend or monitor network performance, and CI/CD scripts support continuous integration.

##### Relevant Technologies, Frameworks, and Tools
- Hyperledger Fabric components – Orderer, Peers, CA.
- Node.js (v10.19.0) and NPM for building and running client and chaincode applications.
- Docker/docker-compose for containerizing network components.
- Hyperledger Caliper for performance testing.
- CI/CD scripts (Azure Pipelines in the “ci” directory) for automated deployment.

##### Final Touches
- Avoid over-cluttering – while detail is important, focus on the primary high-level interactions and major modules that represent the core architectural design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Blockchain Network Layer
    subgraph "Blockchain Network Layer"
        subgraph "Infrastructure"
            fb["Fabric Binaries"]:::blockchain_internal
            tn["Test Network Config"]:::blockchain_internal
            cd["Chaincode Docker Devmode"]:::blockchain_internal
        end
        orderer["Fabric Orderer"]:::blockchain
        peer["Fabric Peer"]:::blockchain
        ca["Fabric CA"]:::blockchain
    end

    %% Chaincode Layer
    subgraph "Chaincode Layer"
        chaincode["Chaincode (Smart Contracts)"]:::chaincode
    end

    %% Application Layer
    subgraph "Application Layer"
        client["Client Application"]:::client
    end

    %% Benchmarking/Monitoring Layer
    subgraph "Benchmarking/Monitoring Layer"
        caliper["Caliper Benchmarks"]:::benchmark
    end

    %% CI/CD Layer
    subgraph "CI/CD Layer"
        cicd["CI/CD & Deployment"]:::cicd
    end

    %% Relationships between components
    client -->|"TransactionProposal"| peer
    peer -->|"TransactionOrdering"| orderer
    client -->|"EnrollIdentity"| ca
    peer -->|"ChaincodeExecution"| chaincode
    caliper -->|"PerformanceTesting"| peer

    cicd -->|"DeployNetwork"| tn
    cicd -->|"DeployChaincode"| cd
    cicd -->|"DeploySmartContracts"| chaincode
    cicd -->|"DeployClient"| client

    %% Infrastructure support relationships (dashed arrows)
    fb -.-> orderer
    fb -.-> peer
    fb -.-> ca
    tn -.-> orderer
    tn -.-> peer
    tn -.-> ca
    cd -.-> chaincode

    %% Click Events for Component Mappings
    click fb "https://github.com/satyajit1910/ptjsp/tree/main/bin"
    click tn "https://github.com/satyajit1910/ptjsp/tree/main/test-network"
    click cd "https://github.com/satyajit1910/ptjsp/tree/main/chaincode-docker-devmode"
    click chaincode "https://github.com/satyajit1910/ptjsp/tree/main/chaincode/PTJSP/javascript"
    click client "https://github.com/satyajit1910/ptjsp/tree/main/client/javascript"
    click caliper "https://github.com/satyajit1910/ptjsp/tree/main/caliper-benchmarks"
    click cicd "https://github.com/satyajit1910/ptjsp/tree/main/ci"

    %% Styles for different layers and components
    classDef blockchain fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef chaincode fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef client fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef benchmark fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef cicd fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef blockchain_internal fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
```
