# prajwalwadekar/authify architecture

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

- Interactive diagram: https://gitdiagram.com/prajwalwadekar/authify
- Repository: https://github.com/prajwalwadekar/authify

## Overview

##### Project type and purpose
- Authify is a full-stack MERN (MongoDB, Express, React, Node.js) authentication system.
- It provides a complete user authentication flow: signup with email verification, login/logout, forgot/reset password, protected routes, and email notifications via Resend API.

##### File structure
Top level:
- backend/ – Express server
- frontend/ – React single‐page app
- outputs/ – screenshot assets
Backend substructure (MVC‐style):
- controllers/ – request handlers (auth.controller.js)
- routes/ – route definitions (auth.routes.js)
- models/ – Mongoose schemas (user.model.js)
- db/ – DB connection (connectDB.js)
- middleware/ – JWT verification (verifyToken.js)
- utils/ – token generation & cookie setting
- resend/ – email templates, service config
Frontend substructure:
- public/ – static assets, index.html
- src/
– components/ – reusable UI bits
– pages/ – route‐mapped views (Login, Signup, Dashboard, etc.)
– store/ – state management (authStore.js)
– utils/ – helper functions
- main.jsx & App.jsx – entry points
Config files: ESLint, Vite, package.json

##### README insights
- Describes features, tech stack, authentication flow steps, environment variables, and live demo.
- Emphasizes React+Tailwind UI, Express+JWT, MongoDB, Resend API.

##### Main components
a. Frontend (React SPA)
– Pages: Signup, Login, Dashboard, Email Verification, Forgot/Reset Password
– State store: authStore
– HTTP client (fetch/axios)
– Routing (React Router)
b. Backend (Node/Express API)
– Routes & Controllers: /api/auth
– Middleware: JWT verification
– Utils: token gen & cookies
c. Database
– MongoDB Atlas (User collection)
d. Email Service
– Resend API for sending verification & reset emails
e. External Clients & Environments
– Browser (client‐side)
– .env config (MONGO_URI, JWT_SECRET, CLIENT_URL, etc.)

##### Relationships & Interactions
1. User (Browser) → Frontend UI
2. Frontend → Backend API (HTTP requests to auth.routes)
- Signup: POST /signup → generate JWT, send email
- Email link callback: GET /verify-email?token=…
- Login: POST /login → set HTTP‐only cookie
- Forgot password: POST /forgot-password → send reset email
- Reset password: POST /reset-password → update DB
- Dashboard: GET /protected → JWT middleware
3. Backend ↔ MongoDB (CRUD on User)
4. Backend → Resend API (emailTemplates & emails)

