How swiftsendllc/swiftsend-client works
Project type and purpose
• Full-stack React/Next.js application
• Purpose: a social/media platform (users, channels, groups, posts, reels, messaging, payments, assets, etc.)
• Uses Next.js App Router, Server Components, Client Components, Server Actions, and a set of custom API hooks
File structure
• app/ – Next.js “app” directory
– Nested dynamic routes: [username], [channelId], [groupId], [postId]
– Per-route layouts, templates, pages, and components for user profiles, channels (chat), groups, posts, reels, etc.
– server-actions/auth.server.ts – Next.js Server Actions for authentication
• components/ – Reusable UI components (navigation, form elements, modals)
• hooks/ –
– api/ – custom React hooks that wrap REST calls: useAPI, usePostAPI, useMessageAPI, usePaymentAPI, useWeatherAPI, etc.
– context/ – React Context providers: user, channel, group, socket, etc.
• config/, util/, library/ – Shared constants, helpers, validation, theme configuration
• next.config.mjs, middleware.ts – Build and routing configuration
• package.json – Dependencies: React, Next.js, Zustand or Context, Stripe JS SDK, socket.io-client, localization
README for insights
• Standard create-next-app bootstrap
• No internal database code—likely calling external microservices or serverless functions for data operations
• Deployment on Vercel implied
Main components and their interactions
A. Frontend Layer (Client & Server Components)
– React components under app/ and components/
– Next.js SSR/SSG for initial HTML (layouts, pages)
– Client Components fetch data via hooks and React Context
– UI State Management: context providers (socket, user, channel, group)
B. API Layer (Next.js Server & REST Endpoints)
– Server Actions (auth.server.ts) for mutations (login, signup, OTP verify)
– next.js API routes (if any) or external REST API
– Hooks (usePostAPI, useMessageAPI, etc.) call these endpoints
C. Real-Time Layer
– WebSocket connection via socket-context
– Channels and Groups use socket.io or similar to receive/send messages
D. Data & Persistence Layer (External)
– Database(s): user profiles, messages, posts, group metadata, payments
– Stripe service for payments/subscriptions
– Weather API for weather component
E. Infrastructure & Deployment
– Hosted on Vercel (Node.js Serverless Functions for API/Server Actions)
– Environment variables configured in next.config.mjs or util/app.config.ts
Architectural patterns and design principles
• Layered architecture: Presentation, API, Real-time, Data
• Component-based UI with clear separation of concerns
• Context-based state management for cross-cutting concerns (user, socket, channels)
• Hooks-based abstraction for all external interactions (REST, WebSocket, Stripe)
• Next.js App Router leveraging Server Components for performance