How davidbernalgonzalez/superalimentos works
Project type and purpose
• This is an Angular single-page application (SPA) named “SuperAlimentos” whose sole purpose is to provide a nutritional‐advice interface: display a list of foods, allow searching, adding new foods, and building a daily menu with calorie totals.
File structure
• Top‐level files (angular.json, tsconfig.json, package.json, etc.) configure the Angular build and tooling.
• src/ holds the application code:
• src/app/app.module.ts and app.component.ts/html/scss define the root module and shell component.
• src/app/food-list/ holds the FoodListComponent (presentation and interactions).
• src/app/services/ holds FoodService (data source, business logic, CRUD on the food array).
• src/assets/ for static images.
• src/environments/ for environment-specific configuration.
• e2e/ and karma.conf.js set up end-to-end and unit testing, but these are peripheral to the runtime architecture.
README
• Confirms a purely front-end exercise using a static data file (food.ts) backed by a service.
• Describes four iterations: display foods, filter by name (with a custom pipe), add foods via a dynamic form, and build a daily menu with quantity tracking.
Main components & interactions
a. Components to show
• User (actor in the browser)
• Angular Application Container
• AppModule (bootstraps the app)
• AppComponent (root shell)
• FoodListComponent (UI for listing, searching, adding foods, building menu)
• Custom Pipe (filtering food by name)
• FoodService (holds the in-memory array, exposes methods: getFoods(), addFood(), addToMenu(), etc.)
• Static Data Source (food.ts or JSON file under assets/)
• Environment Config (injects URLs or feature flags—here mostly empty)
• Hosting Layer (e.g., GitHub Pages or web server serving index.html)
b. Relationships and data flow
• Browser ▶ loads index.html ▶ main.ts ▶ bootstraps AppModule
• AppComponent ▶ displays FoodListComponent
• FoodListComponent ▶ invokes FoodService.getFoods() ▶ returns array from static data
• User events in FoodListComponent (search input, “add food” form submit, “add to menu” clicks) ▶ call FoodService methods ▶ update in-memory state ▶ component re-renders
• Environment config is injected into services or modules at startup (if needed)
• Assets (images) are fetched by the browser directly from /assets
c. Architectural patterns & design principles
• Component-based UI decomposition (Angular’s standard)
• Dependency Injection for services (single source of truth)
• Unidirectional data flow: Service ▶ Component ▶ Template ▶ User Event ▶ Service
• Separation of concerns: UI (components), business logic & state (service), configuration (environments), static assets
d. Key technologies
• Angular (Modules, Components, Services, Pipes)
• TypeScript
• RxJS or simple synchronous arrays for data streams
• Karma & Jasmine (unit testing)
• Protractor (end‐to‐end testing)