How jamesawo/angular-clean-architecture works
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