# rudrasecure/aws_neo4j_map architecture

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

- Interactive diagram: https://gitdiagram.com/rudrasecure/aws_neo4j_map
- Repository: https://github.com/rudrasecure/aws_neo4j_map

## Overview

##### Main Components

a) Data Collection Layer:
- Boto3 scripts (5 separate collectors) as individual components
- Each collector focuses on specific AWS resources:
- EC2 Instances
- Security Groups
- RDS Instances
- VPC Peering
- Application Load Balancers

b) Data Processing Layer:
- Neo4j update script that processes JSON outputs
- Data transformation logic

c) Storage Layer:
- Neo4j Graph Database with temporal data storage

d) AWS Infrastructure Layer:
- AWS services being queried
- IAM authentication component

**┌─────────────────────────────────────────────────────────┐**
- AWS Infrastructure                      │
- ┌─────────┐ ┌──────────┐ ┌────────┐ ┌───────┐ ┌─────┐  │
- EC2   │ │   RDS    │ │  VPC   │ │  ALB  │ │ SG  │  │
- ┘ └──────────┘ └────────┘ └───────┘ └─────┘  │
- ┘
- ▲
- (AWS API Calls)

**┌─────────────────────────────────────────────────────────┐**
- Data Collection Layer                   │
- ┌─────────┐ ┌──────────┐ ┌────────┐ ┌───────┐ ┌─────┐  │
- get_inst │ │get_rds   │ │get_vpc │ │get_alb│ │get_sg│  │
- ┘ └──────────┘ └────────┘ └───────┘ └─────┘  │
- ┘
- ▼
- [JSON Files]
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Data Processing Layer                   │
- ┌────────────────────────────────┐            │
- update_intelligence_db.py     │            │
- ┘            │
- ┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Neo4j Database                       │
- ┌──────────────────────────────────────────────────┐   │
- Graph Model                      │   │
- [Nodes]                [Relationships]          │   │
- Snapshot            - CONTAINS               │   │
- Region             - BELONGS_TO             │   │
- VPC                - PEERED_TO              │   │
- Instance           - ALLOWED                │   │
- SecurityGroup      - TAGGED                 │   │
- ┘   │
- ┘

##### Important Elements to Highlight

- Blue: AWS Services
- Green: Data Collection Scripts
- Yellow: Processing Components
- Red: Database Layer
- Purple: Data Flow Lines

- Clear labels for:
- IAM permissions required (SecurityAudit and ViewOnlyAccess)
- Temporal data aspects (Snapshot nodes)
- Data flow directions
- File formats (JSON) between layers

##### Additional Details

- Notes about the periodic execution nature
- Integration points for SIEM tools
- Where environment variables (.env) are used

##### Technical Notes

- Use standardized UML or C4 model notation
- Version information for major components
- Error handling and retry mechanisms
- Where configuration is required

Remember to maintain a balance between showing enough detail to understand the system's architecture while not overwhelming the viewer with implementation-specific details.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef aws fill:#2674B1,stroke:#fff,stroke-width:2px,color:#fff
    classDef collector fill:#85B800,stroke:#fff,stroke-width:2px,color:#fff
    classDef processor fill:#FF9900,stroke:#fff,stroke-width:2px,color:#fff
    classDef database fill:#C42C48,stroke:#fff,stroke-width:2px,color:#fff
    classDef config fill:#9D44B5,stroke:#fff,stroke-width:2px,color:#fff
    
    subgraph AWS["AWS Infrastructure Layer"]
        EC2[EC2]:::aws
        RDS[RDS]:::aws
        VPC[VPC]:::aws
        ALB[ALB]:::aws
        SG[Security Groups]:::aws
    end

    subgraph Collectors["Data Collection Layer"]
        EC2C[EC2 Collector]:::collector
        RDSC[RDS Collector]:::collector
        VPCC[VPC Collector]:::collector
        ALBC[ALB Collector]:::collector
        SGC[Security Group Collector]:::collector
    end

    subgraph Processing["Data Processing Layer"]
        JSON[("JSON Files")]
        NEO4J_UPDATE[Neo4j Update Script]:::processor
    end

    subgraph Database["Neo4j Database Layer"]
        DB[(Neo4j Graph DB)]:::database
        subgraph Model["Graph Model"]
            Nodes["Nodes:
            - Snapshot
            - Region
            - VPC
            - Instance
            - SecurityGroup"]
            Rels["Relationships:
            - CONTAINS
            - BELONGS_TO
            - PEERED_TO
            - ALLOWED
            - TAGGED"]
        end
    end

    Config[".env Configuration"]:::config

    %% Relationships
    EC2 --> EC2C
    RDS --> RDSC
    VPC --> VPCC
    ALB --> ALBC
    SG --> SGC

    EC2C --> JSON
    RDSC --> JSON
    VPCC --> JSON
    ALBC --> JSON
    SGC --> JSON

    JSON --> NEO4J_UPDATE
    NEO4J_UPDATE --> DB
    Config --> NEO4J_UPDATE

    %% Click Events
    click EC2C "https://github.com/rudrasecure/aws_neo4j_map/blob/master/boto3/get_instance_1.py"
    click SGC "https://github.com/rudrasecure/aws_neo4j_map/blob/master/boto3/get_securitygroup_2.py"
    click RDSC "https://github.com/rudrasecure/aws_neo4j_map/blob/master/boto3/get_rds_3.py"
    click VPCC "https://github.com/rudrasecure/aws_neo4j_map/blob/master/boto3/get_vpc_4.py"
    click ALBC "https://github.com/rudrasecure/aws_neo4j_map/blob/master/boto3/get_alb_5.py"
    click NEO4J_UPDATE "https://github.com/rudrasecure/aws_neo4j_map/blob/master/neo4j/update_intelligence_db.py"
    click Config "https://github.com/rudrasecure/aws_neo4j_map/blob/master/.env.sample"

    %% Legend
    subgraph Legend
        L1[AWS Services]:::aws
        L2[Collectors]:::collector
        L3[Processors]:::processor
        L4[Database]:::database
        L5[Configuration]:::config
    end
```
