# unknownmaster0/feedback-app architecture

> Architecture diagram of the GitHub repository unknownmaster0/feedback-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unknownmaster0/feedback-app
- Repository: https://github.com/unknownmaster0/feedback-app

## Overview

##### Project type and purpose
- This is a full-stack web application built on Next.js.
- Purpose: allow users to register, sign in, send and receive feedback messages, get AI-suggested responses, and toggle a “Focus/Busy” mode to control incoming feedback.

##### File-structure analysis
- Top-level config & containers: Dockerfile, docker-compose.yml, .dockerignore, .gitignore.
- Frontend & backend unified under Next.js’ “src/app” (app-directory routing for pages and serverless API routes).
- “src/app/(auth)” & “src/app/(app)” contain page.tsx files for auth flows (signin/signup/verify-otp) and main UI (dashboard, user profiles).
- “src/app/api/…” directory holds individual serverless “route.ts” endpoints (auth, signUp, get-messages, send-message, suggest-messages, etc.).
- “src/models” defines Mongoose schemas. “src/lib” houses db.ts (Mongo connection), session.ts, utils.ts.
- “src/utils” contains AI integration (connectAi), email utility, custom response wrappers.
- Context & hooks (“src/context”, “src/hooks”) manage authentication state and toasts on client side.
- Styling via Tailwind CSS (tailwind.config.ts, postcss.config.mjs).
- Auth handled by NextAuth.js ([...nextauth] routes, session providers).