##### Architectural patterns & design principles
- Client-Server separation (React client vs. Express server)
- MVC (Models, Controllers, Routes) on backend
- JWT-based stateless authentication with HTTP-only cookies
- Single‐Responsibility: separate modules for DB logic, email logic, token logic
- Environment abstraction (.env for secrets)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Browser["Browser"]:::client
    end

    subgraph "Frontend: React App"
        direction TB
        Main["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
        subgraph "Pages"
            direction TB
            SignUpPage["SignUpPage.jsx"]:::frontend
            LoginPage["LoginPage.jsx"]:::frontend
            DashboardPage["DashboardPage.jsx"]:::frontend
            EmailVerificationPage["EmailVerificationPage.jsx"]:::frontend
            ForgotPasswordPage["ForgotPasswordPage.jsx"]:::frontend
            ResetPasswordPage["ResetPasswordPage.jsx"]:::frontend
        end
        subgraph "Components"
            direction TB
            FloatingShapes["FloatingShapes.jsx"]:::frontend
            Input["Input.jsx"]:::frontend
            LoadingSpinner["LoadingSpinner.jsx"]:::frontend
            PasswordStrengthMeter["PasswordStrengthMeter.jsx"]:::frontend
        end
        Store["authStore.js"]:::frontend
        UtilsFE["date.js"]:::frontend
        Static["public & index.html"]:::frontend
        ConfigFE["vite.config.js<br>eslint.config.js"]:::frontend
    end

    Browser -->|"loads"| Static
    Browser -->|"SPA navigation"| Main
    Main --> App
    App --> Pages
    App --> Components
    App --> Store
    App --> UtilsFE

    Browser -->|"User actions & form submissions"| App

    %% API Layer
    subgraph "Backend: Express Server"
        direction TB
        Entry["index.js"]:::backend
        Routes["auth.routes.js"]:::backend
        Controllers["auth.controller.js"]:::backend
        Middleware["verifyToken.js"]:::backend
        Models["user.model.js"]:::backend
        DBConn["connectDB.js"]:::backend
        TokenUtil["generateTokenAndSetCookie.js"]:::backend
        subgraph "Resend Email Service"
            direction TB
            ResendConfig["resend.config.js"]:::backend
            EmailTemplates["emailTemplates.js"]:::backend
            Emails["emails.js"]:::backend
        end
    end

    App -->|"HTTP: POST/GET to /api/auth/*"| Routes
    Routes -->|"call handlers"| Controllers
    Controllers -->|"use DBConn"| DBConn
    Controllers -->|"CRUD operations"| Models
    Controllers -->|"set JWT cookie"| TokenUtil
    Controllers -->|"verify JWT"| Middleware
    Controllers -->|"send emails"| Emails
    Emails --> ResendConfig
    Emails --> EmailTemplates

    %% External Services
    Controllers -->|"CRUD on users"| MongoDB[(MongoDB Atlas)]:::db
    Controllers -->|"send email via Resend API"| ResendAPI["Resend API"]:::cloud

    %% Legend Styles
    classDef client fill:#B3E5FC,stroke:#0288D1,color:#01579B;
    classDef frontend fill:#BBDEFB,stroke:#1976D2,color:#0D47A1;
    classDef backend fill:#C8E6C9,stroke:#388E3C,color:#1B5E20;
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100,stroke-dasharray: 5 5;
    classDef cloud fill:#E1BEE7,stroke:#8E24AA,color:#4A148C,stroke-dasharray: 5 5;

    %% Click Events - Frontend
    click Main "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/main.jsx"
    click App "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/App.jsx"
    click SignUpPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/SignUpPage.jsx"
    click LoginPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/LoginPage.jsx"
    click DashboardPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/DashboardPage.jsx"
    click EmailVerificationPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/EmailVerificationPage.jsx"
    click ForgotPasswordPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/ForgotPasswordPage.jsx"
    click ResetPasswordPage "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/pages/ResetPasswordPage.jsx"
    click FloatingShapes "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/components/FloatingShapes.jsx"
    click Input "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/components/Input.jsx"
    click LoadingSpinner "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/components/LoadingSpinner.jsx"
    click PasswordStrengthMeter "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/components/PasswordStrengthMeter.jsx"
    click Store "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/store/authStore.js"
    click UtilsFE "https://github.com/prajwalwadekar/authify/blob/main/frontend/src/utils/date.js"
    click Static "https://github.com/prajwalwadekar/authify/tree/main/frontend/public"
    click Static "https://github.com/prajwalwadekar/authify/blob/main/frontend/index.html"
    click ConfigFE "https://github.com/prajwalwadekar/authify/blob/main/frontend/vite.config.js"
    click ConfigFE "https://github.com/prajwalwadekar/authify/blob/main/frontend/eslint.config.js"

    %% Click Events - Backend
    click Entry "https://github.com/prajwalwadekar/authify/blob/main/backend/index.js"
    click Routes "https://github.com/prajwalwadekar/authify/blob/main/backend/routes/auth.routes.js"
    click Controllers "https://github.com/prajwalwadekar/authify/blob/main/backend/controllers/auth.controller.js"
    click Middleware "https://github.com/prajwalwadekar/authify/blob/main/backend/middleware/verifyToken.js"
    click Models "https://github.com/prajwalwadekar/authify/blob/main/backend/models/user.model.js"
    click DBConn "https://github.com/prajwalwadekar/authify/blob/main/backend/db/connectDB.js"
    click TokenUtil "https://github.com/prajwalwadekar/authify/blob/main/backend/utils/generateTokenAndSetCookie.js"
    click ResendConfig "https://github.com/prajwalwadekar/authify/blob/main/backend/resend/resend.config.js"
    click EmailTemplates "https://github.com/prajwalwadekar/authify/blob/main/backend/resend/emailTemplates.js"
    click Emails "https://github.com/prajwalwadekar/authify/blob/main/backend/resend/emails.js"
```
