# tarun516/stealthlink architecture

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

- Interactive diagram: https://gitdiagram.com/tarun516/stealthlink
- Repository: https://github.com/tarun516/stealthlink

## Overview

##### Project Type and Purpose
- StealthLink is a full-stack web application built with Next.js and TypeScript. It enables users to send and receive anonymous messages.
- The project integrates several external services and libraries including MongoDB for data storage, Nodemailer for email-based verification, NextAuth for authentication, and Gemini AI for potential AI-powered features.
- Emphasis is on anonymity, secure messaging, and user verification without revealing identities.

##### Analyzing the File Structure
- Top-Level Structure: You have core configuration (eslintrc.json, tailwind.config.ts, tsconfig.json), dependency definitions (package.json, package-lock.json), readme and other environment examples.
- The “src” directory contains most of the code with subdivisions:
- /app: Organized using Next.js’s file-based routing with clearly separated sections for the main app (dashboard, etc.) and the authentication flows (sign-up, sign-in, verify, etc.). This is where most of the client pages and layouts live.
- /api: Contains numerous endpoints corresponding to messaging (send/get messages, delete messages), authentication and verification logic, and even suggestions. Each API endpoint has its own folder and route file (e.g., src/app/api/send-message/route.ts).
- /components and /components/ui: Houses reusable UI components (Navbar, Footer, animated lists, etc.) and custom UI kits (buttons, forms, cards) likely based on Shadcn UI.
- /context and /hooks: Implements global state management (AuthProvider, DarkModeContext) and custom hooks, reinforcing separation of concerns.
- /lib, /model, /schemas, and /types: These provide utility functions (including database connection and email functionality), data models (e.g., User), and validation schemas for incoming data.
- The presence of files such as next.config.mjs, postcss.config.mjs, and others indicate standard Next.js configuration and styling (Tailwind CSS) choices.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend"
        A["Dashboard Pages (Next.js)"]:::frontend
        B["Auth Pages (Next.js)"]:::frontend
        C["UI Components"]:::frontend
        D["UI Kits"]:::frontend
        E["Global State & Context"]:::frontend
        F["Custom Hooks"]:::frontend
    end

    %% Backend / API Endpoints
    subgraph "Backend / API Endpoints"
        subgraph "Messaging APIs"
            G["Send Message (POST)"]:::backend
            H["Get Messages (GET)"]:::backend
            I["Delete Message (DELETE)"]:::backend
            J["Accept Messages"]:::backend
            K["Suggest Messages"]:::backend
        end
        subgraph "Auth & Verification APIs"
            L["NextAuth (Auth API)"]:::backend
            M["NextAuth Options"]:::backend
            N["Send Verify Code"]:::backend
            O["Verify Code"]:::backend
        end
    end

    %% Database & Models
    subgraph "Database & Models"
        Q["dbConnect (Database Connector)"]:::db
        P[(MongoDB Database)]:::db
        R["Data Models & Schemas"]:::db
    end

    %% External Services
    subgraph "External Services"
        S["Nodemailer Email Service"]:::external
        T["Email Templates"]:::external
        U["Gemini AI Integration"]:::external
    end

    %% Connections from Frontend to Backend APIs
    A -->|"triggers"| G
    A -->|"triggers"| H
    A -->|"triggers"| I
    A -->|"triggers"| J
    A -->|"triggers"| K
    B -->|"auth calls"| L
    B -->|"verification calls"| N
    B -->|"verification calls"| O

    %% Frontend internal connections
    A --- C
    A --- D
    B --- E
    B --- F

    %% Backend APIs to Database and External Systems
    G -->|"uses"| Q
    H -->|"uses"| Q
    I -->|"uses"| Q
    J -->|"uses"| Q
    K -->|"uses"| Q
    L -->|"uses"| Q
    M -->|"uses"| Q
    N -->|"uses"| Q
    O -->|"uses"| Q

    Q --> P

    N -->|"sendsEmail"| S
    O -->|"sendsEmail"| S
    S --> T

    %% Optional integration with Gemini AI for messaging enhancements
    J -->|"optionallyCallsGeminiAI"| U
    K -->|"optionallyCallsGeminiAI"| U

    %% Connections from Frontend to Global State & Hooks (for UI state management)
    A --- E
    B --- E
    A --- F
    B --- F

    %% Link Frontend with Data Models (for rendering validated data)
    C --- R
    D --- R

    %% Click Events for Frontend
    click A "https://github.com/tarun516/stealthlink/tree/main/src/app/(app)"
    click B "https://github.com/tarun516/stealthlink/tree/main/src/app/(auth)"
    click C "https://github.com/tarun516/stealthlink/tree/main/src/components"
    click D "https://github.com/tarun516/stealthlink/tree/main/src/components/ui"
    click E "https://github.com/tarun516/stealthlink/tree/main/src/context"
    click F "https://github.com/tarun516/stealthlink/tree/main/src/hooks"

    %% Click Events for Messaging API Endpoints
    click G "https://github.com/tarun516/stealthlink/blob/main/src/app/api/send-message/route.ts"
    click H "https://github.com/tarun516/stealthlink/blob/main/src/app/api/get-messages/route.ts"
    click I "https://github.com/tarun516/stealthlink/blob/main/src/app/api/delete-message/[messageid]/route.ts"
    click J "https://github.com/tarun516/stealthlink/blob/main/src/app/api/accept-messages/route.ts"
    click K "https://github.com/tarun516/stealthlink/blob/main/src/app/api/suggest-messages/route.ts"

    %% Click Events for Auth & Verification API Endpoints
    click L "https://github.com/tarun516/stealthlink/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click M "https://github.com/tarun516/stealthlink/blob/main/src/app/api/auth/[...nextauth]/options.ts"
    click N "https://github.com/tarun516/stealthlink/blob/main/src/app/api/send-verify-code/route.ts"
    click O "https://github.com/tarun516/stealthlink/blob/main/src/app/api/verify-code/route.ts"

    %% Click Events for Database Integration
    click Q "https://github.com/tarun516/stealthlink/blob/main/src/lib/dbConnect.ts"
    click R "https://github.com/tarun516/stealthlink/blob/main/src/model/User.ts"

    %% Click Events for Email Service Integration
    click S "https://github.com/tarun516/stealthlink/blob/main/src/lib/nodemailer.ts"
    click T "https://github.com/tarun516/stealthlink/blob/main/emails/customEmailTemplate.ts"

    %% Styling Classes
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef db fill:#f8bbd0,stroke:#880e4f,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
```
