|
1 | | -# msgBox |
2 | | -A modern message-sending app built with Next.js, featuring real-time AI responses using OpenAI, user authentication with NextAuth, and designed as a learning project to explore full-stack Next.js development. |
| 1 | +# msgbox |
| 2 | + |
| 3 | +A lightweight Next.js (App Router + TypeScript) messaging demo application. |
| 4 | + |
| 5 | +This project demonstrates a minimal messaging flow with user sign-up, email verification, authentication (NextAuth), server validation (Zod), and MongoDB (Mongoose). |
| 6 | + |
| 7 | +## What this repo contains |
| 8 | + |
| 9 | +- Next.js App Router pages and API routes under `src/app` |
| 10 | +- Reusable UI components under `src/components` |
| 11 | +- Zod validation schemas in `src/schemas` |
| 12 | +- Mongoose models in `src/model` and DB helpers in `src/lib` |
| 13 | +- Helper utilities for email verification and resend logic |
| 14 | + |
| 15 | +## Features |
| 16 | + |
| 17 | +- Sign up and sign-in with email verification |
| 18 | +- Send, accept, and list messages via API routes |
| 19 | +- Request validation using Zod schemas |
| 20 | +- NextAuth credentials provider for authentication |
| 21 | + |
| 22 | +## Requirements |
| 23 | + |
| 24 | +- Node.js 18+ (or the version used in your environment) |
| 25 | +- npm (or yarn / pnpm) |
| 26 | + |
| 27 | +## Install |
| 28 | + |
| 29 | +Install dependencies: |
| 30 | + |
| 31 | +```powershell |
| 32 | +npm install |
| 33 | +``` |
| 34 | + |
| 35 | +## Environment variables |
| 36 | + |
| 37 | +Create a `.env.local` file in the project root and add the required environment variables. Common variables used by this project include: |
| 38 | + |
| 39 | +- `MONGO_URI` — MongoDB connection string |
| 40 | +- `NEXTAUTH_SECRET` — NextAuth secret |
| 41 | +- `NEXTAUTH_URL` — NextAuth URL (for example, `http://localhost:3000`) |
| 42 | +- `OPENAI_API_KEY` — (only if OpenAI features are used) |
| 43 | +- SMTP / email variables used by the verification email sender (check `src/helpers/sendVerificationEmail.ts`) |
| 44 | + |
| 45 | +Check the API route files under `src/app/api` for any additional environment variables referenced by specific routes. |
| 46 | + |
| 47 | +## Run (development) |
| 48 | + |
| 49 | +```powershell |
| 50 | +npm run dev |
| 51 | +``` |
| 52 | + |
| 53 | +## Build and start (production) |
| 54 | + |
| 55 | +```powershell |
| 56 | +npm run build |
| 57 | +npm run start |
| 58 | +``` |
| 59 | + |
| 60 | +## Project structure (high level) |
| 61 | + |
| 62 | +- `src/app` — App Router pages and API routes (core application) |
| 63 | +- `src/components` — UI components and shared presentational pieces |
| 64 | +- `src/schemas` — Zod validation schemas for request bodies |
| 65 | +- `src/model` — Mongoose models (e.g. `User`) |
| 66 | +- `src/lib` — utilities (DB connection, helpers) |
| 67 | +- `src/helpers` — e.g. `sendVerificationEmail.ts` |
| 68 | + |
| 69 | +## Notes & recommended next steps |
| 70 | + |
| 71 | +- Add a `LICENSE` if you intend to publish the repo publicly. |
| 72 | +- Add automated tests (Vitest or Jest) for API routes and helper logic. |
| 73 | +- Add stronger type annotations for NextAuth authorize return types to avoid `any`. |
| 74 | + |
| 75 | +## Contributing |
| 76 | + |
| 77 | +Contributions are welcome. Open an issue to discuss larger changes or submit a PR with a clear description and tests when appropriate. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +<sub>Created by following the "Chai aur NextJs" playlist on YouTube.</sub> |
0 commit comments