# defuse/crackstation-rust architecture

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

- Interactive diagram: https://gitdiagram.com/defuse/crackstation-rust
- Repository: https://github.com/defuse/crackstation-rust

## Overview

crackstation-rust is a web application for looking up plaintext preimages of submitted hashes, alongside informational pages and downloadable wordlists. A visitor submits hashes to the home-page handler; it verifies reCAPTCHA and delegates cracking to the preimage-backed oracle, then returns results. The request dispatcher resolves registered pages, builds request context, and records hit counts. The README documents the lookup dependency and wordlist capability; unsampled implementation details are represented only at supported directory-level paths, and edges without explicit evidence are omitted.

Main entry points: [`src/registered_page_handler.rs`](https://github.com/defuse/crackstation-rust/blob/main/src/registered_page_handler.rs) (Page dispatcher), [`src/main.rs`](https://github.com/defuse/crackstation-rust/blob/main/src/main.rs) (HTTP server), [`src/app_state.rs`](https://github.com/defuse/crackstation-rust/blob/main/src/app_state.rs) (Application state), [`src/libs/phpcount.rs`](https://github.com/defuse/crackstation-rust/blob/main/src/libs/phpcount.rs) (Hit counter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web request handling"]
  node_server["HTTP server<br/>[main.rs]"]
  node_canonical["URL canonicalization"]
  node_dispatcher["Page dispatcher"]
  node_page_registry["Page registry<br/>[pages.rs]"]
  node_page_handlers["Page handler contract<br/>[handler.rs]"]
  node_request_context["Request context<br/>[context.rs]"]
  node_security_middleware["Security middleware"]
end

subgraph group_lookup["Hash lookup"]
  node_home["Hash submission page<br/>[home.rs]"]
  node_cracking["Hash cracking<br/>[cracking.rs]"]
  node_preimage["Preimage crate"]
  node_hash_indexes[("Hash indexes")]
end

subgraph group_site["Site content"]
  node_info_pages["Informational pages"]
  node_wordlist["Wordlist downloads"]
  node_page_templates["Page templates"]
end

subgraph group_state["State and integrations"]
  node_app_state["Application state<br/>[app_state.rs]"]
  node_hit_counter["Hit counter<br/>[phpcount.rs]"]
  node_mysql[("MySQL database")]
  node_recaptcha["Google reCAPTCHA"]
end

node_visitor(("Visitor"))

node_visitor -->|"sends requests"| node_server
node_server -->|"applies middleware"| node_canonical
node_server -->|"routes page requests"| node_dispatcher
node_server -->|"applies middleware"| node_security_middleware
node_dispatcher -->|"resolves paths"| node_page_registry
node_dispatcher -->|"dispatches methods"| node_page_handlers
node_dispatcher -->|"builds context"| node_request_context
node_dispatcher -->|"records hits"| node_hit_counter
node_dispatcher -->|"reads state"| node_app_state
node_page_registry -->|"registers handlers"| node_page_handlers
node_home -->|"requests cracking"| node_cracking
node_cracking -->|"looks up hashes"| node_preimage
node_preimage -.->|"reads indexes"| node_hash_indexes
node_home -.->|"verifies submissions"| node_recaptcha
node_app_state -->|"holds service"| node_hit_counter
node_hit_counter -->|"reads and writes"| node_mysql
node_app_state -->|"holds oracle"| node_preimage
node_visitor -->|"downloads lists"| node_wordlist

click node_server "https://github.com/defuse/crackstation-rust/blob/main/src/main.rs"
click node_canonical "https://github.com/defuse/crackstation-rust/blob/main/src/middleware/url_canonicalization.rs"
click node_dispatcher "https://github.com/defuse/crackstation-rust/blob/main/src/registered_page_handler.rs"
click node_page_registry "https://github.com/defuse/crackstation-rust/blob/main/src/registry/pages.rs"
click node_page_handlers "https://github.com/defuse/crackstation-rust/blob/main/src/handler.rs"
click node_request_context "https://github.com/defuse/crackstation-rust/blob/main/src/context.rs"
click node_home "https://github.com/defuse/crackstation-rust/blob/main/src/pages/home.rs"
click node_cracking "https://github.com/defuse/crackstation-rust/blob/main/src/cracking.rs"
click node_hash_indexes "https://github.com/defuse/crackstation-rust/tree/main/dev"
click node_info_pages "https://github.com/defuse/crackstation-rust/tree/main/src/pages"
click node_wordlist "https://github.com/defuse/crackstation-rust/tree/main/static/downloads"
click node_page_templates "https://github.com/defuse/crackstation-rust/tree/main/templates/pages"
click node_app_state "https://github.com/defuse/crackstation-rust/blob/main/src/app_state.rs"
click node_hit_counter "https://github.com/defuse/crackstation-rust/blob/main/src/libs/phpcount.rs"
click node_security_middleware "https://github.com/defuse/crackstation-rust/blob/main/src/middleware/security_headers.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_canonical,node_dispatcher,node_page_registry,node_page_handlers,node_request_context,node_security_middleware toneBlue
class node_home,node_cracking,node_preimage,node_hash_indexes toneAmber
class node_info_pages,node_wordlist,node_page_templates toneMint
class node_app_state,node_hit_counter,node_mysql,node_recaptcha toneRose
class node_visitor toneIndigo
```

## Components

### Web request handling

- [HTTP server](https://github.com/defuse/crackstation-rust/blob/main/src/main.rs): `src/main.rs`
- [URL canonicalization](https://github.com/defuse/crackstation-rust/blob/main/src/middleware/url_canonicalization.rs): `src/middleware/url_canonicalization.rs`
- [Page dispatcher](https://github.com/defuse/crackstation-rust/blob/main/src/registered_page_handler.rs): `src/registered_page_handler.rs`
- [Page registry](https://github.com/defuse/crackstation-rust/blob/main/src/registry/pages.rs): `src/registry/pages.rs`
- [Page handler contract](https://github.com/defuse/crackstation-rust/blob/main/src/handler.rs): `src/handler.rs`
- [Request context](https://github.com/defuse/crackstation-rust/blob/main/src/context.rs): `src/context.rs`
- [Security middleware](https://github.com/defuse/crackstation-rust/blob/main/src/middleware/security_headers.rs): `src/middleware/security_headers.rs`

### Hash lookup

- [Hash submission page](https://github.com/defuse/crackstation-rust/blob/main/src/pages/home.rs): `src/pages/home.rs`
- [Hash cracking](https://github.com/defuse/crackstation-rust/blob/main/src/cracking.rs): `src/cracking.rs`
- **Preimage crate**
- [Hash indexes](https://github.com/defuse/crackstation-rust/tree/main/dev): `dev`

### Site content

- [Informational pages](https://github.com/defuse/crackstation-rust/tree/main/src/pages): `src/pages`
- [Wordlist downloads](https://github.com/defuse/crackstation-rust/tree/main/static/downloads): `static/downloads`
- [Page templates](https://github.com/defuse/crackstation-rust/tree/main/templates/pages): `templates/pages`

### State and integrations

- [Application state](https://github.com/defuse/crackstation-rust/blob/main/src/app_state.rs): `src/app_state.rs`
- [Hit counter](https://github.com/defuse/crackstation-rust/blob/main/src/libs/phpcount.rs): `src/libs/phpcount.rs`
- **MySQL database**
- **Google reCAPTCHA**

### Other components

- **Visitor**

## Connections

- Visitor → HTTP server: sends requests (evidence: `README.md`)
- HTTP server → URL canonicalization: applies middleware (evidence: `src/main.rs`)
- HTTP server → Page dispatcher: routes page requests (evidence: `src/main.rs`)
- HTTP server → Security middleware: applies middleware (evidence: `src/main.rs`)
- Page dispatcher → Page registry: resolves paths (evidence: `src/registered_page_handler.rs`)
- Page dispatcher → Page handler contract: dispatches methods (evidence: `src/registered_page_handler.rs`)
- Page dispatcher → Request context: builds context (evidence: `src/registered_page_handler.rs`)
- Page dispatcher → Hit counter: records hits (evidence: `src/registered_page_handler.rs`)
- Page dispatcher → Application state: reads state (evidence: `src/registered_page_handler.rs`)
- Page registry → Page handler contract: registers handlers (evidence: `src/registry/mod.rs`)
- Hash submission page → Hash cracking: requests cracking (evidence: `src/pages/home.rs`)
- Hash cracking → Preimage crate: looks up hashes (evidence: `README.md`)
- Preimage crate → Hash indexes: reads indexes
- Hash submission page → Google reCAPTCHA: verifies submissions
- Application state → Hit counter: holds service (evidence: `src/app_state.rs`)
- Hit counter → MySQL database: reads and writes (evidence: `src/libs/phpcount.rs`)
- Application state → Preimage crate: holds oracle (evidence: `src/app_state.rs`)
- Visitor → Wordlist downloads: downloads lists (evidence: `README.md`)
