How ananth-swamy/discord-storage works
Project type and purpose
• This is a full-stack web application ("Discord Storage") that lets users upload/download files via a Discord bot, using PocketBase as a metadata store.
• Key indicators:
• frontend/ contains a React app (Vite, Tailwind).
• backend/ holds Node.js scripts (commands.js, index.js) and env config.
• pocketbase/ folder runs a local PocketBase server for persistent storage.
• README describes steps to wire up Discord, run PocketBase, start backend, then frontend.
File structure
• Top-level directories:
• frontend – React components, Vite config, styles.
• backend – Node.js bot commands and Express/Koa HTTP server (likely in index.js).
• pocketbase – embedded Go-based database server with migrations.
• preview – static screenshot for documentation.
• Patterns: Simple two-tier service: presentation (React) → application (Node.js) → data (PocketBase + Discord API).
Extract architecture details from the README
• The README calls out three runtime processes: PocketBase server, backend Node.js (bot + API), and frontend dev server.
• External dependency: Discord Developer Bot (REST/WebSocket API) used by backend.
• Data flows:
• User uploads file in browser → frontend POST to backend → backend splits chunks and stores as Discord messages + metadata in PocketBase.
• User requests file → backend re-assembles chunks from Discord and returns to frontend.
Main components & their interactions
a. Frontend (React/Vite)
• Serves UI for file upload/download.
• Calls backend HTTP endpoints (e.g., /upload, /download).
b. Backend (Node.js)
• HTTP API (Express or similar) exposed on localhost (default port from index.js).
• Discord Bot client (via commands.js) that:
• Listens for file-storage commands.
• Uploads file chunks to a Discord channel.
• Interacts with PocketBase SDK to store/retrieve file metadata (chunk IDs, order).
c. PocketBase (embedded Go service)
• Stores metadata collections (“files”, chunk mapping).
• Exposes its own REST API on http://127.0.0.1:8090/_/.
d. External service – Discord API
• Bot uses Discord REST/WebSocket to store and fetch message attachments as file chunks.
Key architectural patterns and design principles
• Three-tier architecture: Presentation, Application, Data.
• Separation of concerns:
• Frontend focuses solely on UI and HTTP integration.
• Backend encapsulates business logic: chunking, Discord bot commands, metadata orchestration.
• PocketBase is pure storage for metadata, not file blobs.
• Extensibility: You could swap PocketBase for another DB or swap Discord for any file-hosting API by abstracting the storage adapter in the backend.
• Three running processes (containers or local services):
• pocketbase:8090
• backend:3000 (or as configured)
• frontend:5173
Final checklist
• Components: Frontend, Backend, PocketBase, Discord.
• Patterns: Three-tier separation, external service adapter.