How saurav2701/finder-a-dating-app works
Purpose and entry points
This is a monorepo for a swipe-based matching application with authenticated profiles, photo uploads, mutual matches, and real-time chat. The primary user-facing runtime is a Next.js app rooted at apps/web/app/page.tsx; its shared shell and request protection are in apps/web/app/layout.tsx and apps/web/middleware.ts. A separate Node socket service provides live chat transport through apps/socket-server/index.js.
Web application and route structure
Next.js App Router pages define the main product surfaces: authentication (apps/web/app/login/page.tsx, apps/web/app/signup/page.tsx), profile management (apps/web/app/profile/page.tsx), matches (apps/web/app/matches/page.tsx), and a match-specific chat room (apps/web/app/chat/[matchId]/page.tsx). Shared interaction/UI pieces are concentrated in apps/web/components/Navbar.tsx, apps/web/components/card.tsx, and apps/web/components/photoUpload.tsx.
Authentication and identity boundary
NextAuth is exposed through apps/web/app/api/auth/[...nextauth]/route.ts, with auth configuration and server helpers in apps/web/app/auth.config.ts and apps/web/auth.ts. Signup is a separate OTP workflow: clients request and validate an OTP through apps/web/app/api/signup/send-otp/route.ts and apps/web/app/api/signup/verify-otp/route.ts. Session-aware routing is an important boundary: page/API handlers should rely on the auth layer rather than trust client-supplied user identity.
Matching and profile flow
Profile reads/updates are handled by apps/web/app/api/profile/route.ts. The discovery/swipe flow is split between candidate retrieval (apps/web/app/api/showUsers/route.ts) and mutation (apps/web/app/api/swipe/route.ts). The likely control flow is: authenticated user retrieves eligible profiles, submits a directional swipe, then downstream persistence determines whether a reciprocal swipe produces a match visible in the matches and chat routes.
Media upload pipeline
Photo upload is intentionally two-stage: apps/web/app/api/photos/presign/route.ts issues upload authorization, while apps/web/app/api/photos/confirm/route.ts confirms the uploaded asset for application persistence. Supabase client/server adapters at apps/web/lib/supabase/client.ts and apps/web/lib/supabase/server.ts mark object storage as an external boundary. The browser should upload directly using a presigned flow; the application should only persist confirmed, authorized photo references.
Realtime chat subsystem
Chat rendering is scoped by match ID in apps/web/app/chat/[matchId]/ChatRoom.tsx. Client socket lifecycle management is centralized in apps/web/hooks/useSocket.ts, and the independent Socket.IO-style service entry point is apps/socket-server/index.js. This separates durable application data/API handling in Next.js from transient connection, room, and message-event delivery in the socket process. Authorization must ensure a connected user belongs to the requested match room.
Persistence and infrastructure
Database ownership is centralized in the reusable DB package: packages/db/prisma/schema.prisma, packages/db/index.js, and its migration history under packages/db/prisma/migrations. The migrations include NextAuth tables and user fields, indicating shared persistence for identity and product entities. Redis is integrated from the web app via apps/web/lib/redis.ts, likely for ephemeral OTP, session-adjacent, cache, or realtime-support state. Material runtimes are therefore Next.js/TypeScript, a separate Node socket server, Prisma-managed database access, Redis, and Supabase-backed media services.
Main entry points: auth.ts Auth and session layer · index.js Shared database access · confirm/route.ts Photo authorization · profile/route.ts Profile API
Components 17
Next.js web app
User interface, protected routes, and application APIs.
- Swipe discovery · Primary product entry point.
apps/web/app/page.tsx - Account and match pages · Login, signup, profile, matches, and chat routes.
apps/web/app/matches/page.tsx - App shell
apps/web/app/layout.tsx - Request protection · Enforces session-aware routing.
apps/web/middleware.ts - Shared UI · Navigation, cards, and photo upload interaction.
apps/web/components/photoUpload.tsx - Auth and session layer · Server-side identity boundary for pages and APIs.
apps/web/auth.ts - NextAuth endpoint
apps/web/app/api/auth/[...nextauth]/route.ts - Signup OTP flow · Issues and validates signup verification codes.
apps/web/app/api/signup/verify-otp/route.ts - Profile API · Reads and updates authenticated profiles.
apps/web/app/api/profile/route.ts - Discovery and swipe APIs · Returns candidates and records directional swipes.
apps/web/app/api/swipe/route.ts - Photo authorization · Presigns uploads then confirms authorized assets.
apps/web/app/api/photos/confirm/route.ts
Realtime chat
Independent process for transient chat delivery.
- Chat room client · Renders the room scoped to a match ID.
apps/web/app/chat/[matchId]/ChatRoom.tsx - Socket client lifecycle
apps/web/hooks/useSocket.ts - Chat transport · Manages connections, rooms, and message events.
apps/socket-server/index.js
Data services
Shared persistence and external state boundaries.
- Shared database access · Owns schema, migrations, and product/identity persistence.
packages/db/index.js - Redis · Supports OTP, cache, session-adjacent, or realtime state.
apps/web/lib/redis.ts - Supabase storage · Browser receives direct-upload authorization through the app.
apps/web/lib/supabase/server.ts
Connections 20
- App shell → Swipe discovery: hosts
- Request protection → Auth and session layer: checks session
- Account and match pages → Auth and session layer: uses identity
- NextAuth endpoint → Auth and session layer: exposes
- Auth and session layer → Shared database access: identity records
- Signup OTP flow → Redis: stores OTP state
- Signup OTP flow → Shared database access: creates verified user
- Swipe discovery → Discovery and swipe APIs: fetches and submits swipes
- Account and match pages → Profile API: manages profile
- Discovery and swipe APIs → Auth and session layer: authorizes user
- Discovery and swipe APIs → Shared database access: candidates, swipes, matches
- Profile API → Auth and session layer: authorizes user
- Profile API → Shared database access: profile data
- Shared UI → Photo authorization: requests upload flow
- Photo authorization → Auth and session layer: authorizes owner
- Photo authorization → Supabase storage: presigns and confirms assets
- Photo authorization → Shared database access: persists photo reference
- Chat room client → Socket client lifecycle: connects through
- Socket client lifecycle → Chat transport: room events
- Chat transport → Shared database access: validates match membership