Skip to content

Refactor map load: bundled map-data and deferred interactions#41

Draft
eduardoperetto wants to merge 33 commits into
mainfrom
refactor/performatic-load
Draft

Refactor map load: bundled map-data and deferred interactions#41
eduardoperetto wants to merge 33 commits into
mainfrom
refactor/performatic-load

Conversation

@eduardoperetto

Copy link
Copy Markdown
Collaborator

Summary

  • Replace nine parallel map API calls with a single cached GET /map-data/ bundle: server-side tag graph, inherited locations, popup DTOs, and inline KML GeoJSON (administration/map_data/).
  • Frontend loads via MapDataService with [MapLoad] profiling; measured ~60% faster interactive load at 10k and 20k (warm cache). See docs/benchmarks/.
  • Phase 2: defer Leaflet interaction setup (popups, tooltips, hover, link/KML/cluster tooltips) to a background enrich pass after static markers and link geometry are painted—no loading overlay; interactions simply do nothing until enrich completes.
  • Add benchmark scripts (scripts/generate_example_map_data.py, scripts/load_example_map_data.sh) and documentation under docs/benchmarks/.

This branch also includes earlier work merged into the same line of development: multi-tenant Django admin/clients, CSV/XLSX import pipeline, password-reset flow, and nginx/env base-URL configuration.

Map load architecture

Layer Before After
Data fetch forkJoin /map-data/ + MapDataService.hydrate
Server Per-endpoint queries build_map_data() + cache.get_or_set + signal invalidation
Interactive path Markers + popups + links in one sync block Marker/link shellsinteractive.total
Full path Same as interactive Batched enrichInteractionsfull.total

Benchmark highlights (example tenant, warm cache)

Scale Before interactive.total After map-data Notes
10k 1054 ms 412 ms ~61% reduction
20k 2810 ms 1121 ms ~60% reduction; DOM still ~65% of post-refactor cost

Deferred enrich is expected to lower interactive.total further; compare interactive.total vs full.total with localStorage.mapProfile = '1'.

Test plan

  • python manage.py test administration.tests.test_map_data
  • cd map-frontend && npm run test:map-behavior
  • Load example.localhost at 10k/20k; confirm pins and links visible before enrich; popups/tooltips work after enrich
  • Tag hide/show and overlay expand buttons (opp-open-button) after enrich completes
  • Menu/filter changes after map is ready (markers + links refresh)
  • Cache invalidation: edit a tag/location in admin, reload map, confirm bundle updates
  • Smoke: CSV/XLSX import and multi-tenant admin login (regression on co-located changes)

Made with Cursor

leonardolauryel and others added 30 commits April 8, 2025 18:12
* Fix: Adding validation to domain names

* Changing string to English

* fix: sync owner changes and prevent inconsistencies in multitenancy

- Sync many-to-many relationship (clients_tenantuser_tenants) when client owner changes
- Sync permissions in tenant schema (permissions_usertenantpermissions) when owner changes
- Prevent removing tenants from users who own them with form validation

* fix: prevent error when creating new tenant users"

* fix: sync tenant permissions on user creation and removal

* refactor: apply clean code principles to multitenancy admin
eduardoperetto and others added 3 commits June 4, 2026 18:39
Document baseline vs map-data bundle timings at 10k/20k and the
deferred interaction enrich phase for future performance comparisons.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants