# nimastic/dgtal-registry-teamg architecture

> Architecture diagram of the GitHub repository nimastic/dgtal-registry-teamg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nimastic/dgtal-registry-teamg
- Repository: https://github.com/nimastic/dgtal-registry-teamg

## Overview

##### Main Components Identification

A. Frontend Layer (Next.js Application)
- User Interface Components
- Wallet Integration (MetaMask)
- Asset Management Interface
- License Management Interface

B. Backend Layer (Node.js)
- API Server
- Smart Contract Controllers
- File Storage System

C. Blockchain Layer
- Smart Contracts (Solidity)
- Local Blockchain (Ganache)
- Contract Interactions

**[Frontend Layer]**
- ↕
**[Backend Layer]**
- ↕
**[Blockchain Layer]**

##### Detailed Component Breakdown

Frontend Layer (Blue):
**┌─ Next.js Frontend ─────────────────┐**
- Asset Management                 │
- License Management              │
- Wallet Integration              │
- Search & Browse                 │
- Upload Interface                │
- ┘

Backend Layer (Green):
**┌─ Node.js Backend ────────────────┐**
- API Routes                     │
- Content Registry Controller    │
- License Manager Controller     │
- Blockchain Controller         │
- File Storage System           │
- ┘

Blockchain Layer (Orange):
**┌─ Blockchain Infrastructure ──────┐**
- ContentRegistry Contract      │
- LicenseManager Contract       │
- Ganache Local Blockchain      │
- Smart Contract Storage        │
- ┘

##### Connection Flows

- User interactions (Frontend → Backend)
- API calls (Backend → Frontend)
- Contract interactions (Backend → Blockchain)
- Wallet operations (Frontend → MetaMask → Blockchain)
- File storage operations (Backend → Storage)

##### Technical Details

Annotations for:
- Port numbers (3000 for frontend)
- Contract addresses
- API endpoints
- File storage paths

##### Implementation Notes

- The separation between frontend routes (/browse, /asset, /licenses)
- Smart contract interaction flow
- File handling system
- Authentication and authorization flow through MetaMask

##### Additional Elements

Include:
- Error handling flows
- Backup systems
- Security measures
- Scaling considerations

Remember to:
- Keep components proportional to their importance
- Use consistent styling
- Version information
- Deployment environment specifications

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[Next.js Frontend]
        WI["Wallet Integration"]
        AM["Asset Management"]
        LM["License Management"]
        SB["Search & Browse"]
        UL["Upload Interface"]
        ADV["Asset Detail View"]
        LCI["License Creation Interface"]
        RM["Request Management"]
    end

    subgraph Backend
        API["API Server"]
        BC["Blockchain Controller"]
        CRC["Content Registry Controller"]
        LMC["License Manager Controller"]
        FSS["File Storage System"]
    end

    subgraph Blockchain
        SC["Smart Contracts"]
        CM["Contract Migrations"]
        LB["Local Blockchain (Ganache)"]
    end

    subgraph External
        MM["MetaMask"]
    end

    %% Frontend connections
    UI --> WI
    UI --> AM
    UI --> LM
    UI --> SB
    UI --> UL
    AM --> ADV
    ADV --> LCI
    ADV --> RM

    %% Backend connections
    UI --> API
    API --> BC
    API --> CRC
    API --> LMC
    API --> FSS

    %% Blockchain connections
    BC --> SC
    SC --> LB
    CM --> SC

    %% External connections
    WI --> MM
    MM --> LB

    %% Click events
    click WI "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/g-frontend/src/app/WalletButtons.tsx"
    click AM "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/g-frontend/src/app/asset/"
    click LM "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/g-frontend/src/app/licenses/"
    click SB "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/g-frontend/src/app/browse/"
    click UL "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/g-frontend/src/app/upload/"
    click API "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/lifehack-backend/routes/api.js"
    click BC "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/lifehack-backend/controller/blockchain.js"
    click CRC "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/lifehack-backend/controller/contentRegistry.js"
    click LMC "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/lifehack-backend/controller/licenseManager.js"
    click FSS "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/lifehack-backend/uploads/"
    click SC "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/lifehack-backend/contracts/"
    click CM "https://github.com/Nimastic/dGtal-Registry-TeamG/tree/main/lifehack-backend/migrations/"
    click ADV "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/g-frontend/src/app/asset/[id]/AssetDetail.tsx"
    click LCI "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/g-frontend/src/app/asset/[id]/create-license/CreateLicenseForm.tsx"
    click RM "https://github.com/Nimastic/dGtal-Registry-TeamG/blob/main/g-frontend/src/app/asset/[id]/request/RequestForm.tsx"

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef blockchain fill:#FFB347,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px

    class UI,WI,AM,LM,SB,UL,ADV,LCI,RM frontend
    class API,BC,CRC,LMC,FSS backend
    class SC,CM,LB blockchain
    class MM external
```
