# gilillo32/rise architecture

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

- Interactive diagram: https://gitdiagram.com/gilillo32/rise
- Repository: https://github.com/gilillo32/rise

## Overview

##### Project Type and Purpose
- The project is an online service map focused on identifying and alerting about cybersecurity vulnerabilities in companies located in the Basque Country.
- It is a full-stack web application that integrates a Node.js/Express backend with a set of frontend views (using EJS templates) and static public assets (CSS, JavaScript, images). In addition, it includes a specialized scanning service (under the “nuclei” directory) implemented in Python that manages vulnerability scanning, process orchestration, and result handling.
- The README confirms the service is used to detect, diagnose, and provide early warnings of cybersecurity issues.

##### Analysis of the File Structure
- Top-level directories and files indicate a symbiotic architecture:
- "controllers", "models", "routes", "server.js": Core Node.js backend components.
- "views" and "public": Frontend presentation layers. "views" contain EJS templates and partials; "public" holds CSS, JavaScript, images, and static JSON data.
- "nuclei": Contains Python scripts and shell scripts for scanning operations, configuration files, and a shared volume for scan results. This component appears to run separately (and may be orchestrated via Docker or invoked as a daemon) to perform vulnerability assessments.
- "dataset": Provides sample JSON data (companies.json) and a Python script for CSV-to-JSON conversion.
- Configuration and deployment artifacts like Dockerfile, docker-compose.yml, nginx.conf, and a mongo-init.sh file indicate containerized deployment (with Docker) and integration with MongoDB.
- Additional files such as package.json/package-lock.json and requirements.txt show the dual dependency management (npm and pip) for the Node and Python parts respectively.

##### Insights from the README
- The README details setup instructions using Docker Compose, environment variable configuration, and service initialization. It also provides usage instructions for creating users and setting up scans.
- It explains how to launch scanned analysis tasks (using nuclei) and how to enable a scan service daemon.
- Specific environment variables listed hint at a dependency on external services (e.g., Telegram for notifications) and database configurations (MongoDB).

a. Main Components:
- Frontend:
– User Interface represented by EJS views and static assets (HTML, CSS, JS).
– Public folder for styling and client-side logic.
- Backend:
– Node.js server (server.js) orchestrating requests via controllers and routes.
– Business logic in controllers and data models in models folder (e.g., company.js, user.js).
– API endpoints and RESTful services for client interactions.
- Vulnerability Scanning Service:
– Dedicated scanning module (nuclei) built with Python scripts.
– Scripts for launching scans (launch_scan.py, process_scan_results.py) and management (telegram_bot_manager.py).
– Shared volume for storing scan results and configuration (rise-config.yml, targets.txt).
– Shell scripts (run_scan_process.sh, setup_rise_service.sh) to run and manage the scanning daemons.
- Database:
– MongoDB for storing user, company, and potentially scan or configuration data (initialized via mongo-init.sh).
- Reverse Proxy / Load Balancer:
– NGINX (nginx.conf) acting as a reverse proxy or static file server.
- Deployment Infrastructure:
– Dockerfile and docker-compose.yml managing containerized deployments of the application and possibly separate containers for the scanning service, the backend API, and the database.

b. Relationships and Interactions:
- The Frontend sends HTTP requests (via forms or AJAX calls) which are received by the Node.js backend.
- The backend, using controllers and routes, processes these requests, interacts with the MongoDB, and renders EJS views with dynamic data.
- The backend may also trigger or communicate with the scanning service to initiate vulnerability scans.
- The scanning service (the nuclei component) periodically or on demand reads configuration, scans specified targets, and writes results into a shared volume.
- Notifications (e.g., via Telegram) or further actions may be triggered by scanning outcomes.
- NGINX routes and load balances incoming traffic to the appropriate backend services.
- Environment variables are used across containers to connect these services securely.

c. Architectural Patterns/Design Principles:
- Separation of Concerns: Frontend, backend API, and scanning services are clearly separated.
- Containerization: Use of Docker and Docker Compose for deployment encapsulation.
- Modularity: The scanning service in the "nuclei" folder is distinct and can be managed or scaled independently.
- Integration: The system integrates multiple technologies (Node.js, Python, MongoDB, NGINX) into one cohesive service.

