# mohamedashfaq01/angular19-simple-blog-app architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedashfaq01/angular19-simple-blog-app
- Repository: https://github.com/mohamedashfaq01/angular19-simple-blog-app

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built entirely in Angular (v18+), intended to fetch and display blog posts from a dummy JSON API.
- It implements standalone components, Angular Signals for reactive state, a truncate pipe, routing between list and detail views, pagination, loading & error states, and has been deployed as a static site (Vercel).

##### File structure
- Top level: angular.json, package.json, public (static assets), src/ (Angular application source).
- src/app/ holds all Angular components, services, models, pipes, routes, and configuration.
- app.component.* – shell component
- app.routes.ts – RouterModule definitions
- app.config.ts – any global configuration (e.g., API base URL)
- blog-post & blog-post-details – two standalone components for list and detail views
- services/post.service.ts – HTTP client to fetch post data
- models/post.model.ts – TypeScript interfaces for post data
- pipes/truncate.pipe.ts – transforms long text
- src/main.ts & index.html – Angular bootstrap and HTML host
- tsconfig*.json – TypeScript configuration
- package.json – dependencies (Angular, RxJS, etc.)

##### README for additional insights
- Fetches data from DummyJSON API
- Uses Angular Signals and new control-flow syntax
- Standalone component architecture
- Deploys to Vercel as a static Angular build
- Features: pagination and reaction count

##### Components
a. Main components:
- Browser/Client
- Static Hosting (Vercel CDN)
- Angular SPA (App Shell)
– App Component & Router
– BlogList Component
– BlogPostDetail Component
– Truncate Pipe
– PostService (wrapping HttpClient)
– Signal-based State Store
- External API (DummyJSON)
b. Relationships & interactions:
- Browser requests index.html from Vercel → Server returns static assets
- Angular bootstraps in browser → main.ts loads AppComponent
- User navigates → Router loads either BlogList or BlogPostDetail
- Components call PostService → HttpClient sends GET requests to DummyJSON API
- API responds → PostService updates Signals → Components re-render
c. Architectural patterns & principles:
- SPA with client-side routing (RouterModule)
- Standalone components – no NgModule wrappers
- Reactive state using Angular Signals
- Separation of concerns:
– Presentation (components & pipes)
– Data access (services)
– Domain models (interfaces)
- Configuration abstraction (app.config.ts)
d. Key technologies & libraries:
- Angular v18+ (Signals, standalone components, new control-flow syntax)
- RxJS & HttpClient
- TypeScript interfaces for models
- Vercel for static hosting
- DummyJSON external REST API

##### Elements
- Browser → Vercel (asset fetch)
- Browser ↔ Angular components & service
- Service → External API → Service
- Service → Signal store → Components
- Gray boundary around CDN/static hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser and Hosting
    Browser["Browser/Client"]:::browser
    subgraph "Static Hosting (Vercel CDN)" 
        direction TB
        Vercel["Vercel CDN"]:::hosting
    end

    Browser -->|"GET index.html, JS, CSS"| Vercel
    Vercel -->|"Serves static assets"| Browser

    %% Angular SPA Container
    subgraph "Angular SPA" 
        direction TB
        AppComponent["App Component"]:::ui
        Router["RouterModule"]:::ui
        BlogList["BlogList Component"]:::ui
        BlogDetail["BlogPostDetail Component"]:::ui
        TruncatePipe["Truncate Pipe"]:::ui
        SignalStore["Signal-based State Store"]:::state
        PostService["PostService"]:::service
    end

    %% External API
    DummyAPI["DummyJSON API"]:::api

    %% Interactions
    Browser -->|"bootstrap via main.ts"| AppComponent
    AppComponent -->|"defines routes (app.routes.ts)"| Router
    Router -->|"navigate to /posts"| BlogList
    Router -->|"navigate to /posts/:id"| BlogDetail

    BlogList -->|"uses TruncatePipe"| TruncatePipe
    BlogList -->|"calls PostService"| PostService
    BlogDetail -->|"calls PostService"| PostService

    PostService -->|"updates Signals"| SignalStore
    SignalStore -->|"provides data"| BlogList
    SignalStore -->|"provides data"| BlogDetail

    PostService -->|"HTTP GET /posts"| DummyAPI
    DummyAPI -->|"HTTP response"| PostService

    %% Click events
    click AppComponent "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/app.component.ts"
    click Router "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/app.routes.ts"
    click AppComponent "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/app.component.html"
    click AppComponent "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/app.component.scss"
    click Config "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/app.config.ts"
    click BlogList "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post/blog-post.component.ts"
    click BlogList "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post/blog-post.component.html"
    click BlogList "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post/blog-post.component.scss"
    click BlogDetail "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post-details/blog-post-details.component.ts"
    click BlogDetail "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post-details/blog-post-details.component.html"
    click BlogDetail "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/blog-post-details/blog-post-details.component.scss"
    click TruncatePipe "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/pipes/truncate.pipe.ts"
    click PostService "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/services/post.service.ts"
    click Models "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/app/models/post.model.ts"
    click Main "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/main.ts"
    click Index "https://github.com/mohamedashfaq01/angular19-simple-blog-app/blob/main/src/index.html"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#DFFBE0,stroke:#22863A,color:#22863A;
    classDef api fill:#FFEFD5,stroke:#D2691E,color:#D2691E;
    classDef hosting fill:#F2F2F2,stroke:#888888,color:#555555;
    classDef browser fill:#FFF5BA,stroke:#DBAB09,color:#DBAB09;
    classDef state fill:#F0F8FF,stroke:#87CEEB,color:#0277BD;
```
