# kayamuhammet/simplenotesapp architecture

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

- Interactive diagram: https://gitdiagram.com/kayamuhammet/simplenotesapp
- Repository: https://github.com/kayamuhammet/simplenotesapp

## Overview

##### Project type and purpose
- This is a monolithic, full-stack web application built on ASP.NET Core MVC (C#).
- Purpose: provide a user-friendly note-taking and management system with features such as authentication, categorization, favorites, PDF export, email verification, password reset, localization, and responsive UI.

##### File structure
- Top-level folders and roles:
- Controllers: handle incoming HTTP requests (Account, Auth, Category, Notes, Home, Error, SharedResource)
- Views & ViewModels: Razor pages and strongly-typed view models for rendering HTML
- Models: domain/entities (User, Note, Category, AuthResponse, error models, etc.)
- Services & Interfaces: business logic layer (IEmailService + EmailService)
- Data: EF Core DbContext (AppDbContext) for database access
- Resources: .resx localization files for Turkish/English
- wwwroot: static assets (CSS, JS)
- Program.cs & appsettings.json: host & middleware configuration, DI setup, connection strings, JWT & SMTP settings

##### README insights
- Architecture patterns: Layered (Presentation → Business/Services → Data) + MVC
- Tech stack: ASP.NET Core MVC 7.0, EF Core, SQLite, Identity + JWT, SMTP email, Localization, Bootstrap 5

##### Main components and relationships
A. Client / Presentation
- Browser (HTML/CSS/JS) ←→ ASP.NET Core MVC (Controllers → Views + ViewModels)
- Static file server (wwwroot) delivers CSS/JS assets to the browser.
B. Application / Business
- Controllers inject Services (EmailService, IdentityManager, PDF generator)
- Localization middleware reads .resx Resources → Controllers via IStringLocalizer
- Authentication & Authorization via ASP.NET Identity + JWT
C. Data / Persistence
- Services & Controllers call AppDbContext (EF Core) → SQLite database
- Entities in Models map to tables (Users, Notes, Categories, etc.)
D. External services
- SMTP server for email verification & password reset
- (Optional) PDF engine library (internal or third-party NuGet)

Interaction flow example (User registration):
1. Browser → POST /Account/Register with form data
2. AccountController validates ViewModel → creates ApplicationUser via UserManager
3. Generates email token → EmailService.SendAsync(token) → SMTP
4. Controller returns confirmation view

##### Architectural patterns and principles
- Layered Architecture: clear separation Presentation → Business → Data
- MVC pattern: Controllers + Models + Views
- Dependency Injection: services, DbContext, localization, email, JWT configured in Program.cs
- Convention-based routing & folder structure of ASP.NET Core MVC
- Use of EF Core migration / Code-First approach

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: Client
    subgraph "Layer 1: Client" 
        direction TB
        Browser["Browser (HTML/CSS/JS)"]:::frontend
        StaticFiles["Static Files (CSS/JS)"]:::frontend
    end

    Browser -->|"Request HTML"| HomeController
    Browser -->|"Request Static Assets"| StaticFiles

    %% Layer 2: Web Server
    subgraph "Layer 2: Web Server (ASP.NET Core MVC)"
        direction TB
        MW["Middleware Pipeline\n(Localization, Authentication, Routing)"]:::config
        MW --> ControllersGroup
        MW --> ViewsGroup
        MW --> ViewModelsGroup
        AppConfig["Program.cs\nappsettings.json"]:::config
    end

    %% Controllers
    subgraph "Controllers" 
        direction TB
        AccountController["AccountController"]:::frontend
        AuthController["AuthController"]:::frontend
        CategoryController["CategoryController"]:::frontend
        NotesController["NotesController"]:::frontend
        HomeController["HomeController"]:::frontend
        ErrorController["ErrorController"]:::frontend
        SharedResourceController["SharedResourceController"]:::frontend
    end
    ControllersGroup --> AccountController
    ControllersGroup --> AuthController
    ControllersGroup --> CategoryController
    ControllersGroup --> NotesController
    ControllersGroup --> HomeController
    ControllersGroup --> ErrorController
    ControllersGroup --> SharedResourceController

    %% Views
    subgraph "Views (Razor)" 
        direction TB
        ViewsAccount["Views/Account"]:::frontend
        ViewsCategory["Views/Category"]:::frontend
        ViewsNotes["Views/Notes"]:::frontend
        ViewsHome["Views/Home"]:::frontend
        ViewsShared["Views/Shared"]:::frontend
        ViewImports["_ViewImports.cshtml"]:::frontend
        ViewStart["_ViewStart.cshtml"]:::frontend
    end
    ViewsGroup --> ViewsAccount
    ViewsGroup --> ViewsCategory
    ViewsGroup --> ViewsNotes
    ViewsGroup --> ViewsHome
    ViewsGroup --> ViewsShared
    ViewsGroup --> ViewImports
    ViewsGroup --> ViewStart

    %% ViewModels
    subgraph "ViewModels" 
        direction TB
        RegisterVM["RegisterViewModel"]:::frontend
        LoginVM["LoginViewModel"]:::frontend
        ForgotVM["ForgotPasswordViewModel"]:::frontend
        ResetVM["ResetPasswordViewModel"]:::frontend
    end
    ViewModelsGroup --> RegisterVM
    ViewModelsGroup --> LoginVM
    ViewModelsGroup --> ForgotVM
    ViewModelsGroup --> ResetVM

    %% Layer 3: Business / Service Layer
    subgraph "Layer 3: Business / Service Layer" 
        direction TB
        IEmailService["IEmailService"]:::service
        EmailService["EmailService"]:::service
        IdentityManager["ASP.NET Identity"]:::service
        PDFGenerator["PDF Generator"]:::service
    end

    AccountController -->|Injects| IEmailService
    AuthController -->|Injects| IEmailService
    CategoryController -->|Injects| IdentityManager
    NotesController -->|Injects| PDFGenerator
    NotesController -->|Injects| IdentityManager
    IEmailService --> EmailService

    %% Layer 4: Data Layer
    subgraph "Layer 4: Data Layer" 
        direction TB
        AppDbContext["AppDbContext"]:::data
        SQLiteDB["SQLite Database"]:::data
    end

    EmailService --> AppDbContext
    IdentityManager --> AppDbContext
    PDFGenerator --> AppDbContext
    AppDbContext --> SQLiteDB

    %% Layer 5: External Services
    subgraph "Layer 5: External Services"
        direction TB
        SMTP["SMTP Server"]:::external
    end

    EmailService -->|Send Email| SMTP

    %% Click Events
    click AccountController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/AccountController.cs"
    click AuthController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/AuthController.cs"
    click CategoryController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/CategoryController.cs"
    click NotesController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/NotesController.cs"
    click HomeController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/HomeController.cs"
    click ErrorController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/ErrorController.cs"
    click SharedResourceController "https://github.com/kayamuhammet/simplenotesapp/blob/main/Controllers/SharedResourceController.cs"
    click ViewsAccount "https://github.com/kayamuhammet/simplenotesapp/tree/main/Views/Account"
    click ViewsCategory "https://github.com/kayamuhammet/simplenotesapp/tree/main/Views/Category"
    click ViewsNotes "https://github.com/kayamuhammet/simplenotesapp/tree/main/Views/Notes"
    click ViewsHome "https://github.com/kayamuhammet/simplenotesapp/blob/main/Views/Home/Index.cshtml"
    click ViewsShared "https://github.com/kayamuhammet/simplenotesapp/tree/main/Views/Shared"
    click ViewImports "https://github.com/kayamuhammet/simplenotesapp/blob/main/Views/_ViewImports.cshtml"
    click ViewStart "https://github.com/kayamuhammet/simplenotesapp/blob/main/Views/_ViewStart.cshtml"
    click RegisterVM "https://github.com/kayamuhammet/simplenotesapp/blob/main/ViewModels/RegisterViewModel.cs"
    click LoginVM "https://github.com/kayamuhammet/simplenotesapp/blob/main/ViewModels/LoginViewModel.cs"
    click ForgotVM "https://github.com/kayamuhammet/simplenotesapp/blob/main/ViewModels/ForgotPasswordViewModel.cs"
    click ResetVM "https://github.com/kayamuhammet/simplenotesapp/blob/main/ViewModels/ResetPasswordViewModel.cs"
    click AppDbContext "https://github.com/kayamuhammet/simplenotesapp/blob/main/Data/AppDbContext.cs"
    click IEmailService "https://github.com/kayamuhammet/simplenotesapp/blob/main/Services/Interfaces/IEmailService.cs"
    click EmailService "https://github.com/kayamuhammet/simplenotesapp/blob/main/Services/EmailService.cs"
    click AppConfig "https://github.com/kayamuhammet/simplenotesapp/blob/main/Program.cs"
    click AppConfig "https://github.com/kayamuhammet/simplenotesapp/blob/main/appsettings.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef service fill:#d4edda,stroke:#155724,color:#155724;
    classDef data fill:#fff3cd,stroke:#856404,color:#856404;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef config stroke-dasharray: 5 5,fill:#f8f9fa,stroke:#343a40,color:#343a40;
```
