docs: initialize project documentation, AI guidelines, and logging standards

This commit is contained in:
2026-08-15 00:31:20 -07:00
parent 150e3dfbd5
commit 3d0156a7d8
5 changed files with 230 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# System Architecture
Hireme is designed as a single-binary, local-first web application. It combines a high-performance backend, an embedded database, background job processing, and a lightweight frontend into a cohesive, easy-to-deploy system.
## Components
### 1. Database Layer (`internal/db`)
- **Technology:** SQLite3 via `github.com/mattn/go-sqlite3`.
- **Mode:** WAL (Write-Ahead Logging) mode is enabled (`PRAGMA journal_mode=WAL;`) to support high concurrency between the HTTP server reads and background worker writes without "database is locked" errors.
- **Pattern:** Centralized query methods attached to a `DB` struct (`queries.go`).
### 2. Worker Pool & Task Queue (`internal/worker`, `internal/db/tasks.go`)
- **Technology:** Custom goroutine worker pool pulling from a `tasks` SQLite table.
- **Tasks:**
- `DISCOVER`: Initiates crawling on a target (e.g., Google Jobs search URL).
- `FETCH`: Fetches raw HTML for a specific job posting.
- `PROCESS`: Parses raw HTML, applies rule-based filtering (keywords, scoring), and enqueues for analysis if qualified.
- `ANALYZE`: Sends the parsed job to an LLM for final qualification scoring and tailoring tips.
- **Concurrency:** Managed via context cancellation and `atomic.Bool` flags for safe pausing and resuming.
### 3. Filters & Rules (`internal/filter`, `data/config/filters.yaml`)
- A pipeline pattern is used to quickly reject jobs before doing expensive LLM API calls.
- **Hard Keywords:** Immediate rejection if a keyword (e.g., "Clearance", "Staff") is found.
- **Scoring Weights:** Basic substring counting for required technologies (e.g., "Go", "Python"). If the raw score falls below a threshold, the job is rejected.
### 4. Crawlers (`pkg/crawler`)
- Currently implements Google Jobs (`pkg/crawler/google`).
- **Mechanism:** Parses embedded JSON (`AF_initDataCallback`) in the raw HTML response rather than fragile DOM traversal. This ensures stability against UI changes.
### 5. UI Layer (`internal/ui`)
- **Technology:** Standard Go HTTP server (`net/http`), Go Templates (`html/template`), HTMX, and Tailwind CSS.
- **Philosophy:** Server-Side Rendered (SSR) HTML fragments returned directly to HTMX for seamless, single-page application (SPA) like updates without heavy JS payloads.
- **Templates:** Statically compiled strings in `.go` files (`template_layout.go`, `template_jobs.go`) rather than external `.html` files to keep the binary fully self-contained.
### 6. Logging (`internal/logger`)
- **Technology:** `go.uber.org/zap` (Sugared Logger).
- **Pattern:** Structured logging using `w` methods (`Infow`, `Errorw`, `Debugw`) to allow for strongly-typed key-value pairs (`"component", "API"`) instead of string formatting.
+38
View File
@@ -0,0 +1,38 @@
# UI Guidelines
Hireme uses a modern, server-rendered UI stack that eliminates the need for heavy JavaScript frameworks (React, Vue, etc.) while maintaining a highly reactive, single-page application (SPA) feel.
## Stack
- **HTML / Go Templates:** Server-side rendering using `html/template`.
- **HTMX (`hx-*`):** Used for all dynamic interactions, form submissions, and UI updates.
- **Tailwind CSS:** Utility-first CSS framework for styling via CDN.
## Architecture & Patterns
### 1. Template Strings vs Files
Templates are declared as `const` strings in `.go` files (e.g., `template_layout.go`, `template_jobs.go`) and collected in a `TemplateRegistry` in `templates.go`. This keeps the final build as a single executable without requiring external static asset folders.
### 2. HTMX Updates
Instead of returning JSON and re-rendering via JS, API endpoints return rendered HTML fragments.
- **Example:** Clicking `+ Save` on a job POSTs to `/applications`. The handler updates the DB and returns the `template_jobs` HTML fragment, which HTMX swaps directly into the `#jobs-container` DOM element.
### 3. Layout & Navigation (Tab Persistence)
- The main UI uses a tabbed layout (Jobs, Apply, Targets).
- Switching tabs is handled via lightweight Vanilla JS (`switchTab(id)`) which toggles `.hidden` classes.
- Tab states are synced to the URL `#hash` so reloading the page preserves the active tab.
### 4. Client-Side Filtering & Sorting
- To prevent unnecessary server load for display formatting, table sorting and filtering (e.g., searching by keyword, or filtering by "Qualified") is done purely client-side using Vanilla JS.
- Data attributes (`data-sort-val`, `data-qual`, `data-app`) are embedded in the `<tr>` elements during server-render to aid the JS filter logic.
### 5. Design Aesthetics
- **Dark Mode Default:** The UI uses Tailwind's `dark:` classes implicitly by having `class="dark"` on the root `<html>` tag.
- **Micro-interactions:** Use hover states (`hover:bg-slate-800`), transitions (`transition-colors`), and subtle borders to create a premium feel.
- **Indicators:** Use badges and color-coded text (Emerald for success/qualified, Rose for rejected/not qualified, Indigo for actions).