# akhilsharma90/docbot architecture

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

- Interactive diagram: https://gitdiagram.com/akhilsharma90/docbot
- Repository: https://github.com/akhilsharma90/docbot

## Overview

##### Project Type and Purpose
- DOCBOT is a Rust-based, full-stack command‐line application for cracking PDF passwords using both dictionary and brute-force techniques.
- It is organized as a workspace of four crates:
- cli-interface – handles argument parsing, help/banner display, and user I/O
- producer       – generates password candidates (date, range, default, custom queries)
- engine         – orchestrates multithreading, schedules candidate batches, coordinates producers and crackers
- cracker        – attempts to unlock PDF streams with given passwords

##### Main Components
- External Input: the encrypted PDF file provided by the user
- CLI Interface (crate `cli-interface`):
- Parses `docbot` arguments (file path, attack type, parameters)
- Displays banners/help text
- Dispatches to the appropriate producer submodule or dictionary attack
- Producer Layer (crate `producer`):
- default_query (alphanumeric brute force)
- dates        (DDMMYYYY date generator)
- number_ranges (numeric ranges)
- custom_query (user-specified format with ranges and optional zero padding)
- dictionary   (reads wordlists from disk)
- Engine Layer (crate `engine`):
- Implements a thread pool (using all CPU cores)
- Requests password batches from producer modules
- Enqueues tasks to the cracker module
- Monitors progress and halts on success
- Cracker Layer (crate `cracker`):
- Performs the low-level PDF opening/decryption attempts
- Returns success/failure for each password
- Test Harness (`tests/`): validates each attack mode and edge cases

##### Component Relationships and Data Flow
1. User invokes `docbot` binary → CLI Interface
2. CLI Interface parses params → selects Producer strategy or dictionary mode
3. Engine receives the selected Producer → requests the next batch of candidate passwords
4. Engine dispatches each candidate batch to the Cracker (in parallel threads)
5. Cracker attempts PDF unlock → returns result to Engine
6. Engine reports success or continues until exhaustion → CLI outputs result

##### Architectural Patterns and Principles
- Modular Crate Boundary: clear separation of concerns via Rust workspace crates
- Pipeline Pattern: Producer → Engine → Cracker
- Thread-Pool Worker Pattern in Engine for concurrency
- Builder/Strategy Pattern in Producer for flexible query generation
- Single-Responsibility: each crate has one focused domain

##### Technologies and Frameworks
- Rust/Cargo workspace and crates
- Threading primitives (`std::thread`, channels, or `rayon`) in `engine`
- PDF parsing/decryption library in `cracker` (e.g., `lopdf` or similar)
- CLI argument parser (e.g., `clap` or `structopt`) in `cli-interface`

## Diagram (Mermaid)

```mermaid
flowchart TB
    PDF["Encrypted PDF File"]:::external

    subgraph "CLI Interface"
        CLI["docbot CLI"]:::cli
        Args["Argument Parser"]:::cli
        Banner["Banner/Help Display"]:::cli
    end

    subgraph "Producer Layer"
        DQ["default_query"]:::producer
        DT["dates"]:::producer
        NR["number_ranges"]:::producer
        CQ["custom_query"]:::producer
        DICT["dictionary"]:::producer
    end

    subgraph "Engine Layer"
        Engine["Engine Core\n(N worker threads)"]:::engine
    end

    subgraph "Cracker Layer"
        Cracker["Cracker Core"]:::cracker
    end

    subgraph "Support Artifacts"
        Ex["examples/"]:::support
        Tests["tests/"]:::support
        Manifest["Cargo.toml"]:::support
        Main["src/main.rs"]:::support
        Readme["README.md"]:::support
        License["LICENSE"]:::support
    end

    PDF -->|"input file"| CLI
    CLI -->|"select strategy"| DQ
    CLI -->|"select strategy"| DT
    CLI -->|"select strategy"| NR
    CLI -->|"select strategy"| CQ
    CLI -->|"select strategy"| DICT

    DQ -->|"Password Batch[]"| Engine
    DT -->|"Password Batch[]"| Engine
    NR -->|"Password Batch[]"| Engine
    CQ -->|"Password Batch[]"| Engine
    DICT -->|"Password Batch[]"| Engine

    Engine -->|"Password Batch[]"| Cracker
    Cracker -->|"Attempt Result"| Engine
    Engine -->|"Final Status"| CLI

    click CLI "https://github.com/akhilsharma90/docbot/blob/master/crates/cli-interface/src/lib.rs"
    click Args "https://github.com/akhilsharma90/docbot/blob/master/crates/cli-interface/src/arguments.rs"
    click Banner "https://github.com/akhilsharma90/docbot/blob/master/crates/cli-interface/src/banner/mod.rs"
    click DQ "https://github.com/akhilsharma90/docbot/blob/master/crates/producer/src/default_query.rs"
    click DT "https://github.com/akhilsharma90/docbot/blob/master/crates/producer/src/dates.rs"
    click NR "https://github.com/akhilsharma90/docbot/blob/master/crates/producer/src/number_ranges.rs"
    click CQ "https://github.com/akhilsharma90/docbot/blob/master/crates/producer/src/custom_query.rs"
    click DICT "https://github.com/akhilsharma90/docbot/blob/master/crates/producer/src/dictionary.rs"
    click Engine "https://github.com/akhilsharma90/docbot/blob/master/crates/engine/src/lib.rs"
    click Cracker "https://github.com/akhilsharma90/docbot/blob/master/crates/cracker/src/lib.rs"
    click Ex "https://github.com/akhilsharma90/docbot/tree/master/examples/"
    click Tests "https://github.com/akhilsharma90/docbot/tree/master/tests/"
    click Manifest "https://github.com/akhilsharma90/docbot/blob/master/Cargo.toml"
    click Main "https://github.com/akhilsharma90/docbot/blob/master/src/main.rs"

    classDef external fill:#f9f,stroke:#333,stroke-width:2px
    classDef cli fill:#9f9,stroke:#333,stroke-width:2px
    classDef producer fill:#ff9,stroke:#333,stroke-width:2px
    classDef engine fill:#9cf,stroke:#333,stroke-width:2px
    classDef cracker fill:#f99,stroke:#333,stroke-width:2px
    classDef support fill:#ccc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
