# jamesawo/angular-clean-architecture architecture

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

- Interactive diagram: https://gitdiagram.com/jamesawo/angular-clean-architecture
- Repository: https://github.com/jamesawo/angular-clean-architecture

## Overview

##### Project Type & Purpose
- Full-stack single-page application built with Angular on the frontend and Netlify Edge (serverless) functions on the backend, following Uncle Bob’s Clean Architecture.
- Goal: A blog/CMS site (posts, bookmarks, projects) whose UI is decoupled from its data-access logic, and whose backend is a set of HTTP-triggered serverless functions that CRUD against MongoDB.

##### High-Level Architecture Components
a. Frontend (Angular App hosted as static site)
- Layers (in vertical stack):
- Core: application-wide utilities, type contracts, and configuration (src/app/core)
- Domain: entities (Bookmark, Post, Project), use-case definitions, and repository interfaces (src/app/domain)
- Data: concrete implementations of repository interfaces (remote HTTP repos under src/app/data/datasources/remote), interactors (use-case executors), and HTTP request wrappers (src/app/data/requests)
- Presentation: Angular modules, pages (home, blog, bookmarks, projects, editor), and shared UI components (buttons, tables, modals, theme-switcher, toast, etc.)
- Angular’s HttpClient in Data layer → communicates with serverless backend endpoints.

b. Backend (Netlify Edge Functions)
- HTTP endpoints under netlify/functions/{bookmarks,posts,projects} with CRUD files (get.ts, post.ts, put.ts, delete.ts, index.ts)
- Shared helper code (helper.ts) and TS config for functions
- Connects to MongoDB Atlas cluster to execute actual data operations

c. Database
- MongoDB cluster as the single persistence store

d. Deployment & Hosting
- Source in Git; netlify.toml & example.env define build & environment setup
- Netlify builds Angular CLI app, deploys static assets + functions

##### Data Flow & Relationships
- Browser → loads SPA (static files) from Netlify hosting
- UI (Presentation) invokes use-case methods in Domain
- Domain use-cases call repository interfaces (contracts)
- Data layer provides implementations that issue HTTP requests to Edge Functions
- Edge Functions receive HTTP request → parse payload → use MongoDB driver → return JSON
- Data layer maps JSON to Domain entities and returns to Use-Case → UI updates

##### Key Architectural Patterns
- Clean Architecture: strict separation into Core, Domain, Data, Presentation
- Dependency Inversion: Domain defines interfaces; Data and Presentation depend on Domain interfaces
- Inversion of Control / IoC: data.ioc.ts registers concrete repos for injection
- Serverless Function pattern: thin HTTP handlers on Netlify providing backend APIs

## Diagram (Mermaid)

