How sumitcoder01/anony-texts works
Project type and purpose
• This is a full-stack web application (“Anony Texts”) built on Next.js (app router), offering anonymous messaging with authentication, email notifications, and AI-enhanced features.
File structure
• src/app: Next.js pages & layouts (client-side and server-side rendered UI).
• src/app/api: API routes (Next.js serverless functions) handling auth, messaging, file upload, etc.
• src/lib: Business logic and integration code (DB connection, Cloudinary, email sending, AI prompts).
• src/models & src/schemas: Data models (User) and validation schemas (Zod).
• src/context: React Context providers (AuthContext, ThemeContext).
• config files: next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json.
README
• Next.js + Tailwind CSS + shadcn UI library for presentation layer
• NextAuth for authentication
• Resend for email delivery
• Zod + React Hook Form for schema validation and form handling
• Gemini (AI) integration for enhanced messaging features
• Deployed on Vercel
Main components and their interactions
a. User’s Browser (Client)
• Interacts with Next.js pages (SSR/CSR) and static assets (public folder).
• Uses React Hook Form + Zod validation in forms.
b. Next.js Frontend (App Router)
• Layouts & pages in src/app
• UI Components from src/components
• ThemeContext & AuthContext provide state and theming.
c. Next.js API Routes (Serverless Functions)
• Auth endpoints (NextAuth, register, login, verify-user, forgot/update-password)
• Messaging endpoints (send-message, get-messages, delete-message, accept-messages)
• Utility endpoints (check-username-unique)
d. Business Logic Layer (src/lib)
• dbConnect: Connects to MongoDB (or another DB)
• cloudinary: Handles image uploads
• sendEmail / resend: Manages email notifications
• suggestMessages / Gemini: AI-powered messaging suggestions
e. Data Layer
• src/models/User.ts: Mongoose schema for users
• Zod schemas: Request validation
f. External Services
• Database (MongoDB Atlas or similar)
• Cloudinary (image hosting)
• Resend (email delivery)
• OpenAI / Gemini (AI features)
Architectural patterns and design principles
• Separation of concerns: UI layer (components) vs. API layer vs. business logic vs. data layer
• Serverless micro-endpoints: Each API route is a discrete function
• Context-driven global state: Auth & Theme via React Context
• Schema-driven validation: Zod for request and form validation
• Component-driven UI: Reusable UI primitives (shadcn) and shared components