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
+32
View File
@@ -0,0 +1,32 @@
# AI Development Guidelines for Hireme
These guidelines provide context to AI assistants working on the `hireme` repository. Adhere to these principles to maintain the project's architecture and design philosophy.
## 1. Single Binary & Zero Dependencies
- **Goal:** The application must compile into a single Go binary.
- **Rule:** Do NOT introduce external dependencies that require separate build steps, node_modules, or static asset folders unless explicitly authorized.
- **Rule:** Use Go 1.22+ standard library features wherever possible (e.g., `net/http` `ServeMux`).
## 2. UI Philosophy (HTMX + Tailwind)
- **Rule:** Do NOT introduce React, Vue, or any heavy JS frameworks.
- **Rule:** All dynamic interactions must be handled via HTMX (`hx-get`, `hx-post`, `hx-target`). Endpoints should return HTML fragments, not JSON, for UI updates.
- **Rule:** CSS is handled via Tailwind CSS utility classes. Maintain the dark mode aesthetic using `bg-slate-*`, `text-slate-*`, and vibrant accents (`indigo`, `emerald`, `rose`).
- **Rule:** UI templates are stored as constant strings in Go files (`internal/ui/template_*.go`) and registered in `templates.go`. Do not create external `.html` files.
## 3. Database Integrity
- **Rule:** Use `go-sqlite3` and ensure `PRAGMA journal_mode=WAL;` is maintained. The application heavily relies on WAL mode to allow concurrent reads (from the UI) and writes (from background workers).
- **Rule:** Avoid long-running transactions that could lock the database.
## 4. Structured Logging
- **Rule:** Use `zap` structured logging exclusively. Do NOT use the standard library `log.Printf`.
- **Rule:** Use the `w` methods (`Infow`, `Debugw`, `Errorw`) to pass key-value pairs.
- **Correct:** `logger.Log.Infow("User created", "component", "API", "user_id", id)`
- **Incorrect:** `logger.Log.Infof("[API] User created: %d", id)`
## 5. Background Workers
- **Rule:** Long-running tasks (Crawling, LLM Analysis) must be executed asynchronously via the `internal/worker` pool. Do not block HTTP request handlers. Enqueue tasks in the SQLite `tasks` table instead.
+51
View File
@@ -0,0 +1,51 @@
---
name: Structured Logging with Zap
description: How to correctly use the zap structured logging library in this repository instead of standard log or string formatting.
---
# Structured Logging with Zap
When adding logs to the `hireme` repository, **always** use the global `logger.Log` (which is a `zap.SugaredLogger`).
Do **NOT** use `log.Printf` or `fmt.Printf`.
Do **NOT** use `logger.Log.Infof` to format strings with variables if those variables should be structured data.
## Proper Usage (The `w` methods)
Use the `w` variants of the log methods (`Infow`, `Debugw`, `Errorw`, `Warnw`). These methods take a message string as the first argument, followed by variadic key-value pairs.
### Example: API Endpoints
Always include a `"component", "API"` field.
```go
// GOOD
logger.Log.Infow("Triggered endpoint", "component", "API", "endpoint", "/applications", "status", "success")
// BAD - String interpolation hides the data from JSON parsers
logger.Log.Infof("[API] Triggered /applications with status %s", "success")
```
### Example: Background Workers
Include the worker ID and task ID.
```go
// GOOD
logger.Log.Errorw("Task processing failed", "component", "Worker", "worker_id", id, "task_id", task.ID, "error", err)
```
### Example: Database Operations
```go
// GOOD
logger.Log.Debugw("Running query", "component", "DB", "query", "SELECT * FROM jobs")
```
## Summary of `w` Methods
- `logger.Log.Debugw(msg string, keysAndValues ...interface{})`
- `logger.Log.Infow(msg string, keysAndValues ...interface{})`
- `logger.Log.Warnw(msg string, keysAndValues ...interface{})`
- `logger.Log.Errorw(msg string, keysAndValues ...interface{})`
- `logger.Log.Fatalw(msg string, keysAndValues ...interface{})` // Note: calls os.Exit(1)