# gaurav-chatribin/threat-reputation-checker architecture

> Architecture diagram of the GitHub repository gaurav-chatribin/threat-reputation-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gaurav-chatribin/threat-reputation-checker
- Repository: https://github.com/gaurav-chatribin/threat-reputation-checker

## Overview

##### Project Overview and Purpose
- That this is a backend web application built using Flask. The main goal is to offer a unified interface for checking the reputation of IP addresses and domain names via multiple threat intelligence APIs (VirusTotal, AbuseIPDB, Criminal IP, and Whoislookup).
- The README explains its purpose, features, and user interactions. It’s a single-page web interface where users can enter input, triggering API calls to gather threat intelligence data.

##### Analyzing the File Structure
- Top-Level Files:
- app.py: The main Flask application file; this is the entry point.
- LICENSE, README.md, requirements.txt: These are standard metadata and dependency files.
- module Directory:
- Contains individual Python modules (abuseipdb.py, criminal_ip.py, virustotal.py, whoislookup.py). These encapsulate the functionality to interact with the respective APIs.
- This reflects a modular design pattern where external service interactions are separated for maintainability.
- templates and static Directories:
- templates: Contains index.html, which is used to render the user interface.
- static: Contains style.css for front-end styling.

a. Main Components:
- Web Server / Application Layer: The Flask application in app.py acts as the main controller that receives requests from users.
- API Modules: Represented by individual modules (abuseipdb, criminal_ip, virustotal, whoislookup) which handle external service calls.
- Presentation Layer: Templates (index.html) and static files (style.css) that generate the UI.
- External Services: The third-party APIs provided by VirusTotal, AbuseIPDB, Criminal IP, and Whoislookup that are queried for threat information.

b. Relationships and Interactions:
- User Interaction: The user enters an IP or domain in the browser (UI).
- Request Flow: The browser sends the request to the Flask app (HTTP request).
- Controller Action: app.py receives the request, validates input, and determines which module to invoke based on the input type.
- Module Communication: app.py calls relevant functions from the modules in the module folder, which then issue API calls to external services.
- Data Handling: The responses from these APIs are aggregated, processed, and then rendered back on the index.html template.

c. Architectural Patterns and Principles:
- Modular Design: Each external API is encapsulated in its own module for clean separation of concerns.
- MVC-Like Pattern: Although simple, there’s an evident separation between the view (templates, static), the controller (app.py), and the model/logic (modules handling API calls).
- Single-Page Interface: The UI is simple and dynamic, providing feedback on a single page.

d. Relevant Technologies and Frameworks:
- Python & Flask: For the backend web functionality.
- Requests library: Used within the modules to communicate with the external APIs.
- HTML/CSS: For the frontend via Jinja2 templates served by Flask.
- External APIs: VirusTotal, AbuseIPDB, Criminal IP, and Whoislookup.

##### Instructing the Principal Software Engineer
- Components to include:
- Client / Frontend: Represented by the browser, index.html, and static files.
- Backend Server: The Flask application process running app.py.
- Modules: Separate blocks for abuseipdb.py, criminal_ip.py, virustotal.py, and whoislookup.py.
- External APIs: Represent each external threat intelligence API as distinct services.
- From Client → Flask Application: user request initiation.
- From Flask Application → Each API Module: representing function calls and data aggregation.
- From Modules → External Services: outgoing API calls.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Browser["User Browser"]:::client
        Template["HTML Template (index.html)"]:::client
        CSS["CSS Styling (style.css)"]:::client
    end

    subgraph "Backend Layer"
        Flask["Flask Application (app.py)"]:::backend
    end

    subgraph "API Modules"
        Abuse["AbuseIPDB Module (abuseipdb.py)"]:::module
        Criminal["Criminal IP Module (criminal_ip.py)"]:::module
        Vtotal["VirusTotal Module (virustotal.py)"]:::module
        Whois["Whoislookup Module (whoislookup.py)"]:::module
    end

    subgraph "External Threat Intelligence APIs"
        ExtAbuse(("AbuseIPDB API")):::external
        ExtCriminal(("Criminal IP API")):::external
        ExtVtotal(("VirusTotal API")):::external
        ExtWhois(("Whoislookup API")):::external
    end

    Browser -->|"HTTPRequest"| Flask
    Flask -->|"Calls"| Abuse
    Flask -->|"Calls"| Criminal
    Flask -->|"Calls"| Vtotal
    Flask -->|"Calls"| Whois

    Abuse -->|"Requests"| ExtAbuse
    Criminal -->|"Requests"| ExtCriminal
    Vtotal -->|"Requests"| ExtVtotal
    Whois -->|"Requests"| ExtWhois

    ExtAbuse -->|"Response"| Abuse
    ExtCriminal -->|"Response"| Criminal
    ExtVtotal -->|"Response"| Vtotal
    ExtWhois -->|"Response"| Whois

    Abuse -->|"Returns"| Flask
    Criminal -->|"Returns"| Flask
    Vtotal -->|"Returns"| Flask
    Whois -->|"Returns"| Flask

    Flask -->|"Renders"| Template
    Template -->|"Displays"| Browser

    %% Click Events
    click Flask "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/app.py"
    click Abuse "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/module/abuseipdb.py"
    click Criminal "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/module/criminal_ip.py"
    click Vtotal "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/module/virustotal.py"
    click Whois "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/module/whoislookup.py"
    click Template "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/templates/index.html"
    click CSS "https://github.com/gaurav-chatribin/threat-reputation-checker/blob/main/static/style.css"

    %% Styles
    classDef client fill:#DDEEFF,stroke:#333,stroke-width:2px;
    classDef backend fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef module fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef external fill:#FFCCCC,stroke:#333,stroke-width:2px;
```