##### README insights
- Confirms tech-stack: Next.js + Tailwind CSS, MongoDB + Mongoose, NextAuth, external AI LLM model.
- Features: user listing, messaging, AI suggestions, auth, focus/busy toggle.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        Pages["Pages (SSR & Client)"]:::frontend
        Components["UI Components"]:::frontend
        ContextHooks["Context & Hooks"]:::frontend
    end

    %% Pages details
    subgraph "Pages"
        direction TB
        PHome["src/app/page.tsx"]:::frontend
        PSignIn["src/app/(auth)/signin/page.tsx"]:::frontend
        PSignUp["src/app/(auth)/signup/page.tsx"]:::frontend
        PVerifyOTP["src/app/(auth)/verify-otp/page.tsx"]:::frontend
        PDashboard["src/app/(app)/dashboard/page.tsx"]:::frontend
        PUserProfile["src/app/(app)/u/[userName]/page.tsx"]:::frontend
    end

    %% Components details
    subgraph "Components"
        direction TB
        Button["ButtonComponent.tsx"]:::frontend
        MessageCard["MessageCard.tsx"]:::frontend
        Navbar["Navbar.tsx"]:::frontend
        TopBar["TopBar.tsx"]:::frontend
        UIFolder["ui/*"]:::frontend
    end

    %% Context & Hooks details
    subgraph "Context & Hooks"
        direction TB
        AuthProvider["AuthProvider.tsx"]:::frontend
        SessionProvider["CustomsessionProvider.tsx"]:::frontend
        UseToast["use-toast.ts"]:::frontend
        UseGetSession["useGetSession.ts"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Next.js Server)"
        direction TB
        %% SSR handled in Frontend
        APIs["API Routes"]:::backend
        Utils["Utilities & Shared"]:::backend
        SessionUtil["Session Utility"]:::backend
        ModelsUtil["Mongoose Models & DB"]:::backend
    end

    %% API groups
    subgraph "Auth API"
        direction TB
        NextAuthRoute["[...nextauth]/route.ts"]:::backend
        NextAuthOpt["[...nextauth]/options.ts"]:::backend
        SignUpAPI["signUp/route.ts"]:::backend
        VerifyOTPAPI["verify-otp/route.ts"]:::backend
        ValidUserName["validating-username/route.ts"]:::backend
        VerifyUserName["verify-userName/route.ts"]:::backend
        DeleteSessionAPI["delete-session/route.ts"]:::backend
        GetSessionAPI["get-session/route.ts"]:::backend
    end

    subgraph "Messaging API"
        direction TB
        GetMessages["get-messages/route.ts"]:::backend
        SendMessage["send-message/route.ts"]:::backend
        DeleteMessage["delete-message/route.ts"]:::backend
        AcceptingMessages["accepting-messages/route.ts"]:::backend
    end

    subgraph "AI Suggestions API"
        direction TB
        SuggestMessages["suggest-messages/route.ts"]:::backend
    end

    subgraph "User Listing API"
        direction TB
        GetAllUsers["get-all-users/route.ts"]:::backend
    end

    %% Utilities & Models
    DBUtil["db.ts"]:::backend
    Models["models.ts"]:::backend
    LibUtils["utils.ts"]:::backend
    RespWrap["Response.ts"]:::backend
    SessionLib["session.ts"]:::backend
    ConnectAi["connectAi.ts"]:::backend
    SendEmail["sendEmail.utility.ts"]:::backend

    %% Database and External Services
    MongoDB["MongoDB"]:::db
    AIService["LLM API"]:::ext
    EmailService["Email Service"]:::ext

    %% Connections
    Pages -->|"fetch /page"| APIs
    ContextHooks -->|"XHR /api/*"| APIs
    APIs -->|"queries"| MongoDB
    APIs -->|"POST suggestions"| AIService
    APIs -->|"send OTP"| EmailService
    APIs -->|"session callbacks"| SessionLib

    Utils --> APIs
    SessionUtil --> APIs
    ModelsUtil --> APIs

    %% Click events
    click PHome "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/page.tsx"
    click PSignIn "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/(auth)/signin/page.tsx"
    click PSignUp "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/(auth)/signup/page.tsx"
    click PVerifyOTP "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/(auth)/verify-otp/page.tsx"
    click PDashboard "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/(app)/dashboard/page.tsx"
    click PUserProfile "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/(app)/u/[userName]/page.tsx"
    click Button "https://github.com/unknownmaster0/feedback-app/blob/main/src/components/ButtonComponent.tsx"
    click MessageCard "https://github.com/unknownmaster0/feedback-app/blob/main/src/components/MessageCard.tsx"
    click Navbar "https://github.com/unknownmaster0/feedback-app/blob/main/src/components/Navbar.tsx"
    click TopBar "https://github.com/unknownmaster0/feedback-app/blob/main/src/components/TopBar.tsx"
    click UIFolder "https://github.com/unknownmaster0/feedback-app/tree/main/src/components/ui"
    click AuthProvider "https://github.com/unknownmaster0/feedback-app/blob/main/src/context/AuthProvider.tsx"
    click SessionProvider "https://github.com/unknownmaster0/feedback-app/blob/main/src/context/CustomsessionProvider.tsx"
    click UseToast "https://github.com/unknownmaster0/feedback-app/blob/main/src/hooks/use-toast.ts"
    click UseGetSession "https://github.com/unknownmaster0/feedback-app/blob/main/src/hooks/useGetSession.ts"
    click NextAuthRoute "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click NextAuthOpt "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/auth/[...nextauth]/options.ts"
    click SignUpAPI "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/signUp/route.ts"
    click VerifyOTPAPI "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/verify-otp/route.ts"
    click ValidUserName "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/validating-username/route.ts"
    click VerifyUserName "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/verify-userName/route.ts"
    click DeleteSessionAPI "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/delete-session/route.ts"
    click GetSessionAPI "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/get-session/route.ts"
    click GetMessages "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/get-messages/route.ts"
    click SendMessage "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/send-message/route.ts"
    click DeleteMessage "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/delete-message/route.ts"
    click AcceptingMessages "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/accepting-messages/route.ts"
    click SuggestMessages "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/suggest-messages/route.ts"
    click GetAllUsers "https://github.com/unknownmaster0/feedback-app/blob/main/src/app/api/get-all-users/route.ts"
    click DBUtil "https://github.com/unknownmaster0/feedback-app/blob/main/src/lib/db.ts"
    click Models "https://github.com/unknownmaster0/feedback-app/blob/main/src/models/models.ts"
    click LibUtils "https://github.com/unknownmaster0/feedback-app/blob/main/src/lib/utils.ts"
    click RespWrap "https://github.com/unknownmaster0/feedback-app/blob/main/src/utils/Response.ts"
    click SessionLib "https://github.com/unknownmaster0/feedback-app/blob/main/src/lib/session.ts"
    click ConnectAi "https://github.com/unknownmaster0/feedback-app/blob/main/src/utils/connectAi.ts"
    click SendEmail "https://github.com/unknownmaster0/feedback-app/blob/main/src/utils/sendEmail.utility.ts"

    %% Styles
    classDef frontend fill:#B3CDE3,stroke:#333,stroke-width:1px
    classDef backend fill:#C2EABD,stroke:#333,stroke-width:1px
    classDef db fill:#FBE4A0,stroke:#333,stroke-width:1px
    classDef ext fill:#F8D7DA,stroke:#333,stroke-width:1px
```
