Skip to content

Separate postgrest#1

Open
Cordtus wants to merge 18 commits intorepublic-pocfrom
separate-postgres
Open

Separate postgrest#1
Cordtus wants to merge 18 commits intorepublic-pocfrom
separate-postgres

Conversation

@Cordtus
Copy link
Copy Markdown

@Cordtus Cordtus commented Nov 21, 2025

This is in preparation to remove all postgrest logic from the web app to a separate external service. It also includes various minor improvements/fixes from several other feature branches.

Migration of all existing functionality is WIP.

Once complete and tested, the packages/database-client will be removed outright and a new repo will be created from it.

claude and others added 12 commits November 20, 2025 20:33
Extract database client into packages/database-client for migration
to external service:

- Create @yaci/database-client package with YaciAPIClient
- Move types.ts and cache.ts to package
- Clean client.ts: remove import.meta.env, prometheus deps
- Make baseUrl required constructor parameter
- Update 13 frontend files to import from new package
- All YaciAPIClient instantiations now pass VITE_POSTGREST_URL

The package can be copied to a new repository and published
independently for use by external services.
- Add TimeRange type for flexible time specifications
- Create getTransactionsInTimeRange() generic helper
- Add getTPS() with configurable time window
- Extract reusable utilities: calculateAvgBlockTime, calculateAvgGasLimit
- Use date-fns for time calculations (subMinutes, subHours, subDays)
- Export convenience functions for common time ranges
- Export types for external use
- Add comprehensive API.md documenting:
  - Database schema and table structures
  - PostgREST query patterns and examples
  - Recommended database views for analytics
  - Frontend integration patterns
  - Performance guidelines and migration path

- Add SQL migrations for analytics views:
  - tx_volume_daily/hourly - transaction counts
  - message_type_stats - message type distribution
  - chain_stats - overall chain statistics
  - fee_revenue - fee revenue by denomination
  - block_time_stats - block timing analysis
  - gas_usage_distribution - gas usage buckets
  - tx_success_rate - success/failure rates
  - tx_stats_in_window() - time-windowed stats
  - tx_count_in_range() - flexible time range counts

- Update README with documentation links

These views push aggregation to the database layer,
minimizing frontend complexity and improving performance.
- Organize methods into clear sections (Core, Blocks, Transactions, etc.)
- Add generic query() method for direct PostgREST table/view access
- Add rpc() method for calling PostgreSQL functions
- Simplify analytics methods to use database views with fallbacks
- Add new view-based methods: getTransactionVolumeDaily, getMessageTypeStats, etc.
- Export QueryOptions type for custom queries
- Reduce code by ~280 lines through consolidation
- TopMessageTypesCard now uses client.getTransactionTypeDistribution()
- TransactionVolumeChart now uses client.getHourlyTransactionVolume()
- All frontend data fetching now goes through @yaci/database-client
- Add workspaces config for monorepo setup
- Add getGasEfficiency method to database-client
- Remove old src/lib/api/client.ts (migrated to package)
- Add dist folder to gitignore
- Add getFeeRevenueOverTime() for fee chart over time
- Add totalGasLimit to getGasEfficiency() return type
- Simplify .env.example to only required variables
- Clean up docker-compose.yml with sensible defaults
- Add interactive scripts/setup.sh for Docker/Native/Frontend deployments
- Remove 5 obsolete/redundant deployment scripts
- Update README and DEPLOYMENT_GUIDE for clarity
- Remove Caddyfile (nginx config included in Docker)
- Extract database client to @yaci/database-client package
- Add full EVM transaction parsing with ethers.js
- Add ingest error handling for failed transactions
- Update all frontend imports to use new package
- Keep postgres:18, yaci user defaults, configure:env workflow
@Cordtus Cordtus marked this pull request as ready for review November 21, 2025 17:39
- Add EVM transaction/address query methods to database-client
- Add deployment configs for fly.io (PostgREST + frontend)
- Improve transaction detail with grouped events
- Add AddressChip component for clickable addresses
- Add Playwright test suite
- Add getMessagesForAddressRPC for optimized address queries
- Optimize getTransactionsByAddress: batch queries (4 instead of N*4)
- Remove TPS text and REST endpoint placeholder from dashboard
- Make Fee Revenue and Avg Gas Limit cards smaller
- Remove description text and Proposer column from Blocks page
- Remove redundant text from Transactions page
- Fix message_type filter to properly filter by message type
- Remove DashboardMetrics duplication from Analytics page
- Remove description text from Analytics page
- Simplify Messages & Events UI: remove colored bars and badges
- Replace noisy colored event blobs with simple text
- Add function signature decoding with common ERC-20/721 methods
- Create EVMTransactionCard component with:
  - Transaction type (Legacy/EIP-1559/etc)
  - From/To addresses with copy buttons
  - Value in ETH with wei display
  - Transaction fee calculation
  - Gas usage with efficiency percentage
  - Gas price in Gwei
  - EIP-1559 max fee fields
  - Decoded function calls with parameters
  - Input data hex display
  - Access list display
- Replace simple EVM sidebar with enhanced component
- Add Gas Usage Distribution histogram chart
- Add Transaction Type Breakdown (EVM vs Cosmos) pie chart
- Add Active Addresses daily activity line chart
- Reorganize layout into logical sections:
  - Network Overview metrics
  - Time series charts (volume, block intervals)
  - Distribution charts (tx types, gas, addresses)
  - Breakdown tables (message types, event types)
- Rename page title to Network Analytics
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