# dhruvjain2207/mystery-message architecture

> Architecture diagram of the GitHub repository dhruvjain2207/mystery-message, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhruvjain2207/mystery-message
- Repository: https://github.com/dhruvjain2207/mystery-message

## Overview

Mystery Message is an anonymous-feedback web app. Its main journey is account registration and email OTP verification, followed by a public profile accepting anonymous messages and an authenticated dashboard for viewing, deleting, and controlling message acceptance. The graph includes documented AI suggestions and profile-sharing capabilities; unsampled UI-to-API wiring is not asserted. Edges are limited to relationships shown in the excerpts, SOURCE INDEX, or README.

Main entry points: [`src/lib/dbconnect.ts`](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/dbconnect.ts) (Database connection), [`src/models/User.ts`](https://github.com/dhruvjain2207/mystery-message/blob/main/src/models/User.ts) (User and message model), [`src/lib/auth.ts`](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/auth.ts) (Authentication), [`src/app/dashboard/page.tsx`](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/dashboard/page.tsx) (Message dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_registration["Registration UI<br/>[page.tsx]"]
  node_verification["OTP verification UI<br/>[page.tsx]"]
  node_login["Login UI<br/>[page.tsx]"]
  node_dashboard["Message dashboard<br/>[page.tsx]"]
  node_navbar["Dashboard navigation<br/>[Navbar.tsx]"]
  node_profile["Public profile<br/>[page.tsx]"]
  node_username_edit["Username editor"]
end

subgraph group_identity["Identity and verification"]
  node_auth_api["Auth route<br/>[route.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_registration_api["Registration endpoint<br/>[route.ts]"]
  node_otp_api["OTP verification endpoint<br/>[route.ts]"]
  node_email["Verification email sender<br/>[resend.ts]"]
  node_email_template["Email template<br/>[emailTemplate.tsx]"]
  node_account_delete["Account deletion<br/>[route.ts]"]
  node_username_update["Username update<br/>[route.ts]"]
end

subgraph group_messaging["Anonymous messaging"]
  node_public_message["Anonymous message submission<br/>[route.ts]"]
  node_username_check["Username validation<br/>[route.ts]"]
  node_suggestions["AI message suggestions<br/>[ai.ts]"]
  node_suggest_api["Suggestion endpoint<br/>[route.ts]"]
  node_message_read["Fetch messages<br/>[route.ts]"]
  node_message_delete["Delete message<br/>[route.ts]"]
  node_accept_toggle["Acceptance control<br/>[route.ts]"]
end

subgraph group_services["Application services"]
  node_resend["Resend email service"]
  node_groq["Groq AI service"]
end

subgraph group_data["Persistence"]
  node_user_model["User and message model<br/>[User.ts]"]
  node_database[("MongoDB")]
  node_db_connection["Database connection<br/>[dbconnect.ts]"]
end

node_visitor(("Visitor"))

node_visitor -->|"registers"| node_registration
node_visitor -->|"verifies email"| node_verification
node_visitor -->|"signs in"| node_login
node_visitor -->|"visits profile"| node_profile
node_visitor -->|"manages messages"| node_dashboard
node_auth_api -->|"routes to"| node_auth
node_auth -->|"authenticates against"| node_user_model
node_auth -->|"connects via"| node_db_connection
node_registration_api -->|"creates or updates"| node_user_model
node_registration_api -->|"connects via"| node_db_connection
node_registration_api -->|"sends verification"| node_email
node_email -->|"renders"| node_email_template
node_email -.->|"sends through"| node_resend
node_otp_api -->|"verifies and saves"| node_user_model
node_otp_api -->|"connects via"| node_db_connection
node_profile -->|"validates username"| node_username_check
node_public_message -->|"stores message"| node_user_model
node_public_message -->|"connects via"| node_db_connection
node_suggest_api -->|"requests suggestions"| node_suggestions
node_suggestions -.->|"uses AI service"| node_groq
node_dashboard -->|"renders"| node_navbar
node_dashboard -.->|"fetches messages"| node_message_read
node_dashboard -.->|"deletes messages"| node_message_delete
node_dashboard -.->|"sets acceptance"| node_accept_toggle
node_message_read -->|"checks session"| node_auth
node_message_read -->|"reads messages"| node_user_model
node_message_read -->|"connects via"| node_db_connection
node_message_delete -->|"checks session"| node_auth
node_message_delete -->|"removes message"| node_user_model
node_message_delete -->|"connects via"| node_db_connection
node_accept_toggle -->|"checks session"| node_auth
node_accept_toggle -->|"updates acceptance"| node_user_model
node_accept_toggle -->|"connects via"| node_db_connection
node_username_edit -.->|"updates username"| node_username_update
node_username_update -->|"checks session"| node_auth
node_username_update -->|"updates username"| node_user_model
node_username_update -->|"connects via"| node_db_connection
node_account_delete -->|"checks session"| node_auth
node_account_delete -->|"deletes account"| node_user_model
node_account_delete -->|"connects via"| node_db_connection
node_db_connection -->|"connects to"| node_database

click node_registration "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/register/page.tsx"
click node_verification "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/verify/page.tsx"
click node_login "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/login/page.tsx"
click node_dashboard "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/dashboard/page.tsx"
click node_navbar "https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/Navbar.tsx"
click node_profile "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/u/%5Busername%5D/page.tsx"
click node_username_edit "https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/editusernameform.tsx"
click node_auth_api "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_auth "https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/auth.ts"
click node_registration_api "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/register/route.ts"
click node_otp_api "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/verifyotp/route.ts"
click node_email "https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/resend.ts"
click node_email_template "https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/emailTemplate.tsx"
click node_public_message "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/send-message/route.ts"
click node_username_check "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/usernameValidation/route.ts"
click node_suggestions "https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/ai.ts"
click node_suggest_api "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/suggest-messages/route.ts"
click node_message_read "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/get-messages/route.ts"
click node_message_delete "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/delete-message/route.ts"
click node_accept_toggle "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/accept-messages/route.ts"
click node_account_delete "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/delete-account/route.ts"
click node_username_update "https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/updateUsername/route.ts"
click node_user_model "https://github.com/dhruvjain2207/mystery-message/blob/main/src/models/User.ts"
click node_db_connection "https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/dbconnect.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_registration,node_verification,node_login,node_dashboard,node_navbar,node_profile,node_username_edit toneBlue
class node_auth_api,node_auth,node_registration_api,node_otp_api,node_email,node_email_template,node_account_delete,node_username_update toneAmber
class node_public_message,node_username_check,node_suggestions,node_suggest_api,node_message_read,node_message_delete,node_accept_toggle toneMint
class node_resend,node_groq toneRose
class node_user_model,node_database,node_db_connection,node_visitor toneIndigo
```

## Components

### Web experience

- [Registration UI](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/register/page.tsx): `src/app/register/page.tsx`
- [OTP verification UI](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/verify/page.tsx): `src/app/verify/page.tsx`
- [Login UI](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Message dashboard](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Dashboard navigation](https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/Navbar.tsx): `src/components/Navbar.tsx`
- [Public profile](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/u/%5Busername%5D/page.tsx): `src/app/u/[username]/page.tsx`
- [Username editor](https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/editusernameform.tsx): `src/components/editusernameform.tsx`

### Identity and verification

- [Auth route](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts): `src/app/api/auth/[...nextauth]/route.ts`
- [Authentication](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Registration endpoint](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/register/route.ts): `src/app/api/register/route.ts`
- [OTP verification endpoint](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/verifyotp/route.ts): `src/app/api/verifyotp/route.ts`
- [Verification email sender](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/resend.ts): `src/lib/resend.ts`
- [Email template](https://github.com/dhruvjain2207/mystery-message/blob/main/src/components/emailTemplate.tsx): `src/components/emailTemplate.tsx`
- [Account deletion](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/delete-account/route.ts): `src/app/api/delete-account/route.ts`
- [Username update](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/updateUsername/route.ts): `src/app/api/updateUsername/route.ts`

### Anonymous messaging

- [Anonymous message submission](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/send-message/route.ts): `src/app/api/send-message/route.ts`
- [Username validation](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/usernameValidation/route.ts): `src/app/api/usernameValidation/route.ts`
- [AI message suggestions](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/ai.ts): `src/lib/ai.ts`
- [Suggestion endpoint](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/suggest-messages/route.ts): `src/app/api/suggest-messages/route.ts`
- [Fetch messages](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/get-messages/route.ts): `src/app/api/get-messages/route.ts`
- [Delete message](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/delete-message/route.ts): `src/app/api/delete-message/route.ts`
- [Acceptance control](https://github.com/dhruvjain2207/mystery-message/blob/main/src/app/api/accept-messages/route.ts): `src/app/api/accept-messages/route.ts`

### Application services

- **Resend email service**
- **Groq AI service**

### Persistence

- [User and message model](https://github.com/dhruvjain2207/mystery-message/blob/main/src/models/User.ts): `src/models/User.ts`
- **MongoDB**
- [Database connection](https://github.com/dhruvjain2207/mystery-message/blob/main/src/lib/dbconnect.ts): `src/lib/dbconnect.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Registration UI: registers (evidence: `README.md`)
- Visitor → OTP verification UI: verifies email (evidence: `README.md`)
- Visitor → Login UI: signs in (evidence: `README.md`)
- Visitor → Public profile: visits profile (evidence: `README.md`)
- Visitor → Message dashboard: manages messages (evidence: `README.md`)
- Auth route → Authentication: routes to (evidence: `src/app/api/auth/[...nextauth]/route.ts`)
- Authentication → User and message model: authenticates against (evidence: `src/lib/auth.ts`)
- Authentication → Database connection: connects via (evidence: `src/lib/auth.ts`)
- Registration endpoint → User and message model: creates or updates (evidence: `src/app/api/register/route.ts`)
- Registration endpoint → Database connection: connects via (evidence: `src/app/api/register/route.ts`)
- Registration endpoint → Verification email sender: sends verification (evidence: `src/app/api/register/route.ts`)
- Verification email sender → Email template: renders (evidence: `src/lib/resend.ts`)
- Verification email sender → Resend email service: sends through
- OTP verification endpoint → User and message model: verifies and saves (evidence: `src/app/api/verifyotp/route.ts`)
- OTP verification endpoint → Database connection: connects via (evidence: `src/app/api/verifyotp/route.ts`)
- Public profile → Username validation: validates username (evidence: `src/app/api/usernameValidation/route.ts`)
- Anonymous message submission → User and message model: stores message (evidence: `src/app/api/send-message/route.ts`)
- Anonymous message submission → Database connection: connects via (evidence: `src/app/api/send-message/route.ts`)
- Suggestion endpoint → AI message suggestions: requests suggestions (evidence: `src/app/api/suggest-messages/route.ts`)
- AI message suggestions → Groq AI service: uses AI service
- Message dashboard → Dashboard navigation: renders (evidence: `src/app/dashboard/page.tsx`)
- Message dashboard → Fetch messages: fetches messages
- Message dashboard → Delete message: deletes messages
- Message dashboard → Acceptance control: sets acceptance
- Fetch messages → Authentication: checks session (evidence: `src/app/api/get-messages/route.ts`)
- Fetch messages → User and message model: reads messages (evidence: `src/app/api/get-messages/route.ts`)
- Fetch messages → Database connection: connects via (evidence: `src/app/api/get-messages/route.ts`)
- Delete message → Authentication: checks session (evidence: `src/app/api/delete-message/route.ts`)
- Delete message → User and message model: removes message (evidence: `src/app/api/delete-message/route.ts`)
- Delete message → Database connection: connects via (evidence: `src/app/api/delete-message/route.ts`)
- Acceptance control → Authentication: checks session (evidence: `src/app/api/accept-messages/route.ts`)
- Acceptance control → User and message model: updates acceptance (evidence: `src/app/api/accept-messages/route.ts`)
- Acceptance control → Database connection: connects via (evidence: `src/app/api/accept-messages/route.ts`)
- Username editor → Username update: updates username
- Username update → Authentication: checks session (evidence: `src/app/api/updateUsername/route.ts`)
- Username update → User and message model: updates username (evidence: `src/app/api/updateUsername/route.ts`)
- Username update → Database connection: connects via (evidence: `src/app/api/updateUsername/route.ts`)
- Account deletion → Authentication: checks session (evidence: `src/app/api/delete-account/route.ts`)
- Account deletion → User and message model: deletes account (evidence: `src/app/api/delete-account/route.ts`)
- Account deletion → Database connection: connects via (evidence: `src/app/api/delete-account/route.ts`)
- Database connection → MongoDB: connects to (evidence: `src/lib/dbconnect.ts`)
