Skip to content

Company Entity

Chazona Baum edited this page Jun 24, 2026 · 3 revisions

Relevant source files

The Company entity represents a target organization within the job search pipeline. It serves as the parent container for roles (Jobs) and tracks high-level metadata such as domain expertise, business model, and screening status. Companies are persisted as Markdown files within the companies/ directory of the user's vault.

Data Model

The Company model is synchronized between a Rust struct for backend processing/persistence and a TypeScript interface for the Svelte frontend.

Rust Struct (src-tauri/src/company.rs)

The Rust Company struct includes both persistent fields (from YAML frontmatter) and derived fields calculated at runtime, such as due_for_check and screening.

src-tauri/src/company.rs#16-35

Field Type Description
slug String Unique identifier derived from the filename.
name String Display name of the company.
domain Vec<String> List of functional/industry tags (e.g., fintech, security).
due_for_check bool Derived: true if status is active and last_checked is > 3 days old.
screening Option<String> Derived: dealbreaker or caution based on domain screening rules.
notes String The Markdown body of the note.

TypeScript Interface (src/lib/company.ts)

The frontend interface mirrors the Rust struct to ensure type safety across the Tauri IPC bridge.

src/lib/company.ts#3-21

Statuses and Screening

Companies follow a simple lifecycle defined by the status field:

  • active: Currently being monitored for new jobs.
  • paused: Monitoring temporarily disabled.
  • exhausted: No relevant roles found after thorough checking.
  • removed: Soft-deleted (file remains in vault but hidden from main views).

src-tauri/src/company.rs#10

Screening Flags: The screening field is derived by comparing the company's domain tags against the user's domain screening configuration.

  • dealbreaker: If any domain matches a "dealbreaker" rule, the company is flagged immediately.
  • caution: If any domain matches a "caution" rule (and no dealbreakers exist).

src-tauri/src/company.rs#90-104

Sources:src-tauri/src/company.rs#10-35src-tauri/src/company.rs#90-104src/lib/company.ts#3-25


CRUD Operations & Tauri Commands

Company data is managed via Tauri commands that perform atomic updates to the Markdown files. All writes are routed through write_note in note.rs to ensure the file watcher can distinguish app-driven changes from manual user edits.

Command Flow: Natural Language to Code

This diagram maps user actions in the UI to the underlying Rust logic and persistence layer.

UI Action to Backend Command Mapping

flowchart TD
    subgraph Persistence
        FILE["/companies/{slug}.md"]
    end
    subgraph subGraph1 ["Backend (Rust)"]
        CMD["src-tauri/src/company.rs"]
        SLUG["Generate Slug"]
        WRITE["src-tauri/src/note.rs"]
    end
    subgraph subGraph0 ["Frontend (Svelte/TS)"]
        UI["CreateCompanyForm.svelte"]
        CS["companiesStore"]
        IPC["Tauri IPC"]
    end
    UI --> CS
    CS --> IPC
    IPC --> CMD
    CMD --> SLUG
    CMD --> WRITE
    WRITE --> FILE
Loading

Sources:src/lib/companies.svelte.ts#82-86src/lib/company.ts#49-51src-tauri/src/note.rs#25-31src-tauri/src/company.rs#170-210

Key Functions

Function Location Purpose
list_companies src-tauri/src/company.rs Scans the companies/ dir, parses every .md file, and returns a list of Company structs.
update_company_field src-tauri/src/company.rs Updates a single scalar frontmatter field (e.g., stage) using note::set_frontmatter_field.
set_company_list_field src-tauri/src/company.rs Specifically handles Vec<String> fields like domain or business_model using YAML flow sequences ([...]).
set_company_notes src-tauri/src/company.rs Replaces the Markdown body (everything after the frontmatter) using note::set_body.

Sources:src/lib/company.ts#44-83src-tauri/src/note.rs#69-84src-tauri/src/note.rs#110-119


Frontend State Management

The companiesStore manages the global state of all loaded companies using Svelte 5 runes ($state).

companiesStore (src/lib/companies.svelte.ts)

The store acts as the single source of truth for the UI, handling initial loads, vault selection, and optimistic updates via the apply helper.

src/lib/companies.svelte.ts#13-28

  • Reactivity: When a command like updateField is called, it awaits the result from the backend (the re-parsed Company object) and passes it to apply(), which replaces the existing object in the $state array.
  • Persistence: The vaultPath is persisted in localStorage to maintain context across sessions.

src/lib/companies.svelte.ts#24-26src/lib/companies.svelte.ts#76-78

View Logic (src/lib/companyView.ts)

Filtering, sorting, and searching are decoupled from the store into a pure utility module. This allows for complex UI logic (like grouping by domain or relevance ranking) without mutating the underlying data.

  • Search Tiers: The searchCompanies function implements a tiered ranking system for search results.

  • Tier 0: Name prefix match.

  • Tier 1: Name substring match.

  • Tier 2: Domain name match.

  • Tier 3: Domain alias match.

  • Tier 4: Notes body match (includes a notesSnippet around the hit).

src/lib/companyView.ts#162-202

Sources:src/lib/companies.svelte.ts#13-87src/lib/companyView.ts#79-118src/lib/companyView.ts#162-208


Data Flow: Update Sequence

This diagram illustrates the "round-trip" data flow when a user updates a company field, such as changing the status.

Company Field Update Flow

Sources:src/routes/companies/[slug]/+page.svelte:69-90, src/lib/companies.svelte.ts#63-65src-tauri/src/note.rs#25-31src-tauri/src/company.rs#136-166

Clone this wiki locally