How abel-ajish/filesend works
Local Share is a single Next.js 14 App Router web app deployed on Vercel that provides temporary file sharing with two transfer paths:
1. P2P path (preferred): Browser ↔ Browser over WebRTC (same network / QR mode), using STUN/TURN infrastructure as needed.
2. Server fallback path: Browser ↔ Next.js API routes ↔ Appwrite Cloud Storage (public files), with auto-delete ~60s.
• UI + WebRTC logic in the browser
• thin server-side API routes (Next.js serverless functions)
• Appwrite as the persistent component (short-lived storage)
• optional external STUN/TURN dependencies for WebRTC
Frontend (Browser)
• app/page.tsx – main workflow page (upload/send/receive UI)
• app/layout.tsx, app/globals.css – shell + styling
• components/file-share.tsx – core UI component(s) for sharing flow
• lib/p2p.ts – WebRTC / peer connection / data channel logic (P2P mode)
• QR code mode is a UI feature (likely in components/page logic) that influences how peers connect (share SDP/offer info or a room/code).
Backend (Next.js API routes running on Vercel)
• app/api/files/route.ts – POST /api/files (upload entrypoint)
• app/api/files/[filename]/route.ts – DELETE /api/files/:filename (explicit delete / lifecycle cleanup)
• app/api/code/[code]/route.ts – GET /api/code/:code (resolve a 6-char code to file metadata / download info)
These are serverless in Vercel terms (stateless, invoked per request).
External Storage / Backend Service
• lib/appwrite.ts – Appwrite SDK wrapper / client configuration for API routes
• Appwrite Cloud: bucket files (per README), using API key with files.read, files.write.
Configuration/Deployment
• .env.example – required runtime config (Appwrite endpoint, project, key, bucket)
• next.config.mjs, tsconfig.json, etc.
• Vercel is the runtime target (README + badge).
Sender Browser (Next.js client)
• Upload UI
• WebRTC sender
• QR generator (or code display)
Receiver Browser (Next.js client)
• Download UI
• WebRTC receiver
• QR scanner (if supported)
Next.js on Vercel
• Static/SSR hosting for the UI
• API Route: POST /api/files
• API Route: GET /api/code/:code
• API Route: DELETE /api/files/:filename
Appwrite Cloud
• Storage bucket files
• File object (filename/id, public URL, metadata/code)
WebRTC Infrastructure (External)
• STUN (and TURN if used/needed)
• This is critical to show because it explains “P2P works sometimes, falls back otherwise”.
Deletion
• Either scheduled client-side timer triggers DELETE /api/files/:filename
• Or server-side logic triggers deletion after ~60s (if implemented in API route)
Important architectural patterns present in this repo
• App Router + Route Handlers: backend logic lives under app/api/**/route.ts (serverless endpoints).
• Thin backend / externalized storage: no custom DB; Appwrite is the persistence layer.
• Dual-path transport: WebRTC P2P first, fallback to Appwrite-hosted download.
• Stateless compute: Vercel serverless functions; do not assume in-memory state for code mapping (if code lookup exists, it must be derivable from storage metadata or deterministic naming).
What to label explicitly (to make it “accurate”, not generic)
Labels because they’re core requirements from README:
• “No login / no accounts” (security/trust note)
• “Auto-delete ~60 seconds” near lifecycle mechanism
• “6-character code” between “upload result” and “receiver lookup”
Quick checklist of “components to separate as much as possible”
To follow “don’t overthink it; separate into many components”, include these as distinct nodes:
• Upload UI
• Code generation/display
• QR encode/decode
• WebRTC sender
• WebRTC receiver
• P2P signaling exchange (QR/manual)
• Fallback upload API route
• Code resolution API route
• Delete API route
• Appwrite bucket
• Appwrite public download endpoint
• STUN and TURN (even if TURN is “optional/unknown”)