supabase-backend
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSupabase & Backend Architecture Skill
Supabase 与后端架构技能
This skill enables the assistant to provide high-level architectural advice and implementation details for the iTaxiBcn backend.
本技能可帮助助手为iTaxiBcn后端提供高阶架构建议和实现细节。
Knowledge Areas
知识领域
1. Database Schema Optimization
1. 数据库Schema优化
- Time-Series Data: Guidelines for handling high-frequency location updates in and
registros_reten.geofence_logs - Indexing: Strategies for spatial indices (PostGIS) and temporal queries to speed up wait-time calculations.
- Materialized Views: Recommendation for replacing heavy queries on with materialized views for zone aggregations.
registros_reten
- 时序数据: 处理和
registros_reten中高频位置更新的指南。geofence_logs - 索引: 空间索引(PostGIS)和时序查询的优化策略,用于加快等待时间计算速度。
- 物化视图: 建议使用物化视图替换对的重查询,用于区域聚合统计。
registros_reten
2. Row Level Security (RLS)
2. 行级安全(RLS)
- Device-Based Access: Ensuring based security since the app currently uses device identifiers instead of full user auth (until Phase 2).
device_id - Audit Logs: Best practices for and
geofence_logssecurity.location_debug_logs
- 基于设备的访问: 确保基于的安全策略,因为当前应用在第二阶段之前使用设备标识符而非完整的用户认证体系。
device_id - 审计日志: 和
geofence_logs的安全最佳实践。location_debug_logs
3. Edge Functions (Deno/TypeScript)
3. Edge Functions(Deno/TypeScript)
- Geofencing Logic: Optimization of the Ray-casting algorithm in .
check-geofence - Performance: Minimizing startup time and memory footprint of edge functions.
- Error Handling: Robust try-catch patterns and standard JSON responses.
- 地理围栏逻辑: 优化中的光线投射算法。
check-geofence - 性能: 最小化边缘函数的启动时间和内存占用。
- 错误处理: 健壮的try-catch模式和标准JSON响应。
4. SQL Scripting
4. SQL 脚本编写
- Migrations: Following the structure.
supabase/migrations/ - Stored Procedures: Writing efficient PL/pgSQL for complex logic like score calculation on the server side.
useWhereNext
- 数据迁移: 遵循目录结构。
supabase/migrations/ - 存储过程: 编写高效的PL/pgSQL代码,在服务端实现诸如分数计算这类复杂逻辑。
useWhereNext
Guidelines for Responses
响应指南
- Always suggest Materialized Views for dashboard metrics that don't need second-by-second accuracy.
- When writing SQL, ensure idempotency (use or
CREATE OR REPLACE).IF NOT EXISTS - Prioritize PostGIS functions for distance and polygon math.
- 对于不需要秒级精度的看板指标,始终建议使用物化视图。
- 编写SQL时要确保幂等性(使用或者
CREATE OR REPLACE语法)。IF NOT EXISTS - 距离和多边形计算优先使用PostGIS函数。