# eudoxia0/hashcards architecture

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

- Interactive diagram: https://gitdiagram.com/eudoxia0/hashcards
- Repository: https://github.com/eudoxia0/hashcards

## Overview

Hashcards is a plain-text spaced-repetition system: users author Markdown decks, which are parsed into content-addressed cards and tracked in a database; the drill command serves a browser review session and saves graded results using FSRS scheduling. The README also documents collection browsing, integrity checks, due-card listing, statistics, orphan management, and JSON export. Relationships for sampled modules are supported by excerpts or the SOURCE INDEX; links to unsampled command implementations reflect README-documented capabilities, with implementation details not independently inspected.

Main entry points: [`src/cli.rs`](https://github.com/eudoxia0/hashcards/blob/master/src/cli.rs) (CLI entry), [`src/cmd/drill/server.rs`](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/server.rs) (Review browser), [`src/db.rs`](https://github.com/eudoxia0/hashcards/blob/master/src/db.rs) (Progress database), [`src/cmd/drill/post.rs`](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/post.rs) (Grade submission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Deck Content"]
  node_parser["Deck parser<br/>[parser.rs]"]
  node_cards["Card model<br/>[card.rs]"]
  node_collection["Collection loader<br/>[collection.rs]"]
  node_media["Media resolution<br/>[resolve.rs]"]
end

subgraph group_review["Review Session"]
  node_browser["Review browser<br/>[server.rs]"]
  node_review_state["Session state<br/>[state.rs]"]
  node_review_get["Review display<br/>[get.rs]"]
  node_review_post["Grade submission<br/>[post.rs]"]
  node_review_cache["Review cache<br/>[cache.rs]"]
end

subgraph group_persistence["Scheduling Data"]
  node_db[("Progress database<br/>[db.rs]")]
  node_scheduler["FSRS scheduling<br/>[fsrs.rs]"]
  node_performance["Review performance<br/>[performance.rs]"]
end

subgraph group_commands["Collection Tools"]
  node_browse["Collection browser<br/>[server.rs]"]
  node_check["Integrity check<br/>[check.rs]"]
  node_due["Due cards<br/>[due.rs]"]
  node_stats["Collection statistics<br/>[stats.rs]"]
  node_orphans["Orphan management<br/>[orphans.rs]"]
  node_export["JSON export<br/>[export.rs]"]
end

node_user(("Collection author"))
node_cli["CLI entry<br/>[cli.rs]"]

node_user -->|"runs commands"| node_cli
node_cli -.->|"loads collection"| node_collection
node_collection -->|"parses decks"| node_parser
node_collection -->|"opens progress"| node_db
node_parser -->|"creates cards"| node_cards
node_cards -->|"resolves media"| node_media
node_cli -.->|"starts drilling"| node_browser
node_user -->|"reviews cards"| node_browser
node_browser -->|"routes display"| node_review_get
node_browser -->|"routes grades"| node_review_post
node_browser -->|"loads session"| node_review_state
node_browser -->|"uses cache"| node_review_cache
node_review_post -->|"updates session"| node_review_state
node_review_post -->|"schedules grade"| node_scheduler
node_review_post -->|"saves reviews"| node_db
node_review_state -->|"reads progress"| node_db
node_review_cache -->|"loads history"| node_db
node_scheduler -->|"updates performance"| node_performance
node_cli -.->|"opens browser"| node_browse
node_cli -.->|"runs check"| node_check
node_cli -.->|"lists due cards"| node_due
node_cli -.->|"prints statistics"| node_stats
node_cli -.->|"manages orphans"| node_orphans
node_cli -.->|"exports collection"| node_export
node_export -->|"reads collection"| node_collection
node_export -->|"reads progress"| node_db

click node_cli "https://github.com/eudoxia0/hashcards/blob/master/src/cli.rs"
click node_parser "https://github.com/eudoxia0/hashcards/blob/master/src/parser.rs"
click node_cards "https://github.com/eudoxia0/hashcards/blob/master/src/types/card.rs"
click node_collection "https://github.com/eudoxia0/hashcards/blob/master/src/collection.rs"
click node_media "https://github.com/eudoxia0/hashcards/blob/master/src/media/resolve.rs"
click node_browser "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/server.rs"
click node_review_state "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/state.rs"
click node_review_get "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/get.rs"
click node_review_post "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/post.rs"
click node_review_cache "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/cache.rs"
click node_db "https://github.com/eudoxia0/hashcards/blob/master/src/db.rs"
click node_scheduler "https://github.com/eudoxia0/hashcards/blob/master/src/fsrs.rs"
click node_performance "https://github.com/eudoxia0/hashcards/blob/master/src/types/performance.rs"
click node_browse "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/browse/server.rs"
click node_check "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/check.rs"
click node_due "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/due.rs"
click node_stats "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/stats.rs"
click node_orphans "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/orphans.rs"
click node_export "https://github.com/eudoxia0/hashcards/blob/master/src/cmd/export.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_parser,node_cards,node_collection,node_media toneBlue
class node_browser,node_review_state,node_review_get,node_review_post,node_review_cache toneAmber
class node_db,node_scheduler,node_performance toneMint
class node_browse,node_check,node_due,node_stats,node_orphans,node_export toneRose
class node_user toneIndigo
class node_cli toneTeal
```

## Components

### Deck Content

- [Deck parser](https://github.com/eudoxia0/hashcards/blob/master/src/parser.rs): `src/parser.rs`
- [Card model](https://github.com/eudoxia0/hashcards/blob/master/src/types/card.rs): `src/types/card.rs`
- [Collection loader](https://github.com/eudoxia0/hashcards/blob/master/src/collection.rs): `src/collection.rs`
- [Media resolution](https://github.com/eudoxia0/hashcards/blob/master/src/media/resolve.rs): `src/media/resolve.rs`

### Review Session

- [Review browser](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/server.rs): `src/cmd/drill/server.rs`
- [Session state](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/state.rs): `src/cmd/drill/state.rs`
- [Review display](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/get.rs): `src/cmd/drill/get.rs`
- [Grade submission](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/post.rs): `src/cmd/drill/post.rs`
- [Review cache](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/drill/cache.rs): `src/cmd/drill/cache.rs`

### Scheduling Data

- [Progress database](https://github.com/eudoxia0/hashcards/blob/master/src/db.rs): `src/db.rs`
- [FSRS scheduling](https://github.com/eudoxia0/hashcards/blob/master/src/fsrs.rs): `src/fsrs.rs`
- [Review performance](https://github.com/eudoxia0/hashcards/blob/master/src/types/performance.rs): `src/types/performance.rs`

### Collection Tools

- [Collection browser](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/browse/server.rs): `src/cmd/browse/server.rs`
- [Integrity check](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/check.rs): `src/cmd/check.rs`
- [Due cards](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/due.rs): `src/cmd/due.rs`
- [Collection statistics](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/stats.rs): `src/cmd/stats.rs`
- [Orphan management](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/orphans.rs): `src/cmd/orphans.rs`
- [JSON export](https://github.com/eudoxia0/hashcards/blob/master/src/cmd/export.rs): `src/cmd/export.rs`

### Other components

- **Collection author**
- [CLI entry](https://github.com/eudoxia0/hashcards/blob/master/src/cli.rs): `src/cli.rs`

## Connections

- Collection author → CLI entry: runs commands
- CLI entry → Collection loader: loads collection
- Collection loader → Deck parser: parses decks (evidence: `src/collection.rs`)
- Collection loader → Progress database: opens progress (evidence: `src/collection.rs`)
- Deck parser → Card model: creates cards (evidence: `src/parser.rs`)
- Card model → Media resolution: resolves media (evidence: `src/types/card.rs`)
- CLI entry → Review browser: starts drilling
- Collection author → Review browser: reviews cards
- Review browser → Review display: routes display (evidence: `src/cmd/drill/server.rs`)
- Review browser → Grade submission: routes grades (evidence: `src/cmd/drill/server.rs`)
- Review browser → Session state: loads session (evidence: `src/cmd/drill/server.rs`)
- Review browser → Review cache: uses cache (evidence: `src/cmd/drill/server.rs`)
- Grade submission → Session state: updates session (evidence: `src/cmd/drill/post.rs`)
- Grade submission → FSRS scheduling: schedules grade (evidence: `src/cmd/drill/post.rs`)
- Grade submission → Progress database: saves reviews (evidence: `src/cmd/drill/post.rs`)
- Session state → Progress database: reads progress (evidence: `src/cmd/drill/state.rs`)
- Review cache → Progress database: loads history (evidence: `src/cmd/drill/cache.rs`)
- FSRS scheduling → Review performance: updates performance (evidence: `src/types/performance.rs`)
- CLI entry → Collection browser: opens browser
- CLI entry → Integrity check: runs check
- CLI entry → Due cards: lists due cards
- CLI entry → Collection statistics: prints statistics
- CLI entry → Orphan management: manages orphans
- CLI entry → JSON export: exports collection
- JSON export → Collection loader: reads collection (evidence: `src/cmd/export.rs`)
- JSON export → Progress database: reads progress (evidence: `src/cmd/export.rs`)
