# wellafl3x/infotecs_ti_automation architecture

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

- Interactive diagram: https://gitdiagram.com/wellafl3x/infotecs_ti_automation
- Repository: https://github.com/wellafl3x/infotecs_ti_automation

## Overview

##### Project Type and Purpose
- This is an automated PCAP-processing pipeline that glues together Zeek (traffic analysis), RITA (threat intelligence reporting), MongoDB (storage), and NGINX (report serving).
- It’s driven by a single orchestrator shell script (`this_script.sh`), with a helper Python component (`main.py`) to generate whitelists from the AdGuard JSON.

##### File Structure Analysis
- Top-level orchestrator:
- this_script.sh – installs components, sets up directories, and runs the monitor loop
- vars – environment variables controlling paths and feature toggles
- Processing scripts:
- main.py – whitelist generator from AdGuard JSON → outputs `domains.txt` and `results.txt`
- helper_scripts/clear.sh – cleanup utility
- Config templates (in `templates/`):
- rita/ (RITA config)
- smb/ (Samba share config)
- web/ (HTML/CSS + NGINX + RITA conf)
- whitelists/ (domain/IP lists)
- External dependencies & binaries:
- golang/go1.20.2.linux-amd64.tar.gz – Go toolchain for building RITA
- requirements.txt – any Python dependencies

##### Key Architecture from README
- Setup phase: installs Zeek, RITA, MongoDB, NGINX → creates directories (PCAPS, REPORTS, temp dirs) → applies templated configs → starts services
- Runtime phase: uses inotify to watch `PCAPS/` → on new file:
a) Zeek analysis → writes logs to `/tmp`
b) RITA analysis (filters via whitelists generated by main.py) → stores in MongoDB → renders web reports
c) NGINX serves those reports on port 80
- Optional SMB share for PCAP/REPORTS via Samba

##### Main Components
- Operator (root shell)
- Orchestrator (this_script.sh + vars)
- Configuration Templates
- File System: input (`PCAPS/`), temp (`/tmp/zeek/`, `/tmp/rita/`), output (`REPORTS/`)
- Watcher (inotify service)
- Zeek engine
- Whitelist generator (main.py + AdGuard JSON external)
- RITA engine + MongoDB
- NGINX web server
- Optional Samba service

##### Interactions & Data Flow
- Operator → runs this_script.sh → installs & configures services
- inotify → triggers Zeek on new PCAP
- Zeek logs → passed to RITA
- main.py (periodic or on-demand) → fetches AdGuard JSON → outputs whitelists → RITA applies filters
- RITA → writes results to MongoDB and generates HTML reports
- NGINX → serves HTML/CSS/JS reports
- Samba (optional) → exposes PCAPS/REPORTS shares

##### Architectural Patterns and Principles
- Pipeline pattern: discrete processing stages (collect → analyze → report)
- Event-driven: inotify triggers analysis automatically
- Modular templates: decoupled configs for each service
- Single orchestrator entry point for reproducible deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        Operator["Operator (root)"]:::external
        Orchestrator["Orchestrator Shell Script"]:::orchestration
        Vars["Environment Variables"]:::orchestration
        Templates["Configuration Templates"]:::orchestration
        Requirements["Python Dependencies\n(requirements.txt)"]:::orchestration
        GoTool["Go Toolchain"]:::orchestration
        Clear["Cleanup Script\n(helper_scripts/clear.sh)"]:::orchestration
    end

    %% Processing Layer
    subgraph "Processing Layer"
        direction TB
        Watcher["inotify Watcher"]:::processing
        Zeek["Zeek Analysis Engine"]:::processing
        MainPy["Whitelist Generator (main.py)"]:::processing
        AdGuard["AdGuard JSON"]:::external
        RITA["RITA Analysis Engine"]:::processing
    end

    %% Storage Layer
    subgraph "Storage Layer"
        direction TB
        PCAPS["PCAPS Folder"]:::storage
        TmpZeek["/tmp/zeek Logs"]:::storage
        TmpRITA["/tmp/rita Logs"]:::storage
        Mongo["MongoDB"]:::storage
        ReportsDir["REPORTS Folder"]:::storage
    end

    %% Serving Layer
    subgraph "Serving Layer"
        direction TB
        NGINX["NGINX Web Server"]:::serving
        Client["Client Browser"]:::external
        Samba["Samba Share (optional)"]:::serving
    end

    %% Orchestration Flows
    Operator -->|"runs"| Orchestrator
    Orchestrator -->|"loads"| Vars
    Orchestrator -->|"applies"| Templates
    Orchestrator -->|"installs"| Requirements
    Orchestrator -->|"installs"| GoTool
    Orchestrator -->|"sets up"| Clear

    %% Processing Flows
    PCAPS -->|"PCAP file event"| Watcher
    Watcher -->|"triggers"| Zeek
    Zeek -->|"writes Zeek logs"| TmpZeek
    TmpZeek -->|"feeds logs"| RITA
    AdGuard -->|"provides JSON"| MainPy
    MainPy -->|"outputs whitelists"| TmpRITA
    TmpRITA -->|"applies filters"| RITA

    %% Storage Flows
    RITA -->|"stores data"| Mongo
    RITA -->|"generates reports"| ReportsDir

    %% Serving Flows
    ReportsDir -->|"serves HTML/CSS"| NGINX
    NGINX -->|"HTTP GET /report"| Client
    PCAPS -->|"shares"| Samba
    ReportsDir -->|"shares"| Samba

    %% Continuous Loop
    Client -->|"requests new analysis"| Watcher

    %% Click Events
    click Orchestrator "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/this_script.sh"
    click Vars "https://github.com/wellafl3x/infotecs_ti_automation/tree/main/vars"
    click Templates "https://github.com/wellafl3x/infotecs_ti_automation/tree/main/templates/"
    click Requirements "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/requirements.txt"
    click GoTool "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/golang/go1.20.2.linux-amd64.tar.gz"
    click Clear "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/helper_scripts/clear.sh"
    click MainPy "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/main.py"
    click AdGuard "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/external/AdGuard.json"
    click RITA "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/rita/config.yaml"
    click Samba "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/smb/smb.conf"
    click ReportsDir "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/web/index.html"
    click NGINX "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/web/nginx.conf"
    click NGINX "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/web/rita.conf"
    click NGINX "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/web/style.css"
    click Domains "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/whitelists/domains.txt"
    click ResultsTxt "https://github.com/wellafl3x/infotecs_ti_automation/blob/main/templates/whitelists/results.txt"

    %% Styles
    classDef orchestration fill:#b7e4c7,stroke:#2d6a4f,color:#1b4332;
    classDef processing fill:#bee3f8,stroke:#1d3557,color:#1d3557;
    classDef storage fill:#ffd8a8,stroke:#ea580c,color:#c2410c;
    classDef serving fill:#e0c3fc,stroke:#6a4c93,color:#5800ad;
    classDef external fill:#f0f0f0,stroke:#555555,color:#555555;
```
