# annibadakh/notes_taking_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/annibadakh/notes_taking_frontend
- Repository: https://github.com/annibadakh/notes_taking_frontend

## Overview

##### Project Type & Purpose
- This is a full-stack web application:
– Frontend: React single-page app (Vite, Tailwind CSS)
– Backend: Node.js + Express API server
– Database: MySQL via Sequelize ORM
– External services: Google OAuth, email (Nodemailer)
- Purpose: user-authenticated note creation, editing, organizing with rich-text, auto-save, pin/archive, pagination.

##### File Structure (Frontend)
- Top-level files:
– index.html, vite.config.js: build & serve frontend
– src/main.jsx: React app bootstrap
– src/Api.jsx: centralized HTTP client for API calls
– src/Context/AuthContext.jsx: global auth state, JWT storage
– src/ProtectedRoute.jsx: route guard for private pages
- Pages folder: HomePage, Login, Signup, Dashboard, NoteEditor, NoteViewer
- Utils: toast notifications
- Public: static assets & redirect rules

##### README for Backend & Architecture Insights
- Backend repo (separate) provides:
– Express.js REST endpoints for auth & note CRUD
– JWT issuance & verification middleware
– Bcrypt hashing, Sequelize models, MySQL schema
– Nodemailer for email OTP delivery
– Google OAuth endpoints

##### Main Components & Interactions
a. Client Layer (Browser / Mobile)
– React SPA hosted on Netlify (or similar)
– Sends HTTP/HTTPS requests to API (JWT in headers)
b. CDN / Static Hosting
– Serves index.html, JavaScript bundles, CSS, assets
c. Frontend Application
– UI Components (Pages, Editor, Dashboard)
– AuthContext for user state & token
– Api.jsx handles fetch/axios calls
d. Backend API Server
– Express.js routes: /auth (login/signup/otp), /notes (CRUD)
– Middleware: JWT verification, input validation
– OAuth controller for Google sign-in
– Email controller for OTP via Nodemailer
e. Database Layer
– MySQL database (notes_app)
– Sequelize models: User, Note, OTP, etc.
f. External Services
– Google OAuth provider
– SMTP/email service for OTP
g. Developer Tools / CI/CD (optional)
– GitHub for code, CI pipelines, Heroku/DigitalOcean for backend, Netlify/Vercel for frontend

##### Relationships & Data Flows
- User → Frontend: browser loads JS, user interacts
- Frontend → API:
– Auth flows: signup/login → receive JWT
– Note CRUD: include JWT in Authorization header
- API → Database: Sequelize queries for user & note data
- API → External Services:
– Google OAuth token exchange & profile fetch
– Nodemailer SMTP requests for OTP emails
- Database → API → Frontend: data responses as JSON

