# janakiramch/recipe-book-app-angular architecture

> Architecture diagram of the GitHub repository janakiramch/recipe-book-app-angular, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/janakiramch/recipe-book-app-angular
- Repository: https://github.com/janakiramch/recipe-book-app-angular

## Overview

##### Project Type and Purpose
- This is a single-page front-end application built entirely with Angular (CLI v16.1.4).
- Its purpose is to allow users to browse, create, edit, and store recipes, as well as manage a shopping list.
- It communicates with an external RESTful backend (via HTTP) to persist recipes and user authentication data.

##### File Structure
- Top-level config files: angular.json, tsconfig.json, package.json – define build, linting, and dependencies.
- src/app/core.module.ts: holds singleton services (e.g., LoggingService, AuthInterceptor).
- src/app/shared/shared.module.ts: reusable directives, components (loading spinner, dropdown, alert) and models.
- Feature modules (lazy-loaded via routing):
– AuthModule: login/signup, AuthService, AuthGuard, AuthInterceptor.
– RecipesModule: components for recipe list, detail, edit; RecipeService; RecipesResolver; routing.
– ShoppingListModule: components for list and edit; ShoppingListService; routing.
- src/app/app.module.ts: root module that imports CoreModule, SharedModule, and sets up routing with AppRoutingModule.
- Services like DataStorageService encapsulate HTTP calls to the backend API.

##### README for Additional Insights
- Standard Angular CLI setup, no built-in backend.
- ng serve runs the dev server; DataStorageService is where HTTP endpoints would be configured (e.g., Firebase or custom REST API).

##### Core Components & Their Relationships
a. User’s Browser & UI Layer
– AppComponent (root)
– HeaderComponent navigates between “Recipes,” “Shopping List,” “Auth.”
– RouterOutlet loads feature-module components.
b. Feature Modules
– RecipesModule: RecipeListComponent → RecipeItemComponent, RecipeDetailComponent, RecipeEditComponent
– ShoppingListModule: ShoppingListComponent, ShoppingEditComponent
– AuthModule: AuthComponent (login/signup)
c. Shared Services & Modules
– DataStorageService → performs HTTP GET/PUT to backend
– AuthService manages JWT tokens
– AuthInterceptor attaches token to outgoing HTTP requests
– LoggingService logs application events
– SharedModule exports common components (AlertComponent, LoadingSpinnerComponent) and directives (DropdownDirective)
d. Routing & Guards
– Routes defined in AppRoutingModule refer to feature modules (lazy loading).
– AuthGuard prevents unauthorized access to protected routes (e.g., managing recipes).
– RecipesResolver pre-fetches recipe data before rendering RecipeDetail/Edit views.

