How marioperezhurtado/boble2 works
Core Components
• Frontend Client: Built with Svelte/SvelteKit and TailwindCSS. This layer includes all UI components (the “ui” and “routes” folders) and user interaction elements.
• API Layer (tRPC): The communication bridge between the frontend and backend, defined in the “src/lib/trpc” folder. This layer handles routes for authentication, chat, contacts, messages, and more.
• Backend Server: Powered by SvelteKit (with a custom Node server defined in server.js) that orchestrates API requests, WebSocket connections, and server-side logic.
• WebSocket Service: Implemented using Socket.io (located in “src/lib/socket”), this is responsible for providing real-time, bidirectional communication.
• Database Layer: PostgreSQL is used as the primary data store with DrizzleORM handling the data models and queries (in “src/lib/db”). The schema, migrations, and specific query functions (for chats, contacts, messages, etc.) are clearly separated.
• Authentication & Encryption: Authentication is implemented using Lucia (in “src/lib/auth”), and end-to-end encryption is handled via the Web Crypto API (see “src/lib/utils/encryption.ts”) with ECDH and AES-GCM specifics.
• Email and File Upload Modules: Email functionality is built using Nodemailer and Svelte-email (in “src/lib/email”), while file uploads (using Amazon S3 SDK) reside in “src/lib/file-upload”, with a fake S3 server provided in the “s3” directory for development.
• External Services: These include SendGrid for SMTP, Giphy for media support, and AWS S3 (or a development S3 server) for file storage.
Relationships and Interactions
• The Frontend interacts with the API Layer via tRPC procedures which then call back-end functions.
• For persistent data, the Backend communicates with the PostgreSQL database using DrizzleORM.
• Authentication flows (account creation, login, email verifications, password resets), as well as encryption key generation and crypto routines, tie into both the API Layer and a secure local storage mechanism on the client side.
• File uploads and email triggers represent integrations with external APIs/services, and should be clearly connected to the backend.
Architectural Patterns and Design Principles
• Modularization: Different aspects of the application are separated into dedicated directories (e.g., “auth”, “db”, “socket”, “email”, “file-upload”).
• API Layer Separation: tRPC router processes make the backend procedures strongly typed and ensure clear boundaries between client and server logic.
• Real-Time Communication: The architecture supports WebSocket communication integrated into the SvelteKit custom server.
• Security Constructs: Notice the end-to-end encryption strategy that uses the Diffie-Hellman key exchange (ECDH) and AES-GCM encryption methodology.
Specific Technologies & Frameworks
• Svelte/SvelteKit, TailwindCSS (Frontend)
• tRPC, Node.js custom server (Backend)
• Socket.io (WebSocket)
• PostgreSQL and DrizzleORM (Database)
• Lucia (Authentication)
• Nodemailer and Svelte-email (Email service)
• AWS S3 SDK (File storage)
• External API integrations like SendGrid and Giphy.
Specific Elements
• Labeled components for each primary module: Frontend, API/tRPC, Backend Server, WebSocket Service, Database, Authentication, Email Service, File Upload Service, External APIs.
• Blue for frontend components,
• Green for backend processes,
• Gray for the database,
• Orange for external services, and
• Labels to indicate critical frameworks and technologies (Svelte, tRPC, PostgreSQL, Socket.io, etc.).
Putting It All Together
• Lastly, include testing and configuration aspects (such as the testing folder, and relevant config files) as supporting infrastructure elements.