# junkin3/webnews architecture

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

- Interactive diagram: https://gitdiagram.com/junkin3/webnews
- Repository: https://github.com/junkin3/webnews

## Overview

##### Project Type and Purpose
- This is a full-stack ASP.NET WebForms application (“WebNews”) for publishing and managing news articles.
- The UI is delivered via .aspx pages (e.g., Default.aspx, DangTin.aspx) with C# code-behind, static assets (CSS, JS, SCSS) and client plugins (owlCarousel, easing).
- Data is stored in a SQL Server Express MDF file under App_Data. External integrations include SendGrid for email and BCrypt.Net for password hashing.

##### File-Structure Insights
- Top-level presentation layer:
- .aspx/.aspx.cs pages
- css/ (compiled CSS from SCSS)
- js/ (custom JS)
- lib/ (third-party client libraries: owlCarousel, easing)
- scss/ (Bootstrap source + custom styles)
- Backend & configuration:
- Web.config, website.publishproj, PublishProfiles (FTP/Web Deploy)
- Bin/ (compiled DLLs & XML docs for SendGrid, BCrypt.Net, JSON, MVC artifacts)
- packages/ (NuGet packages for MVC, Razor, Roslyn, SendGrid, BCrypt, NewtonSoft.Json)
- Data layer:
- App_Data/Database.mdf & SQL scripts (dbo.Tin.data.sql)
- Solution file: WebNews.sln

##### Key Components
a. Client Browser
- Requests pages, loads static assets, invokes JS plugins.
b. Web Server (IIS) Hosting ASP.NET WebForms
- ASP.NET runtime processes .aspx, invokes C# code-behind.
- MVC assemblies are present but not actively used (no Controllers folder).
c. Business Logic Layer
- Code-behind methods handle authentication (DangNhap.aspx.cs), registration (Dangki.aspx.cs), article CRUD (DangTin.aspx.cs, ChinhSuaTin.aspx.cs), search (TimKiem.aspx.cs).
- Utilities: BCrypt.Net for hashing, SendGrid API for confirmation emails (ConfirmReg.aspx.cs).
d. Data Access Layer
- ADO.NET or built-in SQL client connecting to Database.mdf via connection string in Web.config.
- SQL scripts for schema and initial data.
e. Database
- SQL Server Express MDF in App_Data. Contains Tin (news) table.
f. External Services
- SendGrid REST API for transactional emails.
- Potential file storage for images (referenced via Tin_addImage.data.sql).

##### Relationships & Data Flow
- Within ASP.NET: Presentation → calls Business Logic (code-behind) → Data Access → SQL Server
- Code-behind may call SendGrid API asynchronously → External Email Service → Client receives confirmation.
- Static assets (CSS/JS) served directly by IIS → Client browser renders UI.

##### Architectural Patterns & Principles
- 3-Tier architecture (Presentation / Business Logic / Data)
- Separation of concerns:
- UI components (.aspx) vs. server logic (.cs) vs. database
- Security: password hashing (BCrypt), email verification (SendGrid)
- Plug-in architecture on the frontend (owlCarousel, easing)

