Fix #635: Implement Smart Location Intelligence and Geospatial Analytics #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ Key Features Implemented:
Geospatial Transaction Model: Updated
models/Transaction.js
to support GeoJSON storage. Every transaction now has a location (Point) and formattedAddress field, along with a 2dsphere index for high-speed spatial queries.
Location Intelligence Cache: Created
models/Place.js
to store and reuse geocoded location data. This prevents redundant API calls and ensures that spending at the same merchant is consistently grouped.
Proximity Search Engine: Implemented
findNear
in
services/locationService.js
, allowing users to query expenses based on their physical location (e.g., "expenses within 5km of my current position").
Spending Hotspot Clustering: Developed a custom clustering algorithm in
services/locationService.js
that groups nearby transactions into "Hotspots." This identifies physically dense spending zones (e.g., shopping malls or specific neighborhoods).
Automated Geocoding Job: Built
jobs/geocodingJob.js
for background processing. It scans historical transactions and uses the geocoding engine to backfill missing location data.
New API Suite:
GET /api/maps/nearby: Proximity searching.
GET /api/maps/hotspots: Spending density analysis.
POST /api/maps/backfill: Manual trigger for location backfilling.
closes #635