No description
Find a file
goose bd1b7c2925 fix(backend): P1 — handler unwrap cleanup + rewrite integration tests
P1 items #6 (JWT expiry) and #7 (refresh/logout routes) were already delivered
in the P0 pass. This commit covers the two remaining P1 items:

#9 — Replace dangerous handler-level .unwrap() calls (13 sites):
* handlers/users.rs: 5x ObjectId::parse_str(&claims.sub).unwrap() in
  get_profile/update_profile/delete_account/get_settings/update_settings now
  return 401 on a malformed subject instead of panicking (matches the guard
  already used in change_password).
* handlers/auth.rs: the login user.id.ok_or_else(..).unwrap() was a latent
  panic bug — the crafted 500 response was discarded. Now returns the clean
  500 via match.
* handlers/health_stats.rs: 6x state.health_stats_repo.as_ref().unwrap() now
  return 503 SERVICE_UNAVAILABLE if the feature is unconfigured, mirroring the
  interactions.rs pattern.
* Left untouched: 14 test/boot-time unwraps and 7 infallible ones (header
  literal parsing, infallible TryFrom). The 3 borderline model-layer
  inserted_id unwraps are flagged for later.

#8 — Rewrite the broken integration tests against a real test DB:
* Split the crate into bin+lib: new src/lib.rs + src/app.rs (build_app), with
  main.rs now a thin entrypoint. Tests build the exact production router
  in-process instead of hitting a live server on a hardcoded port.
* tests/common/mod.rs: helpers that connect to Mongo, build a fresh AppState
  against a unique per-process DB (normogen_test_<uuid>), and tear it down.
  A 1s connectivity probe makes tests skip gracefully when Mongo is absent, so
  'cargo test' stays green without Mongo — CI runs them for real.
* Rewrote tests/auth_tests.rs and tests/medication_tests.rs with the ACTUAL
  API contracts (POST /register {email,username,password}; response has token
  + refresh_token, not access_token; register returns 201). Covers register,
  login (right/wrong password), auth enforcement, refresh rotation + reuse
  detection, logout, and password-change invalidating old tokens.
* Added a 'test' CI job with a mongo:7 service container running
  cargo test --all-targets.
* Synced scripts/test-ci-locally.sh: fixed the stale -D warnings (CI is
  non-strict) and the reverted 'Docker Buildx' claims; added unit + integration
  test steps with a Mongo skip note.

Verified: cargo fmt --check clean, build + clippy --all-targets clean.
Full 'cargo test': 18 unit + 9 auth + 4 medication = 31 passed, 0 failed
(integration tests skip cleanly when MongoDB is unreachable).
2026-06-27 14:26:39 -03:00
.forgejo/workflows fix(backend): P1 — handler unwrap cleanup + rewrite integration tests 2026-06-27 14:26:39 -03:00
backend fix(backend): P1 — handler unwrap cleanup + rewrite integration tests 2026-06-27 14:26:39 -03:00
docs feat(ci): add format check, PR validation, and Docker buildx 2026-03-17 10:44:42 -03:00
scripts fix(backend): P1 — handler unwrap cleanup + rewrite integration tests 2026-06-27 14:26:39 -03:00
thoughts chore: Clean up temporary docs and start Phase 2.4 2026-02-15 16:33:36 -03:00
web/normogen-web docs(ai): reorganize documentation and update product docs 2026-03-09 11:04:44 -03:00
.cursorrules docs(ai): reorganize documentation and update product docs 2026-03-09 11:04:44 -03:00
.gitignore chore: Update .gitignore to exclude tmp and log files 2026-02-20 13:13:29 -03:00
.gooserules docs(ai): reorganize documentation and update product docs 2026-03-09 11:04:44 -03:00
CI-CD-COMPLETION-REPORT.md fix(ci): make clippy non-strict and fix domain spelling 2026-03-17 23:00:08 -03:00
CI-CD-FINAL-SOLUTION.md docs: add comprehensive CI/CD final solution documentation 2026-03-18 23:27:48 -03:00
CI-CD-IMPLEMENTATION-SUMMARY.md fix(ci): make clippy non-strict and fix domain spelling 2026-03-17 23:00:08 -03:00
CI-CD-STATUS-REPORT.md fix(ci): make clippy non-strict and fix domain spelling 2026-03-17 23:00:08 -03:00
README.md docs(ai): reorganize documentation and update product docs 2026-03-09 11:04:44 -03:00

Normogen

Normogen (Mapudungun for "Balanced Life") is an open-source health data platform for private, secure health data management.

📚 Documentation

All project documentation has been organized into the docs/ directory:

🚀 Quick Start

# Clone repository
git clone <forgejo-url> normogen
cd normogen/backend

# Setup configuration
cp .env.example .env
# Edit .env with your values

# Run with Docker Compose
docker compose up -d

# Check status
curl http://localhost:6800/health

📊 Current Status

  • Phase: 2.8 (Planning - Drug Interactions & Advanced Features)
  • Backend: Rust + Axum + MongoDB (~91% complete)
  • Frontend: React + TypeScript (~10% complete)
  • Deployment: Docker on Solaria

🗂️ Documentation Structure

docs/
├── product/          # Product definition, features, roadmap
├── implementation/   # Phase plans, specs, progress reports
├── testing/          # Test scripts and results
├── deployment/       # Deployment guides and scripts
├── development/      # Git workflow, CI/CD, development tools
└── archive/          # Historical documentation

📖 Full Documentation

See the Documentation Index for complete project documentation.


Last Updated: 2026-03-09