-
Notifications
You must be signed in to change notification settings - Fork 0
Company Entity
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.
The Company model is synchronized between a Rust struct for backend processing/persistence and a TypeScript interface for the Svelte frontend.
The Rust Company struct includes both persistent fields (from YAML frontmatter) and derived fields calculated at runtime, such as due_for_check and screening.
| 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. |
The frontend interface mirrors the Rust struct to ensure type safety across the Tauri IPC bridge.
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).
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).
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.
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
| 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. |
The companiesStore manages the global state of all loaded companies using Svelte 5 runes ($state).
The store acts as the single source of truth for the UI, handling initial loads, vault selection, and optimistic updates via the apply helper.
- Reactivity: When a command like
updateFieldis called, it awaits the result from the backend (the re-parsedCompanyobject) and passes it toapply(), which replaces the existing object in the$statearray. - Persistence: The
vaultPathis persisted inlocalStorageto maintain context across sessions.
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
searchCompaniesfunction 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
notesSnippetaround the hit).
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