How ritammaity55/fynk works
Project type and purpose
• This is a full-stack social-media web application (“Fynk”) built with Next.js (App Router), React, TypeScript, Tailwind CSS, Prisma (PostgreSQL), Clerk (auth), and UploadThing (file uploads).
• Purpose: allow users to sign up/log in, create and view posts (with media), follow other users, receive notifications, and perform CRUD operations via a seamless, real-time UX.
File structure
• Top-level:
• src/app/ – Next.js App Router pages and route-handlers (server components, API routes under api/).
• src/actions/ – server-side business logic (Post, User, Profile, Notification actions).
• src/components/ & src/components/ui/ – reusable React components and UI primitives.
• src/lib/ – shared utilities (prisma.ts, uploadthing.ts, utils.ts).
• prisma/schema.prisma – DB schema definition.
• Config files: next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json.
• Public assets under public/.
• Middlewares: src/middleware.ts.
README for additional insights
• Frontend: server and client components, dynamic/static routing, caching and revalidation.
• Backend: Next.js Route Handlers under src/app/api/, Prisma for DB, Clerk for auth, UploadThing for media.
• Deployment: Vercel, Netlify, AWS.
Main components
a. Frontend (Next.js App Router)
• Pages (Server Components)
• Client Components (e.g., CreatePost, PostCard, Navbar)
• UI library & theming (Tailwind, Shadcn UI)
b. API / Backend layer
• Next.js Route Handlers under src/app/api/*
• Server Actions (src/actions/*.action.ts) invoked by React components/forms
• Middleware (e.g., authentication, session)
c. Database
• PostgreSQL (connected via Prisma ORM)
d. Authentication & Authorization
• Clerk (external service for user sign-up/sign-in)
e. File Upload service
• UploadThing (external service for handling uploads)
f. Deployment / Hosting
• Vercel (or equivalent) for hosting serverless functions & static assets
Relationships & interactions
• Frontend pages/components → invoke Server Actions or call Route Handlers (via fetch API) → Process logic (in src/actions or route code) → Prisma ORM → Postgres.
• Authentication flows: Frontend ↔ Clerk SDK → Clerk service → returns session tokens → backend middleware validates.
• File uploads: Frontend uses lib/uploadthing.ts → UploadThing API → stores media and returns URLs → persisted via Prisma in Postgres.
• Real-time & optimistic updates: Client components subscribe/refresh after mutations.
• Deployment: code is deployed to Vercel, static assets to CDN.
Architectural patterns & principles
• Component separation: Server vs Client components in Next.js
• Route Handlers instead of a monolithic REST API
• Layered architecture: Presentation (React) → Application (Actions/Route Handlers) → Domain (Prisma models) → Infrastructure (DB, Clerk, UploadThing)
• Caching & revalidation strategies (ISR/SSR) for performance
What to label and highlight
• Call paths (e.g., “Client component → calls POST /api/tasks → invokes task.action.ts → Prisma.createTask()”).
• Middleware/authentication guard between UI and API.
• File upload flow separately (UI → lib/uploadthing → UploadThing → storage URL → Prisma).
Final checklist
• All major components (Frontend, API, DB, Auth, Upload service)
• Labels that map back to directory names and key files
• Annotations for architectural patterns (Server vs Client components, caching)