Commit graph

92 commits

Author SHA1 Message Date
4fcdc33ec0
Fix database parameters for PgBouncer compatibility
Remove PostgreSQL session-specific parameters that are not supported
by PgBouncer connection pooling. Keep only application_name parameter
which is passed through properly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 10:32:53 -05:00
c85b907ab7
Move Redis PubSub config to runtime initialization
- Remove static Redis PubSub configuration from runtime.exs
- Add dynamic pubsub_config/0 function in application.ex
- Configure PubSub adapter based on cluster_enabled and REDIS_URL at startup
- Ensures proper initialization order for distributed deployments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 10:10:55 -05:00
194ff0006f
Add Redis PubSub support for distributed clustering
Configures Phoenix.PubSub.Redis adapter when clustering is enabled
and REDIS_URL environment variable is set. This allows PubSub
messages to be shared across Elixir nodes in a distributed
deployment, enabling proper real-time updates in multi-node setups.

- Add phoenix_pubsub_redis dependency (~> 3.0)
- Configure Redis adapter in runtime.exs for production
- Set pool size to 10 for better performance
- Include node name in Redis configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-26 10:05:41 -05:00
f7cf0d0d47
Implement advanced JavaScript optimization with conditional loading
- Created minimal, tree-shaken vendor bundles:
  * Core bundle (3KB): Always loaded utilities and theme management
  * Map bundle (255KB): Leaflet + plugins, loaded only for map pages
  * Chart bundle (205KB): Chart.js, loaded only for chart pages
  * Date adapter (50KB): Chart.js time scale support
- Total optimized size: 513KB JS + 12KB CSS (was 547KB + 17KB)
- Implemented conditional loading via VendorLoader utility
- Bundle loading triggered by LiveView hooks when needed
- Fixed Chart.js date adapter dependency loading
- Eliminated unused JavaScript from being sent to browsers
- Created separate esbuild configs for each optimized bundle

Performance improvements:
- Map pages: Core + Map bundles = 258KB (47% of original)
- Chart pages: Core + Chart + Adapter = 258KB (47% of original)
- Other pages: Core bundle only = 3KB (0.5% of original)
- Reduced initial page load by 94% for non-map/chart pages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 14:05:18 -05:00
f4bc55ed39
Optimize JavaScript delivery by creating local vendor bundles
- Download external libraries locally to reduce CDN dependencies
- Create combined vendor bundles for JavaScript and CSS
- Replace CDN script tags with local bundles in layout template
- Add build scripts for vendor bundle creation and optimization
- Configure esbuild to process vendor bundles separately
- Total bundle size: ~512KB JS + 17KB CSS (optimized)

Benefits:
- Reduced external requests and CDN dependencies
- Better caching control and reliability
- Eliminated CORS and SRI integrity issues
- Faster page loads with bundled resources

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 13:56:12 -05:00
46ece7aa38
Add Cloudflare Insights domain to allowed origins
Add https://static.cloudflareinsights.com to check_origin list
to resolve CORS errors from Cloudflare Web Analytics beacon.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 13:36:16 -05:00
777acc2700
Use DNSSRV strategy for StatefulSet clustering
Switch to Kubernetes.DNSSRV strategy which is specifically designed
for StatefulSets and uses DNS SRV records for node discovery.

This strategy:
- Doesn't require Kubernetes API permissions (no RBAC needed)
- Automatically filters out the current node
- Works with StatefulSet stable DNS names
- Uses SRV records from the headless service

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 12:37:37 -05:00
93397badbd
Switch to Kubernetes strategy with hostname mode for StatefulSet
Based on libcluster documentation, StatefulSets should use the standard
Kubernetes strategy with mode: :hostname, not the DNS strategy.

This properly discovers pods using their stable hostnames and filters
out the current node from connection attempts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 12:35:27 -05:00
620144164f
Switch to Kubernetes.DNS strategy for StatefulSet clustering
The DNSPoll strategy was attempting to connect to IPs instead of DNS names.
Kubernetes.DNS strategy is specifically designed for StatefulSet deployments
and will properly discover pods using their stable DNS names.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 12:23:49 -05:00
16e675745f
Use DNSPoll strategy for Kubernetes clustering 2025-07-25 12:05:12 -05:00
94fad09901
Use Gossip strategy for Kubernetes clustering 2025-07-25 11:53:01 -05:00
187a607563
Fix Kubernetes node naming for distributed Erlang clustering 2025-07-25 11:47:37 -05:00
4804bd16be
Add distributed Erlang clustering for single APRS-IS connection
Implement leader election to ensure only one APRS-IS connection across
multiple Kubernetes replicas. This prevents duplicate packet processing
and respects APRS-IS usage policies.

