# soumya813/notes-app architecture

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

- Interactive diagram: https://gitdiagram.com/soumya813/notes-app
- Repository: https://github.com/soumya813/notes-app

## Overview

##### Project type and purpose
- From the file tree and README (“# Notes-App”), this is a full-stack, server-rendered web application built in Node.js/Express with EJS templates. It implements a simple notes management system with user authentication, CRUD operations for notes, and static asset serving.

##### File structure
- Top-level:
- app.js – the Express application entry point
- package.json / package-lock.json – dependencies and scripts
- public/ – static assets (CSS, images)
- views/ – EJS template files (layouts, partials, page views)
- server/ – all back-end code organized by concern
– config/db.js – database connection (likely MongoDB via Mongoose)
– controllers/ – business logic for routes (dashboardController, mainController)
– middleware/checkAuth.js – authentication gating
– models/ – data schemas (Notes.js, User.js)
– routes/ – Express route definitions (auth, dashboard, index)

##### README for additional insights
- The README only gives the project name. We infer from the file structure that it uses:
- Node.js + Express
- EJS for server-side rendering
- A NoSQL database (MongoDB) via a config file
- MVC-inspired organization

##### Putting it all together
- In the center, stack the Express layers vertically:
1) Static Middleware → 2) Router → 3) Middleware (Auth) → 4) Controller → 5) Model
- Sample flows: “User logs in → /auth POST → auth route → controller → User model → DB”
- Keep component names verbatim from code (e.g., “server/routes/dashboard.js”)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client and Static Assets
    Browser["Web Browser/UI"]:::ui
    StaticAssets["Static Assets"]:::static
    Browser -->|"Request CSS/Images"| StaticAssets
    StaticAssets -->|"Served by express.static"| ExpressStatic["Express Static Middleware"]:::server

    %% Express Application Layers
    subgraph "Express Application" 
        direction TB
        RouterLayer["Express Router"]:::server
        Middleware["checkAuth Middleware"]:::middleware
        ControllerMain["mainController"]:::server
        ControllerDash["dashboardController"]:::server
        ModelUser["User Model"]:::data
        ModelNotes["Notes Model"]:::data
    end

    %% Views
    subgraph "Views (EJS Templates)" 
        direction TB
        LayoutFront["front-page.ejs"]:::views
        LayoutMain["main.ejs"]:::views
        LayoutDashboard["dashboard.ejs"]:::views
        IndexPage["index.ejs"]:::views
        AboutPage["about.ejs"]:::views
        NotFoundPage["404.ejs"]:::views
        subgraph "Dashboard Views"
            direction TB
            AddNote["add.ejs"]:::views
            ListNotes["index.ejs"]:::views
            SearchResults["search.ejs"]:::views
            ViewNote["view-notes.ejs"]:::views
        end
        subgraph "Partials"
            direction TB
            Header["header.ejs"]:::views
            Footer["footer.ejs"]:::views
            HeaderDash["header_dashboard.ejs"]:::views
        end
    end

    %% Database
    MongoDB["MongoDB"]:::db

    %% Connections
    StaticAssets --> RouterLayer
    Browser -->|"HTTP Request (GET/POST)"| RouterLayer
    RouterLayer -->|"auth routes"| ControllerMain
    RouterLayer -->|"index routes"| ControllerMain
    RouterLayer -->|"dashboard routes"| Middleware
    Middleware --> ControllerDash
    ControllerMain -->|"read/write"| ModelUser
    ControllerDash -->|"read/write"| ModelNotes
    ModelUser --> MongoDB
    ModelNotes --> MongoDB
    ControllerMain --> Views
    ControllerDash --> Views

    %% Click Events
    click app.js "https://github.com/soumya813/notes-app/blob/main/app.js"
    click ExpressStatic "https://github.com/soumya813/notes-app/blob/main/app.js"
    click RouterLayer "https://github.com/soumya813/notes-app/blob/main/server/routes/index.js"
    click RouterLayer "https://github.com/soumya813/notes-app/blob/main/server/routes/auth.js"
    click RouterLayer "https://github.com/soumya813/notes-app/blob/main/server/routes/dashboard.js"
    click Middleware "https://github.com/soumya813/notes-app/blob/main/server/middleware/checkAuth.js"
    click ControllerMain "https://github.com/soumya813/notes-app/blob/main/server/controllers/mainController.js"
    click ControllerDash "https://github.com/soumya813/notes-app/blob/main/server/controllers/dashboardController.js"
    click ModelUser "https://github.com/soumya813/notes-app/blob/main/server/models/User.js"
    click ModelNotes "https://github.com/soumya813/notes-app/blob/main/server/models/Notes.js"
    click StaticAssets "https://github.com/soumya813/notes-app/blob/main/public/css/main.css"
    click StaticAssets "https://github.com/soumya813/notes-app/tree/main/public/img/"
    click LayoutFront "https://github.com/soumya813/notes-app/blob/main/views/layouts/front-page.ejs"
    click LayoutDashboard "https://github.com/soumya813/notes-app/blob/main/views/layouts/dashboard.ejs"
    click LayoutMain "https://github.com/soumya813/notes-app/blob/main/views/layouts/main.ejs"
    click IndexPage "https://github.com/soumya813/notes-app/blob/main/views/index.ejs"
    click NotFoundPage "https://github.com/soumya813/notes-app/blob/main/views/404.ejs"
    click AboutPage "https://github.com/soumya813/notes-app/blob/main/views/about.ejs"
    click AddNote "https://github.com/soumya813/notes-app/blob/main/views/dashboard/add.ejs"
    click ListNotes "https://github.com/soumya813/notes-app/blob/main/views/dashboard/index.ejs"
    click SearchResults "https://github.com/soumya813/notes-app/blob/main/views/dashboard/search.ejs"
    click ViewNote "https://github.com/soumya813/notes-app/blob/main/views/dashboard/view-notes.ejs"
    click Header "https://github.com/soumya813/notes-app/blob/main/views/partials/header.ejs"
    click Footer "https://github.com/soumya813/notes-app/blob/main/views/partials/footer.ejs"
    click HeaderDash "https://github.com/soumya813/notes-app/blob/main/views/partials/header_dashboard.ejs"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#3B78FF,color:#000
    classDef static fill:#E8D0FF,stroke:#A35BFF,color:#000
    classDef server fill:#D0FFD6,stroke:#27A544,color:#000
    classDef middleware fill:#FFF4D6,stroke:#E1B800,color:#000,stroke-dasharray: 5 5
    classDef data fill:#FFE5D0,stroke:#FF8A00,color:#000
    classDef db fill:#FFE0B2,stroke:#FF6F00,color:#000,shape:cylinder
    classDef views fill:#F0F0F0,stroke:#999999,color:#000
```
