How kdechant/angular5-httpclient-demo works
Project Type and Purpose
• This is a small full‑stack demo application:
• Front‑end: Angular 5 single‑page app illustrating HttpClient + RxJS Observables
• Back‑end: Node.js/Express API (app.js) serving JSON endpoints
• Build pipeline: Webpack scripts under config/
• Purpose: show how an Angular service calls a REST API and handles responses as Observables.
File‑Structure Analysis
Top–Level
• app.js – Express server defining API routes
• index.html – HTML shell for the SPA (served by both Webpack dev server and Express)
• webpack.config.js + config/webpack.*.js – build configurations for dev and production
• package.json – dependencies: Angular packages, Express, Webpack, TypeScript
• tsconfig.json, tslint.json, .angular-cli.json – TypeScript and Angular CLI settings
src/
• src/main.ts, vendor.ts, polyfills.ts – Angular bootstrap and polyfill setup
• src/app/ – Angular module and component source, including demo.service.ts (HTTP service)
• src/assets/ – static assets
README Insights
• No database—Express API returns mock data
• Webpack handles transpiling TS, bundling, and launching Node server
• Live reload is not configured
a. Main Components
1. Browser/Client
– Hosts the Angular SPA
2. Angular Application
– Components (AppComponent)
– Services (DemoService using HttpClient + Observables)
3. Build Pipeline
– Webpack Dev & Common configs (transpile, bundle)
– TypeScript compiler
4. Node.js/Express Backend
– app.js exposes REST endpoints
5. External Layers (optional)
– npm registry (for dependencies)
– Developer machine (runs npm install / npm start)
b. Relationships & Data Flows
1. Developer triggers “npm start” → Webpack compiles TS → bundles JS
2. Bundled app served to Browser or Node
3. Angular App initializes (main.ts → AppModule → AppComponent)
4. AppComponent calls DemoService.getData()
5. HttpClient issues HTTP GET → Express API → returns JSON
6. Observable stream in Angular → component renders data
c. Architectural Patterns & Principles
• Single‑Page Application (SPA)
• Modular Angular with separation of Presentation (Components) and Data Access (Services)
• Observable‑based async data flow (RxJS)
• Unidirectional data flow: service → component → view
• Build‑time bundling via Webpack
d. Key Technologies
• Angular 5, TypeScript, RxJS
• Express.js on Node.js
• Webpack (config/webpack.common.js, webpack.dev.js)
• npm/Yarn for package management
Diagramming Details
• “npm start” → Build Pipeline
• “bundle.js” → Browser
• “HTTP GET /api/*” → Express
• “JSON response” → Angular Service
• Blue for front‑end (Angular)
• Green for back‑end (Express)
• Orange for build tools (Webpack/TS)
• Annotations:
• Ports (e.g., localhost:3000)
• File paths (e.g., src/app/demo.service.ts)
• Config files under config/