##### Essential Elements Checklist
- Callouts for major NuGet packages (SendGrid, BCrypt, MVC assemblies)
- Notes on deployment profiles (FTP/Web Deploy) if relevant

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["Web Browser"]:::presentation
        StaticCSS["Static Assets (CSS)"]:::presentation
        StaticJS["Static Assets (JavaScript)"]:::presentation
        PluginOwl["owlCarousel Plugin"]:::presentation
        PluginEasing["easing Plugin"]:::presentation
        subgraph "ASP.NET WebForms Pages"
            direction TB
            Default["Default.aspx + Default.aspx.cs"]:::presentation
            DangTin["DangTin.aspx + DangTin.aspx.cs"]:::presentation
            DangNhap["DangNhap.aspx + DangNhap.aspx.cs"]:::presentation
            Dangki["Dangki.aspx + Dangki.aspx.cs"]:::presentation
            ChinhSuaTin["ChinhSuaTin.aspx + ChinhSuaTin.aspx.cs"]:::presentation
            TimKiem["Timkiem.aspx + Timkiem.aspx.cs"]:::presentation
            ConfirmReg["ConfirmReg.aspx + ConfirmReg.aspx.cs"]:::presentation
            DoiMatKhau["DoiMatKhau.aspx + DoiMatKhau.aspx.cs"]:::presentation
            ChinhSuaThongTin["ChinhSuaThongTin.aspx + ChinhSuaThongTin.aspx.cs"]:::presentation
            Single["Single.aspx + Single.aspx.cs"]:::presentation
            Admin["admin.aspx + admin.aspx.cs"]:::presentation
            Test["test.aspx + test.aspx.cs"]:::presentation
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer" 
        direction TB
        CodeBehind["C# Code-Behind Handlers & Utilities\n(BCrypt.Net, SendGrid API)"]:::logic
    end

    %% Data Access & Storage Layer
    subgraph "Data Layer"
        direction TB
        DatabaseMDF["SQL Server Express\nDatabase.mdf"]:::data
        SQLScripts["SQL Scripts\ndbo.Tin.data.sql\nTin_addImage.data.sql"]:::data
        DBLog["Database Log (ldf)"]:::data
    end

    %% Configuration & Deployment
    subgraph "Configuration & Deployment"
        direction TB
        WebConfig["Web.config"]:::config
        PublishProj["website.publishproj"]:::config
        PublishProfiles["App_Data/PublishProfiles"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SendGrid["SendGrid REST API"]:::external
        BCrypt["BCrypt.Net Library"]:::external
        Newtonsoft["Newtonsoft.Json"]:::external
        MVCArtifacts[".NET MVC & Razor Assemblies"]:::external
    end

    %% Connections
    Browser -->|"HTTP Request"| IIS["IIS + ASP.NET WebForms"]:::presentation
    IIS -->|"Loads .aspx, invokes code-behind"| CodeBehind
    CodeBehind -->|"ADO.NET"| DatabaseMDF
    CodeBehind -->|"ADO.NET"| SQLScripts
    CodeBehind -->|"HTTPS"| SendGrid
    StaticCSS -->|served by IIS| Browser
    StaticJS -->|served by IIS| Browser
    PluginOwl -->|served by IIS| Browser
    PluginEasing -->|served by IIS| Browser
    IIS -->|"Reads config"| WebConfig
    IIS -->|"Deployment Profiles"| PublishProj
    IIS -->|"Deployment Profiles"| PublishProfiles

    %% Click Events
    click StaticCSS "https://github.com/junkin3/webnews/blob/master/css/Style.css"
    click StaticJS "https://github.com/junkin3/webnews/blob/master/js/main.js"
    click PluginOwl "https://github.com/junkin3/webnews/tree/master/lib/owlcarousel/"
    click PluginEasing "https://github.com/junkin3/webnews/blob/master/lib/easing/easing.js"
    click Default "https://github.com/junkin3/webnews/blob/master/Default.aspx"
    click DangTin "https://github.com/junkin3/webnews/blob/master/DangTin.aspx"
    click DangNhap "https://github.com/junkin3/webnews/blob/master/DangNhap.aspx"
    click Dangki "https://github.com/junkin3/webnews/blob/master/Dangki.aspx"
    click ChinhSuaTin "https://github.com/junkin3/webnews/blob/master/ChinhSuaTin.aspx"
    click TimKiem "https://github.com/junkin3/webnews/blob/master/Timkiem.aspx"
    click ConfirmReg "https://github.com/junkin3/webnews/blob/master/ConfirmReg.aspx"
    click DoiMatKhau "https://github.com/junkin3/webnews/blob/master/DoiMatKhau.aspx"
    click ChinhSuaThongTin "https://github.com/junkin3/webnews/blob/master/ChinhSuaThongTin.aspx"
    click Single "https://github.com/junkin3/webnews/blob/master/Single.aspx"
    click Admin "https://github.com/junkin3/webnews/blob/master/admin.aspx"
    click Test "https://github.com/junkin3/webnews/blob/master/test.aspx"
    click WebConfig "https://github.com/junkin3/webnews/blob/master/Web.config"
    click PublishProj "https://github.com/junkin3/webnews/blob/master/website.publishproj"
    click PublishProfiles "https://github.com/junkin3/webnews/tree/master/App_Data/PublishProfiles/"
    click DatabaseMDF "https://github.com/junkin3/webnews/blob/master/App_Data/Database.mdf"
    click SQLScripts "https://github.com/junkin3/webnews/blob/master/dbo.Tin.data.sql"
    click DBLog "https://github.com/junkin3/webnews/blob/master/App_Data/Database_log.ldf"
    click SendGrid "https://github.com/junkin3/webnews/blob/master/Bin/SendGrid.pdb"
    click BCrypt "https://github.com/junkin3/webnews/blob/master/Bin/BCrypt.Net.xml"
    click Newtonsoft "https://github.com/junkin3/webnews/blob/master/Bin/Newtonsoft.Json.xml"
    click MVCArtifacts "https://github.com/junkin3/webnews/blob/master/Bin/System.Web.Mvc.xml"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef logic fill:#DFFFE0,stroke:#28A745,color:#28A745;
    classDef data fill:#FFF4E5,stroke:#DD6B20,color:#DD6B20;
    classDef external fill:#F3E8FF,stroke:#6F42C1,color:#6F42C1;
    classDef config fill:#E5F6FF,stroke:#17A2B8,color:#17A2B8;
```