##### Architectural Patterns & Design Principles
- Single-Page Application (SPA) architecture on frontend
- Context API for global state (AuthContext)
- Protected routes for access control
- RESTful API on backend with stateless JWT auth
- Layered architecture: Presentation → Business → Data
- ORM abstraction (Sequelize) for database interactions
- Externalize configuration via environment variables

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client/Browser Zone
    subgraph "Client / Browser" 
        U["User"]:::external
    end

    %% CDN / Hosting Zone
    subgraph "CDN / Static Hosting" 
        CDN["CDN / Netlify / Vercel"]:::infra
        PUB["public/"]:::frontend
        RED["_redirects"]:::frontend
    end

    %% Frontend Application Layer
    subgraph "Frontend Application" 
        direction TB
        HTML["index.html"]:::frontend
        VITE["vite.config.js"]:::frontend
        MAIN["src/main.jsx"]:::frontend
        STYLES["src/index.css & src/App.css"]:::frontend
        APP["src/App.jsx"]:::frontend
        API_CLIENT["src/Api.jsx"]:::frontend
        AUTH_CTX["src/Context/AuthContext.jsx"]:::frontend
        PROT_ROUTE["src/ProtectedRoute.jsx"]:::frontend
        TOAST["src/Utils/toast.jsx"]:::frontend
        ASSETS["src/Assets"]:::frontend
        subgraph "Pages" 
            direction TB
            HOME["src/Pages/HomePage.jsx"]:::frontend
            DASH["src/Pages/Dashboard.jsx"]:::frontend
            LOGIN["src/Pages/Login.jsx"]:::frontend
            SIGNUP["src/Pages/Signup.jsx"]:::frontend
            EDITOR["src/Pages/NoteEditor.jsx"]:::frontend
            VIEWER["src/Pages/NoteViewer.jsx"]:::frontend
        end
    end

    %% Backend Application Layer
    subgraph "Backend API Server" 
        direction TB
        EXPRESS["Express.js Server"]:::backend
        subgraph "Auth & Note Routes"
            AUTH_ROUTE["/auth Routes"]:::backend
            NOTE_ROUTE["/notes Routes"]:::backend
        end
        JWT_MW["JWT Verification Middleware"]:::backend
        VAL_MW["Input Validation Middleware"]:::backend
        OAUTH_CTRL["Google OAuth Controller"]:::backend
        EMAIL_CTRL["Email (Nodemailer) Controller"]:::backend
    end

    %% Database & External Services
    subgraph "Database & External" 
        direction TB
        DB["MySQL (notes_app)"]:::database
        MODELS["Sequelize Models"]:::database
        GOOG["Google OAuth Provider"]:::external
        SMTP["SMTP / Email Service"]:::external
    end

    %% Infrastructure & Dev Tools
    subgraph "Configuration & Dev Tools"
        ENV[".env"]:::infra
        PKG["package.json & package-lock.json"]:::infra
        GITIGNORE[".gitignore"]:::infra
        ESLINT["eslint.config.js"]:::infra
    end

    %% Connections
    U -->|"browses"| CDN
    CDN -->|serves| HTML
    HTML --> VITE
    HTML --> MAIN
    MAIN -->|renders| APP
    APP -->|uses| STYLES
    APP -->|wraps| AUTH_CTX
    APP -->|guards| PROT_ROUTE
    APP -->|routes to| HOME
    APP --> DASH
    APP --> LOGIN
    APP --> SIGNUP
    APP --> EDITOR
    APP --> VIEWER
    APP --> API_CLIENT
    API_CLIENT -->|HTTPS/JSON, JWT| EXPRESS
    AUTH_CTX --> API_CLIENT
    PROT_ROUTE -->|checks| AUTH_CTX
    EDITOR --> TOAST
    VIEWER --> TOAST
    APP --> ASSETS

    EXPRESS --> AUTH_ROUTE
    EXPRESS --> NOTE_ROUTE
    AUTH_ROUTE --> JWT_MW
    NOTE_ROUTE --> JWT_MW
    AUTH_ROUTE -->|calls| OAUTH_CTRL
    AUTH_ROUTE -->|calls| EMAIL_CTRL
    AUTH_ROUTE --> MODELS
    NOTE_ROUTE --> MODELS
    MODELS --> DB
    EXPRESS --> VAL_MW

    OAUTH_CTRL --> GOOG
    EMAIL_CTRL --> SMTP

    %% Config Tool Links
    PUB -->|"public/"| public/
    RED -->|"_redirects"| public/_redirects
    click HTML "https://github.com/annibadakh/notes_taking_frontend/blob/main/index.html"
    click VITE "https://github.com/annibadakh/notes_taking_frontend/blob/main/vite.config.js"
    click MAIN "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/main.jsx"
    click STYLES "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/index.css"
    click APP "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/App.jsx"
    click API_CLIENT "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Api.jsx"
    click AUTH_CTX "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Context/AuthContext.jsx"
    click PROT_ROUTE "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/ProtectedRoute.jsx"
    click TOAST "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Utils/toast.jsx"
    click ASSETS "https://github.com/annibadakh/notes_taking_frontend/tree/main/src/Assets"
    click HOME "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/HomePage.jsx"
    click DASH "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/Dashboard.jsx"
    click LOGIN "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/Login.jsx"
    click SIGNUP "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/Signup.jsx"
    click EDITOR "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/NoteEditor.jsx"
    click VIEWER "https://github.com/annibadakh/notes_taking_frontend/blob/main/src/Pages/NoteViewer.jsx"
    click PUB "https://github.com/annibadakh/notes_taking_frontend/tree/main/public/"
    click RED "https://github.com/annibadakh/notes_taking_frontend/tree/main/public/_redirects"
    click ENV "https://github.com/annibadakh/notes_taking_frontend/blob/main/.env"
    click PKG "https://github.com/annibadakh/notes_taking_frontend/blob/main/package.json"
    click GITIGNORE "https://github.com/annibadakh/notes_taking_frontend/blob/main/.gitignore"
    click ESLINT "https://github.com/annibadakh/notes_taking_frontend/blob/main/eslint.config.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#FFD580,stroke:#000,stroke-width:1px
    classDef database fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef infra fill:#E6E6FA,stroke:#000,stroke-width:1px
```
