Commit graph

15 commits

Author SHA1 Message Date
Jon Seager
b668d368e7
feat(ai): add AI-powered extraction for roaster and roast forms
Users can upload a photo of a coffee bag or type a text prompt to
auto-fill roaster/roast form fields via OpenRouter's chat completions
API. The feature is opt-in: hidden when BREWLOG_OPENROUTER_API_KEY is
not set.

- Add src/infrastructure/ai.rs with OpenRouter client, prompt
  templates, JSON extraction from model responses, and unit tests
- Add extract-roaster and extract-roast API endpoints behind auth
- Add extraction UI (photo button + text input) to both form templates
- Add openrouter_api_key and openrouter_model to CLI args and AppState
- Enable reqwest gzip feature for compressed API responses
- Default model set to openrouter/free (auto-selects available models)
- Prompts instruct model to use web search for missing details
2026-02-03 18:00:19 +00:00
Jon Seager
5e2ee63a1e
test(cafes): add integration tests for nearby cafe search API
- Add wiremock dev-dependency for HTTP mocking
- Make Nominatim URL configurable via AppState for test injection
- Add spawn_app_with_nominatim_mock() test helper
- Add 6 integration tests covering success, empty results,
  authentication, validation, and upstream failure scenarios
2026-02-03 16:03:54 +00:00
Jon Seager
500389583f
chore(deps): remove unused wiremock dev-dependency
The wiremock crate was declared in dev-dependencies but never
imported or used anywhere in the test code.
2026-02-02 17:43:13 +00:00
Jon Seager
6cd621e10a
refactor(deps): switch from openssl to rustls for TLS
- Add tls-rustls feature to sqlx
- Disable default features on reqwest to avoid native-tls
- Remove openssl from flake.nix build and dev dependencies

This simplifies the build by removing the native OpenSSL dependency,
using pure-Rust TLS implementation instead.
2026-02-02 17:23:42 +00:00
Jon Seager
eabf69545f
feat: improved trace logging 2025-11-26 12:01:53 +00:00
Jon Seager
f88a880d07
feat!: update to a more human friendly url structure for roasters/roasts 2025-11-25 21:34:08 +00:00
Jon Seager
42d0f71eb1
feat!: use numeric, database-generated IDs throughout 2025-11-25 18:21:04 +00:00
copilot-swe-agent[bot]
c91dd5d78d
test(auth): add CLI test for revoked tokens and server tests for session auth
- Add test_revoked_token_cannot_be_used to CLI tests
- Add test_session_authentication_via_login to verify session cookies work
- Add test_invalid_session_cookie_fails to verify unauthenticated requests fail
- Add test_logout_invalidates_session to verify logout clears sessions
- Add test_fake_session_cookie_fails to verify forged cookies don't work
- Enable cookies feature for reqwest in dev-dependencies

All 70 tests pass (8 unit + 46 server + 16 CLI) 

Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:49 +00:00
copilot-swe-agent[bot]
e6811d45ad
feat(frontend): add login page and session-based authentication
- Add tower and tower-cookies dependencies for session management
- Create login page template with username/password form
- Implement /login and /logout routes with cookie-based sessions
- Update navigation bar to show Login/Logout based on auth state
- Add is_authenticated field to all page templates
- Hide create/update/delete UI controls when unauthenticated
- Session tokens stored in secure HttpOnly cookies with SameSite=Lax
- Password verification uses constant-time comparison via Argon2

Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:47 +00:00
copilot-swe-agent[bot]
d50ea10012
fix(test): improve CLI test infrastructure with proper JSON parsing and token extraction
- Fix create_token helper to properly parse interactive output and extract token
- Update roasters_cli tests to parse JSON output and verify roaster data
- Update roasts_cli tests to parse JSON output and verify roast data
- Use BREWLOG_SERVER environment variable instead of --server flag
- Add proper assertions on JSON structure and content

Note: CLI tests currently fail due to server startup timing issues when
running multiple tests concurrently. Server tests (42 tests) all pass.
CLI test infrastructure is functional but needs serial execution or
better port management.

Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:43 +00:00
copilot-swe-agent[bot]
94c2403370
test(cli): add initial CLI test infrastructure
- Create tests/cli directory with test modules for roasters, roasts, and tokens
- Add helper functions for spawning test servers and running CLI commands
- Add portpicker and tempfile dev dependencies for CLI tests
- Tests demonstrate expected behavior but need CLI refinements to fully work:
  * CLI commands need --server flag or better env variable handling
  * create-token needs non-interactive mode for testing
  * Commands should support --json output format for easier parsing

Infrastructure is ready for completion once CLI improvements are made

Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:14 +00:00
copilot-swe-agent[bot]
0b9cfefce5
feat(cli): add token management commands
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:09 +00:00
copilot-swe-agent[bot]
d96f2c27e0
feat(auth): add password hashing, token generation, and admin bootstrap
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-25 16:28:03 +00:00
copilot-swe-agent[bot]
52301e64b9
test: add wiremock dependency and test infrastructure
Co-authored-by: jnsgruk <668505+jnsgruk@users.noreply.github.com>
2025-11-24 17:58:21 +00:00
Jon Seager
3241f3c961
feat: bootstrap brewlog platform 2025-11-24 11:44:12 +00:00