# rawanmohameedd/notes_app architecture

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

- Interactive diagram: https://gitdiagram.com/rawanmohameedd/notes_app
- Repository: https://github.com/rawanmohameedd/notes_app

## Overview

##### Project type and purpose
- This is a full-stack, web-based Notes App.
- Frontend: React + TypeScript (Vite, Tailwind CSS, React Context, react-beautiful-dnd).
- Backend: Node.js + Express + TypeScript, JWT authentication, file-based JSON storage.

##### File structure
- Top-level: two folders, `frontend` and `backend`.
- Frontend substructure:
- `src/pages` for route views (LoginPage, NotesPage, RegisterPage)
- `src/components` for UI widgets (Form, Navbar, NoteCard)
- `src/auth` for React Context & routing guard (AuthContext, PrivateRoute, useAuth)
- `src/services/apis.ts` encapsulates HTTP calls to backend.
- Backend substructure:
- `src/routers` for route definitions (`auth.ts`, `notes.ts`)
- `src/middleware/auth.ts` for JWT verification
- `src/storage.ts` for read/write JSON files (`notes.json`, `users.json`)
- `src/data` holds actual JSON files.
- Notice MVC-like layering: routers → controllers → storage, plus middleware.

##### README for technical stack & architecture notes
- Confirms JWT‐based authentication, file‐based storage, React Context for state, drag-and-drop library, Tailwind CSS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Subgraph: Frontend
    subgraph "Frontend (React SPA)"
        direction TB
        SPA["Frontend SPA"]:::frontend
        LoginPage["LoginPage.tsx"]:::frontend
        RegisterPage["RegisterPage.tsx"]:::frontend
        NotesPage["NotesPage.tsx"]:::frontend
        FormComp["Form.tsx"]:::frontend
        NavbarComp["Navbar.tsx"]:::frontend
        NoteCardComp["NoteCard.tsx"]:::frontend
        AuthContext["AuthContext.tsx"]:::frontend
        PrivateRoute["PrivateRoute.tsx"]:::frontend
        UseAuth["useAuth.ts"]:::frontend
        HTTPService["apis.ts"]:::frontend
    end

    %% Subgraph: Backend API Server
    subgraph "Express API Server"
        direction TB
        APIEntry["index.ts"]:::backend
        AuthRouter["auth.ts"]:::backend
        NotesRouter["notes.ts"]:::backend
        AuthMiddleware["auth.ts (middleware)"]:::backend
        AuthController["auth.ts (controller)"]:::backend
        NotesController["notes.ts (controller)"]:::backend
        StorageModule["storage.ts"]:::backend
        TypesDef["types.d.ts"]:::backend
        ExpressTypes["express/index.d.ts"]:::backend
    end

    %% Subgraph: Data Store
    subgraph "Data Store (JSON Files)"
        direction TB
        DataUsers["users.json"]:::storage
        DataNotes["notes.json"]:::storage
    end

    %% External Libraries
    ExternalLibs["External Libraries"]:::external
    ReactDnd["react-beautiful-dnd"]:::external
    Tailwind["Tailwind CSS"]:::external
    JWTLib["jsonwebtoken"]:::external
    ExpressLib["Express"]:::external

    %% Connections: Frontend flow
    SPA -->|uses| AuthContext
    SPA -->|uses| PrivateRoute
    LoginPage -->|renders| FormComp
    RegisterPage -->|renders| FormComp
    NotesPage -->|renders| NoteCardComp
    SPA -->|shows| NavbarComp
    AuthContext -->|provides| UseAuth
    LoginPage -->|calls| HTTPService
    RegisterPage -->|calls| HTTPService
    NotesPage -->|calls| HTTPService
    HTTPService -->|HTTP/JSON| APIEntry

    %% Connections: Backend flow
    APIEntry -->|mounts| AuthRouter
    APIEntry -->|mounts| NotesRouter
    AuthRouter -->|POST /login, POST /register| AuthController
    NotesRouter -->|GET/POST/PUT/DELETE /notes| AuthMiddleware
    NotesRouter -->|after auth| NotesController
    AuthController -->|CRUD users| StorageModule
    NotesController -->|CRUD notes| StorageModule
    StorageModule -->|reads/writes| DataUsers
    StorageModule -->|reads/writes| DataNotes

    %% Libs connections
    SPA -.-> ReactDnd
    SPA -.-> Tailwind
    APIEntry -.-> ExpressLib
    AuthMiddleware -.-> JWTLib

    %% Click Events
    click SPA "https://github.com/rawanmohameedd/notes_app/tree/main/frontend/src"
    click LoginPage "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/pages/LoginPage.tsx"
    click RegisterPage "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/pages/RegisterPage.tsx"
    click NotesPage "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/pages/NotesPage.tsx"
    click FormComp "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/components/Form.tsx"
    click NavbarComp "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/components/Navbar.tsx"
    click NoteCardComp "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/components/NoteCard.tsx"
    click AuthContext "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/auth/AuthContext.tsx"
    click PrivateRoute "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/auth/PrivateRoute.tsx"
    click UseAuth "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/auth/useAuth.ts"
    click HTTPService "https://github.com/rawanmohameedd/notes_app/blob/main/frontend/src/services/apis.ts"
    click APIEntry "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/index.ts"
    click AuthRouter "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/routers/auth.ts"
    click NotesRouter "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/routers/notes.ts"
    click AuthController "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/controllers/auth.ts"
    click NotesController "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/controllers/notes.ts"
    click AuthMiddleware "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/middleware/auth.ts"
    click StorageModule "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/storage.ts"
    click DataUsers "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/data/users.json"
    click DataNotes "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/data/notes.json"
    click TypesDef "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/types.d.ts"
    click ExpressTypes "https://github.com/rawanmohameedd/notes_app/blob/main/backend/src/types/express/index.d.ts"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#0366d6,color:#000
    classDef backend fill:#D4F4DD,stroke:#22863a,color:#000
    classDef storage fill:#FCE5CD,stroke:#d15704,color:#000
    classDef external fill:#EEEEEE,stroke-dasharray: 5 5,color:#333
```
