api-tier-architecture
3-tier API architecture (Convex WebSocket, SSE, REST) for cross-platform data fetching. Platform detection, hybrid hooks, DAL layer patterns. Triggers on "API", "tier", "Convex", "REST", "SSE", "useConvexQuery", "useQuery", "withAuth", "DAL".
npx skills add majiayu000/claude-skill-registry --skill api-tier-architecture --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# API Tier Architecture Three-tier API architecture for web (real-time) and mobile (battery-optimized) platforms. ## Architecture Overview **Tier 1 (Web Desktop):** Convex WebSocket - Real-time bidirectional subscription **Tier 2 (Mobile):** SSE - Server-Sent Events with polling (battery-optimized) **Tier 3 (Mobile Fallback):** REST - Standard HTTP polling All tiers authenticated via `withAuth` middleware, data accessed via DAL layer. ## Platform Detection ```typescript // From apps/web/src/lib/utils/platform.ts export function shouldUseConvex(): boolean { return getDataFetchingStrategy() === "convex"; } export function shouldUseSSE(): boolean { return getDataFetchingStrategy() === "sse"; } // Detection hierarchy: // 1. User-agent (iPhone, Android, mobile browsers) // 2. Viewport width (< 768px) // 3. Touch capability ``` **Manual override for testing:** ```typescript localStorage.setItem("blah_data_strategy", "convex"); // or "sse" or "polling" ``` ## Hybrid Hook Pattern All data hooks use hybrid pattern: Convex for web, React Query for mobile. ```typescript // From apps/web/src/lib/hooks/queries/useConversations.ts export function useConversations(options: UseConversationsOptions
- Architecture Overview
- Platform Detection
- Hybrid Hook Pattern
- DAL Layer (Data Access Layer)
- REST API Routes (Tier 3)
- SSE Routes (Tier 2)
- withAuth Middleware
- Tier Selection Criteria
- Key Files
- Common Patterns
- Avoid
What does the api-tier-architecture skill do?
3-tier API architecture (Convex WebSocket, SSE, REST) for cross-platform data fetching. Platform detection, hybrid hooks, DAL layer patterns. Triggers on "API", "tier", "Convex", "REST", "SSE", "useConvexQuery", "useQuery", "withAuth", "DAL".
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill api-tier-architecture --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
