# woojae9488/fabric-survey-app architecture

> Architecture diagram of the GitHub repository woojae9488/fabric-survey-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/woojae9488/fabric-survey-app
- Repository: https://github.com/woojae9488/fabric-survey-app

## Overview

##### High-Level Architecture Components

a) Client Layer:
- Vue.js Web Application (web-app/client)
- Hyperledger Explorer UI

b) API Gateway Layer:
- Express.js API Gateway (web-app/servers/api-gateway)
- Authentication/Authorization middleware

c) Microservices Layer:
- Fabric Manager Service (web-app/servers/fabric-manager)
- Fabric Student Service (web-app/servers/fabric-student)
- Fabric Event Service (web-app/servers/fabric-event)
- Card Recognition Service (web-app/servers/card-recognize)

d) Blockchain Layer:
- Hyperledger Fabric Network
- Chaincode (Smart Contracts)
- Private Data Collections

**[Client Layer]**

**[API Gateway Layer]**

**[Microservices Layer]**

**[Blockchain Layer]**

##### Component Relationships

- Blockchain transactions (thick lines)

##### Additional Details

Annotations for:
- Security mechanisms (JWT tokens)
- Data privacy (private collections)
- Event handling mechanisms
- Database interactions
- Docker container boundaries

##### Implementation Notes

- Microservice architecture pattern
- Event-driven architecture for blockchain events
- Private data handling for sensitive information
- Authentication flow
- Survey lifecycle states

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        VueApp["Vue.js Web Application"]:::client
        Explorer["Hyperledger Explorer UI"]:::client
    end

    subgraph Gateway
        APIGateway["API Gateway"]:::gateway
        AuthMiddleware["Authentication Middleware"]:::gateway
    end

    subgraph Microservices
        FabricManager["Fabric Manager Service"]:::microservice
        FabricStudent["Fabric Student Service"]:::microservice
        FabricEvent["Fabric Event Service"]:::microservice
        CardRecognition["Card Recognition Service"]:::microservice
    end

    subgraph "Blockchain Network"
        subgraph Chaincode
            SmartContracts["Smart Contracts"]:::blockchain
            PrivateData["Private Data Collections"]:::blockchain
            SurveyComponent["Survey Components"]:::blockchain
            ReplyComponent["Reply Components"]:::blockchain
            UserComponent["User Management"]:::blockchain
            DeptComponent["Department Management"]:::blockchain
        end

        subgraph Infrastructure
            NetworkConfig["Network Configuration"]:::infra
            DockerConfig["Docker Compositions"]:::infra
        end
    end

    %% Client to Gateway connections
    VueApp --> APIGateway
    Explorer --> APIGateway
    APIGateway --> AuthMiddleware

    %% Gateway to Microservices
    AuthMiddleware --> FabricManager
    AuthMiddleware --> FabricStudent
    AuthMiddleware --> FabricEvent
    AuthMiddleware --> CardRecognition

    %% Microservices to Blockchain
    FabricManager --> SmartContracts
    FabricStudent --> SmartContracts
    FabricEvent -.-> SmartContracts
    CardRecognition --> SmartContracts

    %% Chaincode internal connections
    SmartContracts --> PrivateData
    SmartContracts --> SurveyComponent
    SmartContracts --> ReplyComponent
    SmartContracts --> UserComponent
    SmartContracts --> DeptComponent

    %% Infrastructure connections
    NetworkConfig --- DockerConfig

    %% Click events
    click VueApp "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/client/"
    click Explorer "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/docker-config/explorer/"
    click APIGateway "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/servers/api-gateway/"
    click AuthMiddleware "https://github.com/woojae9488/fabric-survey-app/blob/master/web-app/servers/api-gateway/middlewares/auth.js"
    click FabricManager "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/servers/fabric-manager/"
    click FabricStudent "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/servers/fabric-student/"
    click FabricEvent "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/servers/fabric-event/"
    click CardRecognition "https://github.com/woojae9488/fabric-survey-app/tree/master/web-app/servers/card-recognize/"
    click SmartContracts "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/lib/SurveyContract.js"
    click PrivateData "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/ledger-api/PrivateData.js"
    click SurveyComponent "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/lib/Survey.js"
    click ReplyComponent "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/lib/Reply.js"
    click UserComponent "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/lib/User.js"
    click DeptComponent "https://github.com/woojae9488/fabric-survey-app/blob/master/chaincode/lib/Department.js"
    click NetworkConfig "https://github.com/woojae9488/fabric-survey-app/blob/master/artifacts/configtx.yaml"
    click DockerConfig "https://github.com/woojae9488/fabric-survey-app/blob/master/artifacts/base/docker-compose-base.yaml"

    %% Styling
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef gateway fill:#2ecc71,stroke:#27ae60,color:white
    classDef microservice fill:#f1c40f,stroke:#f39c12,color:black
    classDef blockchain fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Client_L["Client Component"]:::client
        Gateway_L["Gateway Component"]:::gateway
        Micro_L["Microservice"]:::microservice
        Block_L["Blockchain Component"]:::blockchain
        Infra_L["Infrastructure"]:::infra
    end
```
