# autodesk-forge/forge-bim360-clashpdfexport architecture

> Architecture diagram of the GitHub repository autodesk-forge/forge-bim360-clashpdfexport, 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/autodesk-forge/forge-bim360-clashpdfexport
- Repository: https://github.com/autodesk-forge/forge-bim360-clashpdfexport

## Overview

##### Project Type and Main Components

a. Frontend Layer (www folder):
- Static web interface
- Forge Viewer integration
- Clash visualization components
- PDF export functionality

b. Backend Layer (server folder):
- Authentication services
- BIM 360/Forge API integration
- Data processing and analysis
- PDF generation services

c. External Services:
- Autodesk Forge Platform
- BIM 360 Services
- Model Coordination API

##### Component Relationships

**[Client Browser] ←→ [Frontend Components] ←→ [Backend Services] ←→ [Forge/BIM360 APIs]**

##### Detailed Component Breakdown

- Main UI (index.html)
- Forge Viewer (ForgeViewer.js)
- Clash Views (breakdown, matrix, raw views)
- PDF Generation Interface

- OAuth Authentication (oauth.services.js)
- Data Management Services (dm.*.services.js)
- Model Coordination Services (mc.*.services.js)
- Analysis Engine (analyze.js)

- Forge Authentication
- BIM 360 Platform
- Model Coordination API
- Data Management API

##### Data Flows

- User authentication flow
- Model set data retrieval
- Clash data processing
- PDF generation and export

##### Specific Implementation Details

Technical elements:
- Node.js backend
- Express.js server
- Forge Viewer integration
- jsPDF library for PDF generation
- REST API endpoints

**┌─────────────────────────────────────────────┐**
- Client Layer (Browser)                      │
- ┤
- Application Layer                           │
- ┌─────────────┐ ┌─────────────┐            │
- Frontend     │ │Backend      │            │
- Components   │ │Services     │            │
- ┘ └─────────────┘            │
- ┤
- External Services Layer                     │
- (Forge APIs, BIM 360, Model Coordination)   │
- ┘

##### Technical Notes

Annotations for:
- Authentication requirements
- API version dependencies
- Critical data processing points
- Performance considerations

Remember to include version numbers for key components and APIs as mentioned in the README (e.g., Forge Viewer v7.25, Node.js v10+).

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        UI["Main UI"]:::frontend
        click UI "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/index.html"
    end

    subgraph "Frontend Components"
        FViewer["Forge Viewer"]:::frontend
        click FViewer "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/ForgeViewer.js"
        
        subgraph "Clash Views"
            BView["Breakdown View"]:::frontend
            click BView "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/mc.clash.breakdown.view.js"
            MView["Matrix View"]:::frontend
            click MView "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/mc.clash.matrix.view.js"
            RView["Raw View"]:::frontend
            click RView "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/mc.clash.raw.view.js"
        end
        
        PDF["PDF Generator"]:::frontend
        click PDF "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/mc.clash.pdf.js"
        PDFLib["jsPDF Library"]:::frontend
        click PDFLib "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/libs/jsPDF-1.3.2/dist/jspdf.debug.js"
        FrontAuth["Frontend Auth"]:::frontend
        click FrontAuth "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/oauth.js"
        FrontUtil["Frontend Utilities"]:::frontend
        click FrontUtil "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/www/js/utility.js"
    end

    subgraph "Backend Services"
        Auth["OAuth Service"]:::backend
        click Auth "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/services/oauth.services.js"
        AuthEP["Auth Endpoints"]:::backend
        click AuthEP "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/endpoints/oauth.endpoints.js"
        
        DMS["Data Management Service"]:::backend
        click DMS "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/services/dm.hubs.services.js"
        DMEP["DM Endpoints"]:::backend
        click DMEP "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/endpoints/dm.endpoints.js"
        
        MCS["Model Coordination Service"]:::backend
        click MCS "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/services/mc.clash.services.js"
        MCEP["MC Endpoints"]:::backend
        click MCEP "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/endpoints/mc.clash.endpoints.js"
        
        MSS["Model Set Service"]:::backend
        click MSS "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/services/mc.modelset.services.js"
        MSEP["Model Set Endpoints"]:::backend
        click MSEP "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/endpoints/mc.modelset.endpoints.js"
        
        Analysis["Analysis Engine"]:::backend
        click Analysis "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/analyze.js"
        DB["Database Handler"]:::backend
        click DB "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/bim.database.js"
        Session["User Session"]:::backend
        click Session "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/services/userSession.js"
        BackUtil["Backend Utilities"]:::backend
        click BackUtil "https://github.com/Autodesk-Forge/forge-bim360-clashpdfexport/blob/master/server/utility.js"
    end

    subgraph "External Services"
        ForgeAuth["Forge Authentication"]:::external
        BIM360["BIM 360 Platform"]:::external
        MCA["Model Coordination API"]:::external
        DMA["Data Management API"]:::external
    end

    %% Connections
    Browser --> UI
    UI --> FViewer
    UI --> BView & MView & RView
    UI --> PDF
    PDF --> PDFLib
    UI --> FrontAuth
    FrontAuth --> Auth
    
    Auth --> ForgeAuth
    DMS --> DMA
    MCS --> MCA
    MSS --> BIM360
    
    Analysis --> DB
    Session --> Auth
    
    AuthEP --> Auth
    DMEP --> DMS
    MCEP --> MCS
    MSEP --> MSS

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        F[Frontend Component]:::frontend
        B[Backend Service]:::backend
        E[External Service]:::external
    end
```