Key changes:
- Add leader election using :global registry
- Create connection manager for dynamic APRS-IS management
- Implement packet distribution from leader to all nodes
- Add Kubernetes headless service for node discovery
- Configure DNS-based clustering with libcluster
- Update deployment to support 3 replicas with clustering

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 10:30:29 -05:00
ce5724973c
Add 10.0.19.221 to allowed origins
Allow HTTP connections from internal IP 10.0.19.221 for k3s cluster access

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 19:51:58 -05:00
c52adc8a9e
Fix Phoenix check_origin configuration and add kubectl docs
- Replace invalid wildcard domains (*.aprs.me) with explicit origins
- Phoenix doesn't support wildcard syntax in check_origin
- Added specific domains for aprs.me, sentry.io, and openstreetmap.org
- Updated CLAUDE.md with kubectl commands for debugging k3s deployment

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 19:40:15 -05:00
992f0f6483
csp change 2025-07-24 11:40:44 -05:00
ae8c74afbe
try vector tiles 2025-07-24 10:54:31 -05:00
63a87f3be1
Fix Docker build JavaScript import errors with vendor bundle
Fixed the esbuild errors during Docker build where npm packages couldn't
be resolved. The issue was caused by node_modules being excluded from
the Docker build context in .dockerignore.

Implemented a proper vendor bundle strategy following Phoenix 1.7+ patterns:

- Created vendor.js that bundles all npm dependencies (Leaflet, Chart.js,
  topbar) and their CSS files into a single pre-built bundle
- Added vendor esbuild profile in config.exs with proper CSS/image loaders
- Updated mix.exs to build vendor bundle before app bundle in assets.deploy
- Modified JavaScript imports to use globally loaded libraries from vendor
  bundle instead of importing from node_modules
- Added vendor.js script tag to root.html.heex before app.js

This approach avoids Docker build failures by pre-bundling all vendor
dependencies, eliminating the need for node_modules during production builds.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 12:32:39 -05:00
53ce452cdf
Fix Docker build CSS import errors
Moved CSS imports from Tailwind config to JavaScript to let ESBuild handle them.
This fixes the Docker build error where Tailwind couldn't resolve node_modules paths.

- Removed CSS @import statements from app.css
- Added CSS imports to map.ts where Leaflet is used
- Configured ESBuild to handle CSS and image files
- Added missing topbar package to package.json
- Updated both dev and prod ESBuild configs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 11:59:04 -05:00
9b034cd211
vendor all js 2025-07-21 11:09:14 -05:00
c932abb434
Fix esbuild vendor bundle error by marking chart.js as external
The Docker build was failing because the Chart.js date adapter was trying
to require("chart.js") but esbuild couldn't resolve it since Chart.js is
loaded as a UMD file, not a CommonJS module.

Added --external:chart.js to the vendor esbuild configuration to tell
esbuild not to try bundling chart.js when it encounters require("chart.js")
in the date adapter. This is correct because Chart.js is already loaded
globally from the UMD file.

This fixes the "Could not resolve 'chart.js'" error during production builds.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 10:11:26 -05:00
299602da65
format 2025-07-21 09:52:59 -05:00
7dc6c616a2
Bundle all vendor JavaScript files locally instead of loading from CDNs
This change eliminates all external CDN dependencies by bundling JavaScript
libraries locally using esbuild. All vendor files are now served from the
application's own assets, improving reliability and privacy.

