# mroth/unindexed architecture

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

- Interactive diagram: https://gitdiagram.com/mroth/unindexed
- Repository: https://github.com/mroth/unindexed

## Overview

##### Main components
- Application Server – represented by files like index.js (the main entry point), config.js, helpers.js, and comments.js. This is where the primary web logic, routing, and request handling reside.
- View Layer – the “views” directory contains ECT template files (alive.ect, dead.ect, and a CSS template) that render what the visitor sees.
- In-Memory Data Store – Redis is used to temporarily store content (as indicated by the README’s explanation on memory-only content storage and disabled backups).
- Content Loading Module – the load_content.js script is responsible for importing content from an encrypted file (from an external partition) into the in‑memory store at startup.
- Automated Scripts – additional scripts (query.js, reset.js, stats.js) likely serve as background tasks:
- query.js probably continuously checks Google search results.
- reset.js might reinitialize or wipe data (for testing or recovery).
- stats.js could be used for gathering runtime or usage statistics.
- Deployment & Environment Configuration – the project is designed to run on platforms like Heroku (as seen with notes for generating random hostnames, Heroku add-ons for Redis, scheduled tasks, etc.).

##### Relationships and Interactions
- The Application Server handles incoming HTTP requests (from visitors) and renders views using the ECT templates.
- The server interacts with Redis to load and retrieve ephemeral content including user-contributed comments.
- A dedicated background process (or scheduled task) running the query.js script monitors Google search results. When an index is detected, it triggers a deletion process that clears the Redis contents and effectively “kills” the site.
- The content-loading process ensures that initial website content is loaded from a secure, encrypted source and that it is only available in volatile memory.
- External monitoring might interact with a /status endpoint to verify the site’s health.

##### Architectural Patterns and Design Principles
- Ephemeral Storage & Stateless Content: The architecture is built around temporary in‑memory data storage (using Redis) without persistent backups.
- Decoupled Background Tasks: Maintenance tasks (automatic indexing detection, content reset, statistics collection) are handled by separate scripts, suggesting a decoupled design from the main request/response cycle.
- Deployment Environment Segregation: The README suggests environment variables and scheduled scripts to orchestrate behavior, showing a separation between application logic and operational/DevOps configurations.
- Security & Privacy: The use of an encrypted partition for loading initial content and immediate data purging aligns with principles of data minimization and security.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External
    V("Visitor"):::external

    %% Deployment Environment
    subgraph "Deployment Environment"
        DS("Heroku Scheduler"):::deployment
        DS2("Package.json"):::deployment
        DS3("README.md"):::deployment
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        A1("Alive Template"):::frontend
        A2("Dead Template"):::frontend
        A3("CSS Template"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1("index.js"):::backend
        B2("config.js"):::backend
        B3("helpers.js"):::backend
        B4("comments.js"):::backend
        B5("Redis"):::backend
    end

    %% Background Processes
    subgraph "Background Processes"
        C1("Content Loader"):::background
        C2("Query Script"):::background
        C3("Reset Script"):::background
        C4("Stats Script"):::background
    end

    %% Connections - Visitor interaction with Application Server
    V -->|"HTTP_Requests"| B1

    %% Application Server renders views
    B1 -->|"RenderViews"| A1
    B1 -->|"RenderViews"| A2
    B1 -->|"RenderViews"| A3

    %% Application Server interacts with Redis
    B1 -->|"Content_Store/Retrieve"| B5

    %% Content Loader loads initial content into Redis
    C1 -->|"Load_Initial_Content"| B5

    %% Query Script monitors Google and triggers deletion
    C2 -->|"Trigger_Deletion"| B1
    C2 -->|"Purge_Data"| B5

    %% Reset Script wipes data from Redis
    C3 -->|"Wipe_Data"| B5

    %% Stats Script gathers runtime statistics from Application Server
    C4 -->|"Report_Stats"| B1

    %% Deployment Scheduler triggers background scripts
    DS -->|"Schedule"| C2
    DS -->|"Schedule"| C3
    DS -->|"Schedule"| C4

    %% Classes & Styles
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef background fill:#ffb6c1,stroke:#333,stroke-width:2px;
    classDef deployment fill:#ffdead,stroke:#333,stroke-width:2px;

    %% Click Events for Application Server files
    click B1 "https://github.com/mroth/unindexed/blob/master/index.js"
    click B2 "https://github.com/mroth/unindexed/blob/master/config.js"
    click B3 "https://github.com/mroth/unindexed/blob/master/helpers.js"
    click B4 "https://github.com/mroth/unindexed/blob/master/comments.js"

    %% Click Events for View Layer templates
    click A1 "https://github.com/mroth/unindexed/blob/master/views/alive.ect"
    click A2 "https://github.com/mroth/unindexed/blob/master/views/dead.ect"
    click A3 "https://github.com/mroth/unindexed/blob/master/views/alive.css.ect"

    %% Click Events for Background Scripts
    click C1 "https://github.com/mroth/unindexed/blob/master/scripts/load_content.js"
    click C2 "https://github.com/mroth/unindexed/blob/master/scripts/query.js"
    click C3 "https://github.com/mroth/unindexed/blob/master/scripts/reset.js"
    click C4 "https://github.com/mroth/unindexed/blob/master/scripts/stats.js"

    %% Click Events for Deployment Components
    click DS2 "https://github.com/mroth/unindexed/blob/master/Package.json"
    click DS3 "https://github.com/mroth/unindexed/blob/master/README.md"
```
