# opswat/mdcloud-go architecture

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

- Interactive diagram: https://gitdiagram.com/opswat/mdcloud-go
- Repository: https://github.com/opswat/mdcloud-go

## Overview

##### Main Components

a) Client Layer:
- CLI interface (cmd/ directory)
- Main entry point (main.go)

b) Core Service Layer (pkg/ directory):
- API Services
- AWS Integration
- Scanning Services
- Utility Services

c) External Services:
- MetaDefender Cloud API
- AWS Security Groups
- AWS Credentials Store

##### User Interface Layer
- Commands by functionality (scanning, lookup, vulnerability, etc.)

##### Service Layer (Middle)
- Create distinct sections for each major package:
- API Handler (pkg/api)
- AWS Integration (pkg/aws)
- Scanning Services (pkg/filescan, pkg/ipscan)
- Lookup Services (pkg/lookup)
- Vulnerability Services (pkg/vulnerability)

##### External Services Layer (Bottom)
- MetaDefender Cloud API
- AWS Services

##### Relationships and Flows

- Command flow from CLI to appropriate service
- API calls to external services
- Data flow between components

##### Specific Elements

a) Components:
**[CLI Interface] -> [Command Handlers]**
- Scan Commands
- Lookup Commands
- AWS Security Group Commands

**[Service Layer] -> [Core Services]**
- API Client
- AWS Integration
- Scanning Services
- Utility Services

**[External Layer] -> [External Services]**
- MetaDefender Cloud
- AWS Security Groups

b) Key Interactions:
- Authentication flow (API key handling)
- AWS credentials management
- Scanning request/response flow
- Security group analysis flow

##### Important Details to Highlight

- API key configuration flow
- AWS credentials integration
- Command processing pipeline
- Error handling paths
- Data transformation flows

##### The external service dependencies

Keep the abstraction level focused on the architectural components while showing the key interactions that make this tool function as a bridge between local systems, MetaDefender Cloud, and AWS services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#388E3C,color:white
    classDef external fill:#FF9800,stroke:#F57C00,color:white
    classDef utility fill:#9E9E9E,stroke:#616161,color:white

    %% CLI Layer
    subgraph CLI
        MainEntry["Main Entry Point"]
        CommandInterface["CLI Interface"]
        
        %% Command Handlers
        ScanCmd["Scan Commands"]
        SGCmd["Security Group Commands"]
        LookupCmd["Lookup Commands"]
        VulnCmd["Vulnerability Commands"]
        CVECmd["CVE Commands"]
    end

    %% Service Layer
    subgraph Services
        %% Core Services
        APIService["API Services"]
        AWSService["AWS Integration"]
        
        %% Scanning Services
        FileScan["File Scanning"]
        IPScan["IP Scanning"]
        
        %% Other Services
        LookupService["Lookup Service"]
        VulnService["Vulnerability Service"]
        CVEService["CVE Processing"]
        FeedService["Feed Processing"]
        RescanService["Rescan Service"]
        UtilsService["Utility Services"]
    end

    %% External Services Layer
    subgraph External
        MetaDefender["MetaDefender Cloud API"]
        AWSSecGroups["AWS Security Groups"]
        AWSCreds["AWS Credentials Store"]
    end

    %% Relationships
    MainEntry --> CommandInterface
    CommandInterface --> ScanCmd & SGCmd & LookupCmd & VulnCmd & CVECmd
    
    ScanCmd --> FileScan & IPScan
    SGCmd --> AWSService
    LookupCmd --> LookupService
    VulnCmd --> VulnService
    CVECmd --> CVEService
    
    FileScan & IPScan --> APIService
    AWSService --> AWSSecGroups
    AWSService --> AWSCreds
    APIService --> MetaDefender
    
    VulnService --> FeedService
    VulnService --> RescanService
    UtilsService -.-> Services

    %% Click Events
    click MainEntry "https://github.com/OPSWAT/mdcloud-go/blob/master/main.go"
    click CommandInterface "https://github.com/OPSWAT/mdcloud-go/tree/master/cmd/"
    click APIService "https://github.com/OPSWAT/mdcloud-go/tree/master/pkg/api/"
    click AWSService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/aws/aws.go"
    click FileScan "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/filescan/filescan.go"
    click IPScan "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/ipscan/ipscan.go"
    click LookupService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/lookup/lookup.go"
    click VulnService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/vulnerability/vulnerability.go"
    click CVEService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/cve/cve.go"
    click FeedService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/feed/feed.go"
    click RescanService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/rescan/rescan.go"
    click UtilsService "https://github.com/OPSWAT/mdcloud-go/blob/master/pkg/utils/utils.go"
    click ScanCmd "https://github.com/OPSWAT/mdcloud-go/blob/master/cmd/scan.go"
    click SGCmd "https://github.com/OPSWAT/mdcloud-go/blob/master/cmd/sgscan.go"
    click LookupCmd "https://github.com/OPSWAT/mdcloud-go/blob/master/cmd/lookup.go"
    click VulnCmd "https://github.com/OPSWAT/mdcloud-go/blob/master/cmd/vulnerability.go"
    click CVECmd "https://github.com/OPSWAT/mdcloud-go/blob/master/cmd/cve.go"

    %% Style Applications
    class MainEntry,CommandInterface,ScanCmd,SGCmd,LookupCmd,VulnCmd,CVECmd cli
    class APIService,AWSService,FileScan,IPScan,LookupService,VulnService,CVEService,FeedService,RescanService service
    class MetaDefender,AWSSecGroups,AWSCreds external
    class UtilsService utility
```