Changes:
- Created assets/js/vendor.js to bundle all external libraries
- Added vendor bundle configuration to esbuild in config files
- Updated all templates to use local vendor.js instead of CDN scripts
- Created download-vendor-files.sh script to fetch vendor libraries
- Added vendor files to .gitignore (they're downloaded during setup)
- Updated CSS imports to include vendor stylesheets
- Added vendor build step to assets.deploy mix task

Bundled libraries:
- Leaflet 1.9.4 (mapping library)
- Leaflet.heat 0.2.0 (heatmap plugin)
- Leaflet.markercluster 1.5.3 (marker clustering)
- OverlappingMarkerSpiderfier 0.2.6 (overlapping marker handling)
- Chart.js 4.5.0 (charting library)
- chartjs-adapter-date-fns 3.0.0 (date adapter for Chart.js)

All functionality tested and working correctly with local bundles.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 09:52:39 -05:00
a0c2970b42
Revert to smaller batch sizes to reduce garbage collection frequency
Reduced batch processing parameters to prevent excessive GC:
- Reduced batch_size from 500 to 100 packets
- Adjusted batch_timeout from 2000ms to 1000ms for faster processing
- Reduced max_demand from 750 to 300 to match smaller batches
- Updated hardcoded fallback from 500 to 100 in packet_consumer.ex
- Changed minor GC trigger from 500 to 100 packets to match batch size

These smaller batch sizes were proven to work well in production and
should significantly reduce the frequency of garbage collection while
maintaining good performance.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 17:46:04 -05:00
ad2d9c14cf
Fix packet buffer overflow with parallel consumer pool
- Create PacketConsumerPool to run 3 parallel consumers (configurable)
- Increase max_demand from 250 to 750 total (250 per consumer)
- Fix timer management to properly cancel/restart on batch processing
- Configure proper GenStage subscriptions with backpressure control
- Allow unnamed consumers for pool usage

This 3x increase in processing capacity prevents the "Packet buffer full"
warnings by ensuring consumers can keep up with incoming packet rate.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 14:49:52 -05:00
234fc2010f
Implement critical performance optimizations and error handling
This commit introduces several major performance improvements and adds
robust error handling for malformed HTTP requests:

Performance Optimizations:
- Add database migration with BRIN indexes for time-series data and partial
  indexes for recent queries, significantly improving query performance
- Create global StreamingPacketsPubSub system for real-time packet distribution
  with geographic bounds filtering using ETS for fast lookups
- Refactor PacketConsumer to use Stream module for memory-efficient processing,
  preventing memory accumulation during batch operations
- Implement dedicated BroadcastTaskSupervisor pool for async broadcast operations,
  preventing GenServer blocking on I/O
- Increase database connection pool from 25 to 45 (production) and 15 to 30 (dev)
  for better concurrency support

Error Handling:
- Add SentryFilter to prevent Bandit.HTTPError from missing Host headers from
  cluttering Sentry (common with bots/scanners)
- Configure custom 400 Bad Request error handling
- Filter out common bot/scanner paths from error reporting

All changes include comprehensive test coverage following TDD practices.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 18:19:49 -05:00
1da12cf665
Remove debug console.log statements from JavaScript files
- Removed all console.log debugging statements from app.js (theme changes, chart rendering)
- Removed all console.log statements from map.ts (map initialization, data processing)
- Removed all console.debug statements from map_helpers.ts
- Removed all console.debug statements from map_fixes.ts
- Kept essential console.error and console.warn statements for error handling
- Reduced bundle size by ~1.4kb

This cleanup removes unnecessary debug output while maintaining error reporting
for production debugging via console.error and Sentry.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 15:37:05 -05:00
1c7a1754ee
add sentry-cdn to cors 2025-07-18 15:23:58 -05:00
4af0f4a421
Fix JavaScript context binding issues in map component
- Fix "this.__view is undefined" error when calling pushEvent in event handlers
- Bind pushEvent context properly in all marker click and hover handlers
- Replace undefined sendBoundsToServer calls with saveMapState
- Ensure all event handlers check for pushEvent availability and type
- Use .bind(self) to preserve LiveView hook context in callbacks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 15:05:15 -05:00
4b159ba0b7
cleanup 2025-07-18 14:44:52 -05:00
8d5bfe127e
add email 2025-07-18 10:15:09 -05:00
53c88d2262
postgres optimization 2025-07-15 09:06:40 -05:00
0298c8ec91
Revert all packet processing optimizations to fix buffer overflow
- Restored original PacketConsumer implementation from before optimizations
- Reverted to fixed batch size of 50 packets (original value)
- Removed SystemMonitor and InsertOptimizer from application startup
- Restored original config with buffer size 1000 and batch timeout 1000ms
- Removed all dynamic batch sizing and optimization logic

The recent performance optimizations were causing packet buffer overflows
because the dynamic batch sizing was actually slowing down processing.
Reverting to the simpler, working implementation that processes packets
consistently without buffer overflows.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-15 08:44:26 -05:00
f1d16d656b
Fix packet buffer overflow by reverting dynamic batch sizing
- Increased packet buffer size from 1,000 to 10,000 to handle traffic spikes
- Removed InsertOptimizer dynamic batch sizing that was slowing processing
- Reverted to fixed batch size of 200 for consistent performance
- Simplified insert options to use static configuration
- Added telemetry metrics for buffer overflow and utilization monitoring
- Fixed unused variable warning in packet_consumer.ex

The root cause was the recent performance optimizations that introduced
dynamic batch sizing, which actually degraded performance and caused
the producer buffer to overflow when the consumer couldn't keep up.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-15 08:25:02 -05:00
389ce8edeb
cleanup worker tweaks 2025-07-14 12:31:47 -05:00
f26c367b6c
allow reduced historical packet age 2025-07-14 12:14:12 -05:00
062489f5ae
staging fix 2025-07-11 13:19:24 -05:00
f5e0f33ac2
fix geolocation hopefully 2025-07-10 17:12:49 -05:00
38f240b3eb
fix info/neighbor page loading 2025-07-10 14:43:00 -05:00
176e90186d
more ci tweaks 2025-07-09 17:04:33 -05:00
9053f0840a
add more i18n testing and fix error page and dashboard 2025-07-08 12:16:00 -05:00
711d92ebb6
performance improvements 2025-07-08 10:03:52 -05:00
79fa7713ab
release tweak 2025-07-07 17:12:42 -05:00
5a6a782a03
release tweak 2025-07-07 17:09:46 -05:00
06efe1834b
release tweak 2025-07-07 17:02:17 -05:00
0bee0228b0
fix app name 2025-07-07 16:46:48 -05:00
9a6f649157
add clustering 2025-07-07 16:41:14 -05:00
b2f9352091
parser hash fix 2025-07-07 13:02:49 -05:00
6749f41137
built in error tracking 2025-07-07 11:06:22 -05:00
2543617f16
add sentry 2025-07-07 09:52:02 -05:00