# parklez/blog architecture

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

- Interactive diagram: https://gitdiagram.com/parklez/blog
- Repository: https://github.com/parklez/blog

## Overview

##### Main Components
- Frontend (Client-side): Represented by the “blog” directory. This is an Angular application that handles the user interface, routing for different pages (home, about, post-reader, login, register, projects, etc.), and client-side logic. Highlight key modules (e.g., home, about, login-signin, register-signup, shared components) and show that these modules interact with backend APIs via HTTP.
- Backend (Server-side): Found in the “server” directory. This NodeJS application provides RESTful APIs (CRUD operations for posts, authentication flows, and project management endpoints). It includes configuration files (found in the “config” subdirectory), models for blog posts, projects, and users, and uses routing files to define API endpoints.
- Database: Indicated by files such as “server/src/config/database.js” and “server/src/lib/mongo.js” (implying a MongoDB connection). Represent this external dependency that the backend communicates with for persistent data storage.
- Static Content and Markdown Posts/Projects: The “_posts” and “_projects” directories hold markdown files and related content. These may be used for static content generation (potentially in tandem with GitHub Pages as outlined in the README) and might be pre-compiled.
- CI/CD / Deployment Tools: The “.github” directory with workflows (e.g., gh-pages.yml) signals usage of GitHub Actions for deployment, specifically for updating the GitHub Pages hosting the static content.

##### Relationships & Interactions
- The Angular “blog” client interacts with the NodeJS server over defined API endpoints (such as for CRUD operations on posts and user authentication).
- The server processes requests from the frontend, performs business logic, and communicates with the MongoDB database for data persistence.
- Markdown static assets in “_posts” and “_projects” might be pre-compiled or integrated into the static content served by GitHub Pages, potentially via build scripts.
- Continuous integration and deployment are handled through GitHub workflows to deploy the latest versions automatically.

##### Architectural Patterns & Technologies
- MVC or Modular Pattern: The separation in the “blog” folder (with multiple modules, components, routing, services, and shared assets) indicates an MVC-like structure in Angular.
- RESTful API Design: In the “server” directory, routing is organized by resource (e.g., posts, projects, login, register).
- Authentication middleware exists (e.g., in “server/src/middleware/auth.js”) suggesting the use of token-based or session-based security.
- The use of NodeJS and likely Express.js (given the file structure) for building server routes.
- GitHub Actions for automated CD/CI processes.
- Database integration with MongoDB.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Presentation Layer
    subgraph "Presentation Layer"
        FC["Angular Client (blog)"]:::frontend
        subgraph "Frontend Modules"
            HM["Home Module"]:::frontend
            LS["Login/Signin Module"]:::frontend
            RS["Register/Signup Module"]:::frontend
            PM["Projects Module"]:::frontend
            SC["Shared Components"]:::frontend
        end
    end

    %% Application Logic Layer
    subgraph "Application Logic Layer"
        BS["NodeJS Server (server)"]:::backend
        subgraph "Backend Components"
            BC1["Backend Configuration"]:::backend
            BC2["Backend Models"]:::backend
            BC3["Backend Middleware (Auth)"]:::backend
            BC4["Backend Routes"]:::backend
        end
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        DB["Database (MongoDB)"]:::database
    end

    %% Static Content
    subgraph "Static Content"
        PMD["Markdown Posts (_posts)"]:::static
        PRJ["Markdown Projects (_projects)"]:::static
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CICD["GitHub Actions (.github)"]:::cicd
        DEP["GitHub Pages (Deployment)"]:::static
    end

    %% Connections
    FC -->|"HTTP_API"| BS
    BS -->|"CRUD"| DB
    CICD -->|"Deploys"| DEP
    DEP -->|"Serves"| FC

    %% Internal Backend Structure
    BS --> BC1
    BS --> BC2
    BS --> BC3
    BS --> BC4

    %% Frontend Modules connections to Angular Client
    FC --> HM
    FC --> LS
    FC --> RS
    FC --> PM
    FC --> SC

    %% Frontend interactions with Backend
    HM -->|"FetchPosts"| BC4
    LS -->|"AuthRequest"| BC3
    RS -->|"AuthRequest"| BC3
    PM -->|"FetchProjects"| BC4

    %% Backend serving static content
    BC4 -->|"ServesMarkdown"| PMD
    BC4 -->|"ServesMarkdown"| PRJ

    %% Click Events
    click FC "https://github.com/parklez/blog/tree/master/blog"
    click HM "https://github.com/parklez/blog/tree/master/blog/src/app/home"
    click LS "https://github.com/parklez/blog/tree/master/blog/src/app/login-signin"
    click RS "https://github.com/parklez/blog/tree/master/blog/src/app/register-signup"
    click PM "https://github.com/parklez/blog/tree/master/blog/src/app/projects"
    click SC "https://github.com/parklez/blog/tree/master/blog/src/app/shared"
    click BS "https://github.com/parklez/blog/tree/master/server"
    click BC1 "https://github.com/parklez/blog/tree/master/server/src/config"
    click BC2 "https://github.com/parklez/blog/tree/master/server/src/models"
    click BC3 "https://github.com/parklez/blog/blob/master/server/src/middleware/auth.js"
    click BC4 "https://github.com/parklez/blog/tree/master/server/src/routes"
    click DB "https://github.com/parklez/blog/blob/master/server/src/config/database.js"
    click PMD "https://github.com/parklez/blog/tree/master/_posts"
    click PRJ "https://github.com/parklez/blog/tree/master/_projects"
    click CICD "https://github.com/parklez/blog/blob/master/.github"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#F4A460,stroke:#000,stroke-width:2px;
    classDef database fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef static fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
