Skip to content

feat(core): implement multi-tenant architecture and roadmap foundation#89

Merged
CFBruna merged 53 commits intov2/monorepo-migrationfrom
feature/clinic-foundation
Mar 4, 2026
Merged

feat(core): implement multi-tenant architecture and roadmap foundation#89
CFBruna merged 53 commits intov2/monorepo-migrationfrom
feature/clinic-foundation

Conversation

@CFBruna
Copy link
Owner

@CFBruna CFBruna commented Mar 4, 2026

What Changed

  • Reorganized the planning and execution tracking documents (ROADMAP.md, ROADMAP-EXECUTION.md, ROADMAP-CHECKLIST.md).
  • Adopted the Clinic model as the tenant isolation core across accounts, ai, core, financial, health, pets, schedule, and store models.
  • Updated ClinicContextMiddleware and TenantManager context injections to securely scope database queries based on the active session's clinic.
  • Applied extensive ruff code formatting, unused import cleanup and backend security checks (bandit/mypy).
  • Included detailed unit tests for the updated schema structure ensuring the Tenant isolating logic behaves as outlined.

Why

This implements "Phase 0 — Foundation Hardening" of the new operational roadmap. A true multi-tenant setup (rather than .env configurations) allows multiple clinics/branches to exist in identical databases without overlap or accidental bleed. This aligns with our efforts to turn PetCare into a massive enterprise-grade system.

How to Test

  • uv run pytest src/apps/core/tests/test_tenant_middleware.py: Tests if a clinic injection correctly parses incoming user or header attributes.
  • Use python manage.py shell to attempt searching across another clinic context; you should receive only your own tenant's specific assets automatically via TenantManager.
  • See the newly pushed ROADMAP-CHECKLIST.md at the project root for the master planning overview and check uv run ruff check . for pipeline sanity.

Checklist

  • Service layer architecture followed
  • No ORM in views
  • No hardcoded strings (frontend and backend)
  • Translation keys added to en, pt, es
  • Tests added or updated
  • uv run pytest passes

CFBruna added 30 commits March 2, 2026 19:38
…ess expansion, delete dialogs, and robust maps URL generator
…t/delete icons, delete confirmation, and safe destroy on backend
CFBruna added 23 commits March 3, 2026 15:54
- Audited pet_service, breed_service, clinic_service, customer_service, and audit_service
- Enforced @transaction.atomic decorator on all create, update, and delete methods
- Verified no direct ORM access in views

Closes #PHASE-0.1.1
- Replaced `(0).toFixed(2)` with safe string placeholder
- Refactored `new Date().toISOString()` into `getISODate()` and `getISODateTime()` in `utils/format.ts`
- Removed direct `Intl` instantiation from components
- Replaced hardcoded date strings in filters and API params

Closes #PHASE-0.1.2
- Wrapped backend `ValueError` exceptions in `django.utils.translation.gettext_lazy`
- Replaced frontend static placeholders ("SKU", "EAN-13", "Ex:") with `react-i18next` `t()` calls
- ROADMAP and task list completely marked for Phase 0.1.3

Closes #PHASE-0.1.3
Closes #SUB-PHASE-0.1
- Multi-tenant: Clinic model, TenantMiddleware, TenantManager
- Security: validate user-clinic ownership in middleware
- All core models now tenant-aware

BREAKING CHANGE: All models require clinic FK
Closes #PHASE-0.2
Closes #PHASE-0
@CFBruna CFBruna merged commit c429241 into v2/monorepo-migration Mar 4, 2026
1 check passed
@CFBruna CFBruna deleted the feature/clinic-foundation branch March 4, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant