How arunstha21/sendgrid-mailer works
Project Type and Purpose
• This is a full-stack web application built with Next.js (React) on the frontend and Node.js/TypeScript on the backend.
• Purpose: manage users and events, compose/send emails via SendGrid, import match data, and display results.
Main Components
A. Frontend (Next.js App)
• Pages & Routing (src/app/**)
• /login (src/app/page.tsx)
• /adduser (src/app/adduser/page.tsx)
• /dashboard (src/app/dashboard/[path]/page.tsx) – new email, import, results tabs
• /results (event-specific results pages)
• /settings (user/event feature settings)
• UI Components (src/components & src/components/ui)
• Styling: Tailwind CSS (tailwind.config.ts, globals.css)
B. Backend API (Next.js API Routes + Custom Server)
• Next.js API Routes (src/server/*.ts invoked via /api/*)
• user.ts – auth, JWT token issuance/validation
• database.ts – CRUD operations against DB
• match.ts – import/validate match data
• publicResult.ts – serve public result pages
• sendgrid.ts – wrap SendGrid REST calls
• Middleware (src/middleware.ts) – JWT validation, role-based access
C. Database Layer
• Connection & Schema (src/lib/database/connect.tsx, schema.tsx)
• Database: PostgreSQL (or similar SQL DB) accessed via TypeORM/Prisma/knex (implied)
D. External Services
• SendGrid API – send transactional emails
• Storage (local .csv/.xlsx upload, or optional S3 for large files)
Relationships & Data Flows
• User → Frontend (React UI)
• Frontend → API Routes (HTTP/HTTPS, JSON)
• API Routes → Middleware → Authentication/Authorization → Database
• API Routes → Database Layer → Persistent Storage
• API Routes → SendGrid Service → Email Delivery
• File Upload → match.ts → CSV/XLSX parser → Database
Architectural Patterns
• Layered Architecture:
• Presentation Layer (Next.js pages & components)
• Application/API Layer (Next.js API routes + middleware)
• Data Access Layer (database connect & schema)
• External Integration Layer (SendGrid)
• Component-Based UI (React + Tailwind)
• Server-Side Rendering (Next.js) with API routes
• JWT-Based Authentication & Role-Based Authorization