d. Relevant Technologies/Frameworks:
- Node.js and Express for the backend.
- EJS for server-side templating.
- MongoDB as the database.
- Python and related libraries (per requirements.txt) for scanning tasks.
- Docker and Docker Compose for container orchestration.
- NGINX for reverse proxying and possibly static content delivery.
- Telegram API integration for scan notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        FE1("Frontend (EJS Views & Public Assets)"):::frontend
        FE2("Views (EJS)"):::frontend
        FE3("Static Assets"):::frontend
    end

    %% API Server
    subgraph "API Server"
        BE1("Server Entry Point (server.js)"):::backend
        BE2("Controllers"):::backend
        BE3("Data Models"):::backend
        BE4("Routing"):::backend
    end

    %% Vulnerability Scanning Subsystem
    subgraph "Vulnerability Scanning Subsystem"
        SC1("Launch Scan (launch_scan.py)"):::scanning
        SC4("Scan Process Runner (run_scan_process.sh)"):::scanning
        SC2("Process Scan Results (process_scan_results.py)"):::scanning
        SC3("Telegram Bot Manager (telegram_bot_manager.py)"):::scanning
        SC5("Shared Volume & Config"):::scanning
        SC6("Service Setup (setup_rise_service.sh)"):::scanning
    end

    %% Database Node
    DB("MongoDB Initialization (mongo-init.sh)"):::database

    %% Reverse Proxy Node
    RP("NGINX Reverse Proxy (nginx.conf)"):::proxy

    %% Deployment & Utilities
    subgraph "Deployment & Utilities"
        DU1("Docker Setup Files (Dockerfile & docker-compose.yml)"):::deployment
        DU2("Container Ignoring (.dockerignore)"):::deployment
        DU3("Dataset & CSV Conversion"):::deployment
        DU4("Node Dependencies"):::deployment
        DU5("Python Dependencies"):::deployment
    end

    %% Relationships
    %% Client Side interactions
    FE1 -->|"HTTP"| BE1
    FE2 --> BE1
    FE3 --> BE1

    %% Reverse Proxy routes traffic to API Server
    RP -->|"routes traffic"| BE1

    %% API Server internal delegation
    BE1 --> BE2
    BE1 --> BE3
    BE1 --> BE4

    %% API Server interacts with Database
    BE1 -->|"DBaccess"| DB

    %% API Server triggers Vulnerability Scanning
    BE1 -->|"trigger_scan"| SC1
    SC2 -->|"results"| BE1

    %% Internal Scanning Service Flow
    SC1 -->|"runs"| SC4
    SC4 -->|"processes"| SC2
    SC2 -->|"notifies"| SC3
    SC2 -->|"store"| SC5

    %% Deployment & Utilities support
    DU1 --> BE1
    DU1 --> SC1
    DU1 --> DB
    DU1 --> RP
    DU3 --> BE1
    DU4 --> BE1
    DU5 --> SC1

    %% Click Events
    click FE2 "https://github.com/gilillo32/rise/tree/main/views"
    click FE3 "https://github.com/gilillo32/rise/tree/main/public"
    click BE1 "https://github.com/gilillo32/rise/blob/main/server.js"
    click BE2 "https://github.com/gilillo32/rise/tree/main/controllers"
    click BE3 "https://github.com/gilillo32/rise/tree/main/models"
    click BE4 "https://github.com/gilillo32/rise/blob/main/routes/router.js"
    click SC1 "https://github.com/gilillo32/rise/blob/main/nuclei/launch_scan.py"
    click SC2 "https://github.com/gilillo32/rise/blob/main/nuclei/process_scan_results.py"
    click SC3 "https://github.com/gilillo32/rise/blob/main/nuclei/telegram_bot_manager.py"
    click SC4 "https://github.com/gilillo32/rise/blob/main/nuclei/run_scan_process.sh"
    click SC5 "https://github.com/gilillo32/rise/tree/main/nuclei/shared-volume"
    click SC6 "https://github.com/gilillo32/rise/blob/main/setup_rise_service.sh"
    click DB "https://github.com/gilillo32/rise/blob/main/mongo-init.sh"
    click RP "https://github.com/gilillo32/rise/blob/main/nginx.conf"
    click DU1 "https://github.com/gilillo32/rise/tree/main/Dockerfile"
    click DU2 "https://github.com/gilillo32/rise/blob/main/.dockerignore"
    click DU3 "https://github.com/gilillo32/rise/tree/main/dataset"
    click DU4 "https://github.com/gilillo32/rise/blob/main/package.json"
    click DU5 "https://github.com/gilillo32/rise/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef scanning fill:#ffcc99,stroke:#000,stroke-width:1px;
    classDef database fill:#ff9999,stroke:#000,stroke-width:1px;
    classDef proxy fill:#99ccff,stroke:#000,stroke-width:1px;
    classDef deployment fill:#D8BFD8,stroke:#000,stroke-width:1px;
```
