How arpitgami/sessionhq works
Project Type and Purpose
• This is a full-stack Next.js application for booking and running live expert sessions.
• The “app” folder under src contains both the React pages (UI) and API routes (Next.js serverless functions).
• A custom Node server (server.js) and Socket.io + PeerJS hooks enable real-time video/audio chat.
• Stripe is used for payments; a database (configured in src/dbconfig and models in src/models) persists users, experts, meetings, availability, etc.
File Structure
• src/app – Next.js App Router pages and layouts.
– /(info-page) and its subfolders: marketing/info pages (landing, explore, expert profiles, meetings).
– /(after-payment): success/failed pages.
– post-sign-in, userform, room/[roomid] (live session UI).
• src/app/api – Next.js API routes (expert data, meeting control, user payment, Stripe webhook).
• src/component – Reusable UI components (ExpertCard, Navbar, modals, room chat controls).
• src/context & src/hooks – Socket connection, WebRTC (usePeer, useMediaStream), image upload, refund initiation, guard hooks.
• src/dbconfig + src/models – DB connector and ORM/ODM models for Users, Experts, Meetings, Requests, Availability, SessionData.
• server.js – Custom Next.js server entrypoint, attaches Socket.io and handles real-time signaling.
• Config files – next.config.ts, tsconfig.json, ESLint, PostCSS.
README
• Standard create-next-app boilerplate – no custom architecture doc.
• Emphasizes development server and deployment on Vercel.
a. Main Components
– Client (Browser): React pages under src/app, WebRTC/Socket.io client in context/hooks.
– Next.js Server:
• Server-Side Rendering and API routes (src/app/api).
• Custom Express/Next server + Socket.io (server.js).
– Database: Postgres/MongoDB (via dbconfig).
– External Services:
• Stripe (payment sessions + webhooks).
• PeerJS (signaling via Socket.io).
b. Relationships & Interactions
1. User navigates to Next.js pages → SSR or client-side render.
2. UI calls Next.js API endpoints for expert data, availability, meeting creation, payments.
3. Payment flow: Next API → Stripe Checkout → Stripe Webhook → Next API → DB.
4. Meeting flow: Next API schedules meeting → DB. User enters room → Socket.io signaling handshake → WebRTC media streams.
5. Real-time chat/control via Socket.io channels managed by server.js.
c. Architectural Patterns & Principles
– Full-stack “App Router” in Next.js: co-located UI + API folders.
– Layered separation: Presentation (app/pages + components), Business (API routes + hooks), Data (models + dbconfig).
– Event-driven for payments (webhooks) and real-time (Socket.io).
– Modular React components and context for reusability.
d. Key Technologies/Frameworks
– Next.js 13+, App Router
– React + TypeScript/JSX
– Express + Socket.io (custom server)
– WebRTC (PeerJS, custom hooks)
– Stripe API
– ORM/ODM (models in src/models) + dbconfig
– Vercel deployment (optional)
Essential Architectural Elements
– Do not oversimplify: include API subdomains (expert, meeting, stripe, user).
– Explicitly show the real-time signaling (Socket.io) vs media streams (WebRTC).
– Illustrate payment flow separately from booking flow.
– Reflect the folder structure: map “src/app/experts/*” to “Expert Dashboard UI”, map “src/models” to “Database Schema”.