##### Architectural Patterns & Design Principles
- Modular architecture: separation of concerns via Shared, Core, and Feature modules.
- Lazy loading of feature modules to optimize bundle size.
- Dependency Injection: services provided in CoreModule (singletons) or in feature modules (scoped).
- HTTP Interceptor pattern for cross-cutting concerns (auth token injection, error handling).
- Resolver pattern for route-level data fetching.
- Component-Service separation: components handle presentation, services handle business logic and state.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Browser / Client"
        direction TB
        AppModule["AppModule"]:::core
        AppRoutingModule["AppRoutingModule"]:::core
        AppModule -->|imports| CoreModule
        AppModule -->|imports| SharedModule
        AppModule -->|imports| AppRoutingModule
        AppModule -->|bootstrap| AppComponent["AppComponent"]:::component

        AppComponent -->|renders| HeaderComponent["HeaderComponent"]:::component
        AppComponent -->|renders| RouterOutlet["RouterOutlet"]:::component

        RouterOutlet -->|"lazy load"| RecipesModule["RecipesModule"]:::feature
        RouterOutlet -->|"lazy load"| ShoppingListModule["ShoppingListModule"]:::feature
        RouterOutlet -->|"lazy load"| AuthModule["AuthModule"]:::feature

        subgraph "RecipesModule" 
            direction TB
            RecipeListComponent["RecipeListComponent"]:::component
            RecipeItemComponent["RecipeItemComponent"]:::component
            RecipeDetailComponent["RecipeDetailComponent"]:::component
            RecipeEditComponent["RecipeEditComponent"]:::component
            RecipeStartComponent["RecipeStartComponent"]:::component
            RecipeService["RecipeService"]:::service
            RecipesResolver["RecipesResolver"]:::service

            RecipeListComponent -->|renders| RecipeItemComponent
            RecipeDetailComponent -->|inject| RecipeService
            RecipeEditComponent -->|inject| RecipeService
            RecipeStartComponent -->|route resolve| RecipesResolver
        end

        subgraph "ShoppingListModule"
            direction TB
            ShoppingListComponent["ShoppingListComponent"]:::component
            ShoppingEditComponent["ShoppingEditComponent"]:::component
            ShoppingListService["ShoppingListService"]:::service

            ShoppingListComponent -->|inject| ShoppingListService
            ShoppingEditComponent -->|inject| ShoppingListService
        end

        subgraph "AuthModule"
            direction TB
            AuthComponent["AuthComponent"]:::component
            AuthService["AuthService"]:::service
            AuthGuard["AuthGuard"]:::service

            AuthComponent -->|inject| AuthService
            AppRoutingModule -->|guard| AuthGuard
        end

        subgraph "CoreModule & SharedModule"
            direction TB
            CoreModule["CoreModule"]:::core
            SharedModule["SharedModule"]:::core
            LoggingService["LoggingService"]:::service
            AuthInterceptor["AuthInterceptor"]:::service
            DataStorageService["DataStorageService"]:::service
            DropdownDirective["DropdownDirective"]:::component
            AlertComponent["AlertComponent"]:::component
            LoadingSpinnerComponent["LoadingSpinnerComponent"]:::component
            IngredientModel["Ingredient Model"]:::core
            UserModel["User Model"]:::core

            CoreModule -->|provides| LoggingService
            CoreModule -->|provides| AuthInterceptor
            SharedModule -->|exports| DropdownDirective
            SharedModule -->|exports| AlertComponent
            SharedModule -->|exports| LoadingSpinnerComponent
            SharedModule -->|uses| IngredientModel
            AuthService -->|manages| UserModel
        end

        DataStorageService -->|HTTP request| ExternalAPI["External REST API"]:::external
        AuthInterceptor -->|attach token| ExternalAPI
    end

    subgraph Legend
        direction TB
        A["Feature Module"]:::feature
        B["Service"]:::service
        C["Component"]:::component
        D["Core/Shared Module"]:::core
        E["External System"]:::external
    end

    classDef feature fill:#cce5ff,stroke:#0066cc,color:#0066cc;
    classDef service fill:#d4edda,stroke:#28a745,color:#155724;
    classDef component fill:#ffe5b4,stroke:#ff8c00,color:#8b4000;
    classDef core fill:#e2e3e5,stroke:#6c757d,color:#343a40;
    classDef external fill:#f8d7da,stroke:#dc3545,color:#721c24;

    click AppModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/app.module.ts"
    click AppRoutingModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/app-routing.module.ts"
    click CoreModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/core.module.ts"
    click SharedModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/shared.module.ts"
    click AuthModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/auth.module.ts"
    click AuthComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/auth.component.ts"
    click AuthService "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/auth.service.ts"
    click AuthGuard "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/auth.guard.ts"
    click AuthInterceptor "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/auth-interceptor.service.ts"
    click UserModel "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/auth/user.model.ts"
    click HeaderComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/header/header.component.ts"
    click LoggingService "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/logging.service.ts"
    click DataStorageService "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/data-storage.service.ts"
    click DropdownDirective "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/dropdown.directive.ts"
    click AlertComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/alert/alert.component.ts"
    click LoadingSpinnerComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/loading-spinner/loading-spinner.component.ts"
    click RecipesModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipes.module.ts"
    click RecipeService "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe.service.ts"
    click RecipesResolver "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipes-resolver.service.ts"
    click RecipeListComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe-list/recipe-list.component.ts"
    click RecipeItemComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe-list/recipe-item/recipe-item.component.ts"
    click RecipeDetailComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe-detail/recipe-detail.component.ts"
    click RecipeEditComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe-edit/recipe-edit.component.ts"
    click RecipeStartComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/recipes/recipe-start/recipe-start.component.ts"
    click ShoppingListModule "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shopping-list/shopping-list.module.ts"
    click ShoppingListComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shopping-list/shopping-list.component.ts"
    click ShoppingEditComponent "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shopping-list/shopping-edit/shopping-edit.component.ts"
    click ShoppingListService "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shopping-list/shopping-list.service.ts"
    click IngredientModel "https://github.com/janakiramch/recipe-book-app-angular/blob/master/src/app/shared/ingredient.model.ts"
```
