How yadav036/bethere works
Project Type and Purpose
• Snap Events is a full-stack, real-time event coordination web application.
• Frontend and backend are both implemented with Next.js (React + API routes).
• Purpose: Allow users to authenticate, create/join events, share live locations, compute ETAs.
File Structure Analysis
• Top-level “app” directory follows Next.js 13+ App Router:
• app/api – serverless API endpoints (auth, events, invites, places, users)
• app/(routes) – React server components/pages (home, login, signup, event pages)
• app/layout.tsx, globals.css – top-level layout and styling
• “components” – reusable UI components organized by domain (auth, event, invites, ui library).
• “hooks” – custom React hooks (location reporter, toast, mobile detection).
• “lib” – shared utilities (API client, auth handlers, JWT, Prisma client, Google Maps integration).
• “prisma” – database schema and migrations.
• Configuration files: next.config.mjs, tsconfig.json, postcss.config.mjs.
• Styling: Tailwind CSS with shadcn/ui components in components/ui and styles/globals.css.
README Insights
• Architecture: frontend + backend via Next.js API routes.
• Database: Prisma ORM (PostgreSQL or equivalent).
• Authentication: JWT stored in cookies or local storage.
• External service: Google Maps Directions API for ETA and geocoding.
• Live location: browser Geolocation API with polling via useLocationReporter hook.
Diagramming the Architecture
a. Main Components
• Next.js Frontend (React pages + UI components)
• Next.js Backend (API route handlers)
• Database (PostgreSQL via Prisma ORM)
• External Services:
– Google Maps API (Directions, Geocoding, Autocomplete)
• Browser:
– Geolocation API
• State Management:
– React Hooks, SWR or built-in fetch caching
b. Relationships and Interactions
• User browser ↔ Next.js Frontend (HTTP GET pages, Web UI interactions)
• Frontend ↔ API routes (HTTP REST calls for auth, events, invites, location updates)
• API routes ↔ Database (Prisma client CRUD operations)
• API routes ↔ Google Maps API (ETA calculation, place autocomplete, geocoding)
• useLocationReporter hook in browser sends POST location every 10s → API → DB
c. Architectural Patterns
• Server-Side Rendering / Server Components (Next.js App Router)
• Client-Side Data Fetching (fetch hooks, React state)
• RESTful API Endpoints (under app/api)
• ORM Layer (Prisma) separating data access
• Layered separation: UI → Business Logic (API routes / lib) → Data Layer (Prisma)
d. Key Technologies
• Next.js (frontend SSR/SSG, API routes)
• React + TypeScript
• Tailwind CSS + shadcn/ui
• Prisma ORM + PostgreSQL
• JWT for authentication (lib/jwt.ts, lib/auth.ts)
• Browser Geolocation API
• Google Maps Directions & Places API