How synmmmm/synmm works
Project Type and Purpose
• This is a full-stack, server-rendered React application built on Next.js (App Router) with two primary user interfaces: a public “app” section and an authenticated “admin” section.
• It uses NextAuth for user authentication, Prisma as its ORM to talk to a relational database, serverless API routes for CRUD operations (blog, contact, admin auth), and integrates with external services (eBird, OpenWeather, email provider).
File Structure Insights
• src/app: holds the Next.js App Router directory, split into two parallel route groups:
• (app) – public‐facing pages (blog listings, contact form, dynamic eBird/OpenWeather labs)
• (admin) – protected/admin pages (login, register, blog management, password reset)
• src/app/api: Next.js route handlers running as serverless functions for each domain (admin/auth/login, blog, contact, eBird data, weather)
• prisma: database migrations + schema.prisma (PostgreSQL/MySQL/SQLite) + generated client
• common, components, features, store: shared UI components, hooks, validation schemas, global state
• emails: server-side email templates to notify on contact submission and verification
Key System Components
a. Frontend (Browser)
• Public UI – pages under src/app/(app) rendered via SSR/SSG or client components (React + Tailwind CSS)
• Admin UI – pages under src/app/(admin) guarded by NextAuth session checks
b. Next.js Serverless Layer
• App Router – handles SSR, routing, and client component hydration
• API Routes – each folder under src/app/api becomes a serverless endpoint
• NextAuth – session store, JWT, callbacks integrated via src/app/api/auth/[...nextauth]
• Prisma Client – imported into API routes (common/utils/prismadb.ts) to perform DB queries
c. Database
• Managed via Prisma migrations; holds Users, Blogs, Contacts, etc.
d. External Services
• eBird REST API (observations, species, refs)
• OpenWeather API (current weather)
• Email Delivery Service (SendGrid, Mailgun, etc.) via server-side templates in src/emails
e. Deployment & Infrastructure
• Vercel (Serverless Functions runtime for API routes + edge caching)
• Public assets served from public/ (logos, textures)
• Environment Variables for DB connection, API keys, Email credentials
Component Relationships & Data Flows
• User Browser → Next.js App Server (SSR/SSG) → Browser
• Browser (public or admin) → fetch() → Next.js API Route (serverless)
• API Route → Prisma Client → Database
• API Route → External REST API (eBird/OpenWeather) → Response
• API Route → Email Service → Outbound email
• NextAuth routes manage session cookies & JWT in between Browser ↔ Server
Architectural Patterns & Principles
• Monolithic serverless architecture: Next.js App + API in one repo
• App Router pattern: separation of page vs. API logic by directory
• ORM pattern with Prisma and declarative migrations
• Edge-neutral serverless functions – stateless, invoked per request
• React Server Components vs Client Components (inferred from file extensions)