# chahatkesh/webmark architecture

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

- Interactive diagram: https://gitdiagram.com/chahatkesh/webmark
- Repository: https://github.com/chahatkesh/webmark

## Overview

##### Main Components
- Frontend Client: Emphasizes the UI layer built with React. It features various pages (Home, Dashboard, Auth, Help, etc.), reusable components (both for home and dashboard functionality), custom hooks (e.g., useAuth, useBookmarks), and context providers for global state management. It also integrates development tools and various libraries such as Tailwind CSS, React Router, and React Beautiful DnD.
- Backend Server: Built using Node.js and Express. It contains directories for configuration (database connections, email configuration), controllers (handling bookmark, category, stats, and user operations), middleware (for authentication), and models (Mongoose schemas for bookmarks, categories, stats, and users). Additionally, it includes scheduled tasks (via node-cron) and utility scripts.
- Database: MongoDB (accompanied by Mongoose for schema modeling).
- External Services & Integrations: Email service (Nodemailer) for notifications, authentication components (JWT and Bcrypt for secure password logic), and potentially integrations for analytics or future AI-powered functionality.

##### Relationships and Interactions
- The Frontend interacts with the Backend over HTTP/REST API endpoints. User actions on the client—such as creating, editing, or deleting bookmarks—translate into API calls handled by controllers within the backend.
- The Backend processes these requests, applying authentication (via the auth middleware) before interacting with the database (MongoDB through Mongoose models).
- Additional interactions include scheduled tasks, such as periodic jobs managed by node-cron, and the integration of email notifications via Nodemailer.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between the frontend and backend roles.
- MVC-esque Structure on the Server: Controllers (business logic), models (data schemas), and middleware for authentication.
- Component-based UI on the Frontend: Modular React components in separate directories for Home and Dashboard.
- Modern development practices: Use of a Vite build tool, TypeScript for type safety, and optional Context API combined with React Query for state management.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React.js, React Router, TypeScript, Tailwind CSS, React Query, Radix UI, Lucide React, Framer Motion, React Toastify, and React Beautiful DnD. Vite is used for the development toolchain.
- Backend: Node.js, Express.js, MongoDB (with Mongoose), JWT for authentication, Bcrypt for password hashing, Nodemailer for email notifications, and node-cron for task scheduling.
- DevOps: ESLint configuration for code quality and version control via Git.

- Within the Frontend section, map out critical subsystems such as “UI Components” (e.g., Header, Dashboard Components, Home Components), “State Management” (Context API, React Query), and “Routing.”
- In the Backend section, illustrate the flow from “Incoming API Requests” to “Controllers” (bookmarkController, userController, etc.), through “Middleware (Authentication),” down to “Models” (e.g., bookmarkModel), and finally to “MongoDB.”
- Annotations or callouts if needed to highlight key technologies or unique application features like “Smart Organization” or “Secure Sharing.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        FE["Frontend Client (React Application)"]:::frontend
        FE_Pages["UI Pages & Routing"]:::frontend
        FE_Components["Reusable UI Components"]:::frontend
        FE_Hooks["Custom Hooks"]:::frontend
        FE_Context["Global State Management"]:::frontend
    end

    subgraph "Backend"
        BE["Backend Server (Node.js/Express)"]:::backend
        BE_Config["Server Configuration (Database & Email)"]:::backend
        BE_Controllers["API Controllers"]:::backend
        BE_Middleware["Authentication Middleware"]:::backend
        BE_Models["Data Models (Mongoose Schemas)"]:::backend
        BE_Tasks["Scheduled Tasks (node-cron)"]:::backend
    end

    DB["Database (MongoDB)"]:::database

    %% Frontend internal relationships
    FE -->|"contains"| FE_Pages
    FE -->|"contains"| FE_Components
    FE -->|"contains"| FE_Hooks
    FE -->|"contains"| FE_Context
    FE_Pages -->|"renders"| FE_Components
    FE_Components -->|"uses"| FE_Hooks
    FE_Hooks -->|"updates"| FE_Context

    %% Interaction from Frontend to Backend
    FE_Components -->|"triggersAPICall"| BE_Controllers
    FE_Context -->|"suppliesState"| BE_Controllers

    %% Backend internal flow
    BE -->|"routesRequestTo"| BE_Controllers
    BE_Controllers -->|"invokes"| BE_Middleware
    BE_Controllers -->|"queries"| BE_Models
    BE_Models -->|"persistsTo"| DB
    BE_Controllers -->|"utilizes"| BE_Config
    BE_Config -->|"configures"| BE_Controllers
    BE_Tasks -->|"executesJobsOn"| BE_Controllers

    %% Click Events for Frontend Components
    click FE "https://github.com/chahatkesh/webmark/tree/main/client"
    click FE_Pages "https://github.com/chahatkesh/webmark/tree/main/client/src/pages"
    click FE_Components "https://github.com/chahatkesh/webmark/tree/main/client/src/components"
    click FE_Hooks "https://github.com/chahatkesh/webmark/tree/main/client/src/hooks"
    click FE_Context "https://github.com/chahatkesh/webmark/blob/main/client/src/context/StoreContext.jsx"

    %% Click Events for Backend Components
    click BE "https://github.com/chahatkesh/webmark/tree/main/server"
    click BE_Config "https://github.com/chahatkesh/webmark/tree/main/server/config"
    click BE_Controllers "https://github.com/chahatkesh/webmark/tree/main/server/controllers"
    click BE_Middleware "https://github.com/chahatkesh/webmark/blob/main/server/middleware/authmiddleware.js"
    click BE_Models "https://github.com/chahatkesh/webmark/tree/main/server/models"
    click BE_Tasks "https://github.com/chahatkesh/webmark/blob/main/server/utils/cronJobs.js"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#F4A460,stroke:#000,stroke-width:2px;
```
