How maitreyeepaliwal/coursera-front-end-javascript-frameworks-angular works
Project Type and Purpose
• This is a single-page application (SPA) built entirely in Angular (v13), serving as a restaurant website front end (“ConFusion”).
• There is no native backend in this codebase; instead it consumes JSON data (src/assets/db.json) via HTTP (e.g., with json-server or a real REST API).
File Structure Analysis
• Top-level Angular config and metadata: angular.json, package.json, tsconfig.json, README.md.
• src/app – contains the AppModule and feature folders:
• about, contact, home, login, menu, dishdetail – each with component.ts/.html/.scss/.spec.ts
• shared – type definitions (dish.ts, leader.ts, etc.) and baseurl.ts
• services – DishService, LeaderService, PromotionService, FeedbackService, ProcessHTTPMsgService
• animations – reusable animation definitions
• approuting – a routing submodule (routes.ts, approuting.module.ts)
• src/assets/db.json – mock data store
• src/environments – dev/prod environment settings
README Insights
• Built with Angular CLI; run with ng serve.
Main Components
a. Browser / Client
– Hosts the Angular SPA, bootstrapped in main.ts → AppModule → AppComponent.
b. Angular Layers
– AppModule
– Routing Module (AppRouting or ApproutingModule)
– Components: Header, Footer, Home, About, Menu, DishDetail, Contact, Login
– Services: HTTP-based data retrieval (DishService, PromotionService, etc.)
– Shared domain models (Dish, Leader, Promotion, Feedback)
– Animations module
c. External API / Mock Server
– JSON server (or REST API) serving db.json over HTTP
d. (Optional) Browser Local Storage / Forms / Reactive Forms as used by Feedback or Login
Relationships and Interactions
• On load, main.ts boots AppModule → AppComponent.
• AppComponent contains Header & Footer; router-outlet displays feature components based on routes.ts.
• Feature Components inject Services to fetch data: Service → HttpClient → HTTP GET baseUrl + endpoint.
• Services map JSON to Shared models, handle errors via ProcessHTTPMsgService.
• Data flows from JSON server → Service → Component → Template.
• User interactions (e.g., submitting feedback in ContactComponent) POST back to REST API.
Architectural Patterns and Principles
• Modularization: Core (AppModule), Feature Modules (ApproutingModule), Shared (models & utilities).
• Component-Based UI: each screen is a self-contained component.
• Service-Oriented Data Access: all HTTP calls centralized in services.
• Single Source of Configuration: baseUrl in shared/baseurl.ts, environment.ts for endpoint toggling.
Elements
• Component cluster: Home, About, Menu, DishDetail, Contact, Login
• Service cluster: DishService, LeaderService, PromotionService, FeedbackService, ProcessHTTPMsgService
• Shared models: Dish, Leader, Promotion, Feedback
• ApproutingModule with route definitions