```mermaid
graph TB
  %% Frontend Application
  subgraph "Frontend Application"
    subgraph "Core Layer"
      Core["Core (Utilities, Config)"]:::core
    end
    subgraph "Domain Layer"
      Entities["Entities (Bookmark, Post, Project)"]:::domain
      UseCases["Use-Case Interfaces"]:::domain
    end
    subgraph "Data Layer"
      IoC["Data IoC (dependency registration)"]:::data
      DataModule["Data Module"]:::data
      RemoteDS["Remote DataSources"]:::data
      Interactors["Interactors (Use-Case Executors)"]:::data
      Requests["HTTP Request Wrappers"]:::data
    end
    subgraph "Presentation Layer"
      UI["UI Pages & Components"]:::presentation
    end
  end

  %% Backend Application
  subgraph "Netlify Edge Functions"
    subgraph "Bookmarks API" 
      Bindex["index.ts"]:::backend
      Bget["get.ts"]:::backend
      Bpost["post.ts"]:::backend
      Bput["put.ts"]:::backend
      Bdelete["delete.ts"]:::backend
    end
    subgraph "Posts API"
      Pindex["index.ts"]:::backend
      Phelper["helper.ts"]:::backend
    end
    subgraph "Projects API"
      Prindex["index.ts"]:::backend
      Prget["get.ts"]:::backend
      Prpost["post.ts"]:::backend
      Prput["put.ts"]:::backend
      Prdelete["delete.ts"]:::backend
    end
    TSfunc["tsconfig.json"]:::backend
  end

  %% Database
  DB["MongoDB Atlas"]:::db

  %% Deployment & Config
  NetlifyToml["netlify.toml"]:::config
  Env["example.env"]:::config
  AngularCLI["angular.json"]:::config
  TSApp["tsconfig.app.json"]:::config
  TSRoot["tsconfig.json"]:::config
  TSSpec["tsconfig.spec.json"]:::config

  %% Data Flow
  UI -->|"invoke Use-Case"| UseCases
  UseCases -->|"execute()"| Interactors
  Interactors -->|"use RemoteDS"| RemoteDS
  RemoteDS -->|"map→Requests"| Requests
  Requests -->|"HttpClient.call()"| Bindex
  Bindex -->|"MongoDB Driver"| DB
  DB -->|"result JSON"| Bindex
  Bindex -->|"HTTP Response"| Requests
  Requests -->|"map→Entities"| Interactors
  Interactors -->|"return Entities"| UseCases
  UseCases -->|"update UI"| UI

  %% Deployment Flow
  AngularCLI -->|"build SPA"| UI
  NetlifyToml -->|"config functions"| Bindex
  Env -->|"env vars"| Bindex

  %% Click Events
  click Core "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/core"
  click Entities "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/domain"
  click IoC "https://github.com/jamesawo/angular-clean-architecture/blob/main/src/app/data/data.ioc.ts"
  click DataModule "https://github.com/jamesawo/angular-clean-architecture/blob/main/src/app/data/data.module.ts"
  click RemoteDS "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/data/datasources/remote"
  click Interactors "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/data/interactors"
  click Requests "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/data/requests"
  click UI "https://github.com/jamesawo/angular-clean-architecture/tree/main/src/app/presenter"
  click Bindex "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/bookmarks/index.ts"
  click Bget "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/bookmarks/get.ts"
  click Bpost "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/bookmarks/post.ts"
  click Bput "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/bookmarks/put.ts"
  click Bdelete "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/bookmarks/delete.ts"
  click Pindex "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/posts/index.ts"
  click Phelper "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/posts/helper.ts"
  click Prindex "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/projects/index.ts"
  click Prget "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/projects/get.ts"
  click Prpost "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/projects/post.ts"
  click Prput "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/projects/put.ts"
  click Prdelete "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/projects/delete.ts"
  click TSfunc "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify/functions/tsconfig.json"
  click NetlifyToml "https://github.com/jamesawo/angular-clean-architecture/blob/main/netlify.toml"
  click Env "https://github.com/jamesawo/angular-clean-architecture/blob/main/example.env"
  click AngularCLI "https://github.com/jamesawo/angular-clean-architecture/blob/main/angular.json"
  click TSApp "https://github.com/jamesawo/angular-clean-architecture/blob/main/tsconfig.app.json"
  click TSRoot "https://github.com/jamesawo/angular-clean-architecture/blob/main/tsconfig.json"
  click TSSpec "https://github.com/jamesawo/angular-clean-architecture/blob/main/tsconfig.spec.json"

  %% Styles
  classDef core fill:#cccccc,stroke:#333,stroke-width:1px
  classDef domain fill:#add8e6,stroke:#333,stroke-width:1px
  classDef data fill:#ffa500,stroke:#333,stroke-width:1px
  classDef presentation fill:#90ee90,stroke:#333,stroke-width:1px
  classDef backend fill:#dda0dd,stroke:#333,stroke-width:1px
  classDef db fill:#333333,stroke:#fff,stroke-width:1px,color:#fff
  classDef config fill:#dddddd,stroke:#333,stroke-width:1px
```
