# mark0-22/personal-blog architecture

> Architecture diagram of the GitHub repository mark0-22/personal-blog, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mark0-22/personal-blog
- Repository: https://github.com/mark0-22/personal-blog

## Overview

##### Main System Components

a) Frontend Layer:
- Views (EJS Templates)
- Admin section
- Guest section
- Shared components (includes)
- Static Assets
- CSS files

b) Backend Layer (NestJS):
- Controllers
- Services
- Modules
- Middleware
- DTOs (Data Transfer Objects)
- Entities

##### Architectural Pattern Representation

a) Core Module Layer:
- AppModule (root module)
- ArticleModule (feature module)

b) MVC Pattern:
- Controllers (handling HTTP requests)
- Services (business logic)
- Views (EJS templates)

**┌─────────────────────────────────────────────────────────┐**
- Client Browser                      │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- NestJS Application                    │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- Views     │    │  Controllers │    │  Services   │ │
- (EJS)      │←───│             │←───│             │ │
- ┘    └─────────────┘    └─────────────┘ │
- ↑                 ↑                  ↑          │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- Static    │    │    DTOs     │    │  Entities   │ │
- Assets    │    │             │    │             │ │
- ┘    └─────────────┘    └─────────────┘ │
- ↑                             │
- ┌─────────────┐    ┌─────────────┐                    │
- Auth     │    │   Article   │                    │
- Middleware  │    │   Module    │                    │
- ┘    └─────────────┘                    │
- ┘

##### Component Relationships

- Client → Auth Middleware → Controllers
- Controllers ↔ Services
- Services ↔ Entities
- Controllers → Views
- Views → Static Assets

##### Notes for Implementation

- NestJS's modular architecture
- MVC pattern implementation
- Authentication flow
- Separation between admin and public access
- Template rendering with EJS
- Static file serving

This architecture represents a typical NestJS application with server-side rendering using EJS templates, following RESTful principles for article management, and implementing authentication for admin access.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Client Browser"]
    end

    subgraph NestJS["NestJS Application"]
        subgraph Frontend
            Views["Views (EJS)"]:::frontend
            AdminViews["Admin Views"]:::frontend
            GuestViews["Guest Views"]:::frontend
            SharedViews["Shared Components"]:::frontend
            StaticAssets["Static Assets"]:::frontend
            MainCSS["Main CSS"]:::frontend
            ArticleCSS["Article CSS"]:::frontend
        end

        subgraph Core
            Main["Main Entry"]:::core
            AppModule["App Module"]:::module
            ArticleModule["Article Module"]:::module
        end

        subgraph Controllers
            AppController["App Controller"]:::controller
            ArticleController["Article Controller"]:::controller
        end

        subgraph Services
            AppService["App Service"]:::service
            ArticleService["Article Service"]:::service
        end

        subgraph Data
            DTOs["DTOs"]:::data
            CreateArticleDTO["Create Article DTO"]:::data
            UpdateArticleDTO["Update Article DTO"]:::data
            FilesDTO["Files DTO"]:::data
            ArticleEntity["Article Entity"]:::data
        end

        AuthMiddleware["Auth Middleware"]:::security
    end

    %% Relationships
    Browser --> AuthMiddleware
    AuthMiddleware --> AppController
    AuthMiddleware --> ArticleController
    
    AppController --> AppService
    ArticleController --> ArticleService
    
    AppController --> Views
    ArticleController --> Views
    
    Views --> AdminViews
    Views --> GuestViews
    Views --> SharedViews
    Views --> StaticAssets
    
    StaticAssets --> MainCSS
    StaticAssets --> ArticleCSS
    
    ArticleController --> DTOs
    DTOs --> CreateArticleDTO
    DTOs --> UpdateArticleDTO
    DTOs --> FilesDTO
    
    ArticleService --> ArticleEntity

    %% Click Events
    click Views "https://github.com/Mark0-22/personal-blog/tree/master/src/views/"
    click AdminViews "https://github.com/Mark0-22/personal-blog/tree/master/src/views/admin/"
    click GuestViews "https://github.com/Mark0-22/personal-blog/tree/master/src/views/guest/"
    click SharedViews "https://github.com/Mark0-22/personal-blog/tree/master/src/views/includes/"
    click StaticAssets "https://github.com/Mark0-22/personal-blog/tree/master/src/public/css/"
    click MainCSS "https://github.com/Mark0-22/personal-blog/blob/master/src/public/css/main.css"
    click ArticleCSS "https://github.com/Mark0-22/personal-blog/blob/master/src/public/css/article.css"
    click AppController "https://github.com/Mark0-22/personal-blog/blob/master/src/app.controller.ts"
    click ArticleController "https://github.com/Mark0-22/personal-blog/blob/master/src/article/article.controller.ts"
    click AppService "https://github.com/Mark0-22/personal-blog/blob/master/src/app.service.ts"
    click ArticleService "https://github.com/Mark0-22/personal-blog/blob/master/src/article/article.service.ts"
    click AppModule "https://github.com/Mark0-22/personal-blog/blob/master/src/app.module.ts"
    click ArticleModule "https://github.com/Mark0-22/personal-blog/blob/master/src/article/article.module.ts"
    click AuthMiddleware "https://github.com/Mark0-22/personal-blog/blob/master/src/middleware/auth.middleware.ts"
    click CreateArticleDTO "https://github.com/Mark0-22/personal-blog/blob/master/src/article/dto/create-article.dto.ts"
    click UpdateArticleDTO "https://github.com/Mark0-22/personal-blog/blob/master/src/article/dto/update-article.dto.ts"
    click FilesDTO "https://github.com/Mark0-22/personal-blog/blob/master/src/dto/files.dto.ts"
    click ArticleEntity "https://github.com/Mark0-22/personal-blog/blob/master/src/article/entities/article.entity.ts"
    click Main "https://github.com/Mark0-22/personal-blog/blob/master/src/main.ts"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#27ae60,stroke:#219a52,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef module fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white
```
