# gavilanch/angular-7-cloud-firestore-demo architecture

> Architecture diagram of the GitHub repository gavilanch/angular-7-cloud-firestore-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gavilanch/angular-7-cloud-firestore-demo
- Repository: https://github.com/gavilanch/angular-7-cloud-firestore-demo

## Overview

##### Project Type and Purpose
- This is a Single-Page Application (SPA) built entirely in Angular (v7) using the Angular CLI.
- Its sole purpose is a “Todo” front-end: users can add, list, and manage todo items. There is no back-end in this repo—data lives in the TodoService (in-memory or stubbable for future HTTP).

##### Top-Level File Structure Analysis
- Angular CLI scaffold: angular.json, tsconfig.json, src/, e2e/
- src/ contains:
- index.html, main.ts, polyfills.ts – bootstrapping & polyfills
- environments/ – environment.ts & environment.prod.ts for build-time config
- app/ – the heart of the app:
– app.module.ts & app-routing.module.ts – core module & router
– app.component.* – root component
– contact/, menu/ – shared UI components
– todo/ – feature folder with:
· models/ (Todo, TodoViewModel)
· services/ (TodoService)
· todo-form/ & todo-list/ components
- e2e/ & spec files for Protractor and Karma test harnesses

##### Key Architectural Elements
a. Presentation Layer
- Components (AppComponent, MenuComponent, ContactComponent, TodoFormComponent, TodoListComponent)
- Angular Router directs URL paths to components
b. Business-Logic Layer
- TodoService: holds/manipulates the list of Todo models, stub for HTTP calls
c. Data Layer
- In-memory list (could be replaced with HttpClient to talk to REST)
d. Configuration
- environment.ts files select API endpoints or flags at build time
e. Build & Deployment
- Angular CLI build (webpack under the covers) outputs to dist/
- e2e: Protractor; unit: Karma + Jasmine

##### Important Patterns & Principles
- Component-based architecture: each UI part is its own component with HTML+CSS+TS+spec
- Service for shared state & business logic (singleton, injectable)
- Separation of concerns: models under models/, services under services/, views in their own component folders

##### Summary
- Break the app into Presentation, Service, and Model layers.
- How the Angular CLI build & serve process feeds the browser.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::actor
    Browser["Browser/Client"]:::browser
    Server["Static Web Server / ng serve"]:::server

    User --> Browser
    Browser -->|"HTTP"| Server
    Server --> AngularApp["Angular App"]

    subgraph "Angular App"
        subgraph "Presentation Layer"
            Router["Router"]:::presentation
            AppModule["AppModule"]:::config
            AppRouting["AppRoutingModule"]:::config
            AppComp["AppComponent"]:::presentation
            MenuComp["MenuComponent"]:::presentation
            ContactComp["ContactComponent"]:::presentation
            TodoFormComp["TodoFormComponent"]:::presentation
            TodoListComp["TodoListComponent"]:::presentation
        end
        subgraph "Service Layer"
            TodoService["TodoService"]:::service
        end
        subgraph "Model Layer"
            TodoModel["Todo"]:::model
            TodoVM["TodoViewModel"]:::model
        end
    end

    Router --> AppRouting
    AppRouting --> AppModule
    Router --> AppComp
    AppComp --> MenuComp
    AppComp --> ContactComp
    AppComp --> TodoFormComp
    AppComp --> TodoListComp

    TodoFormComp -->|"uses"| TodoService
    TodoListComp -->|"uses"| TodoService
    TodoService -->|"manipulates"| TodoModel
    TodoService --> TodoVM

    subgraph "Build & Deployment"
        AngularJSON["angular.json"]:::config
        Webpack["Webpack Bundler"]:::config
        Dist["dist/"]:::assets
        EnvDev["environment.ts (dev)"]:::config
        EnvProd["environment.prod.ts (prod)"]:::config
        Main["main.ts"]:::config
        Polyfills["polyfills.ts"]:::config
    end

    AngularJSON --> Webpack
    EnvDev --> Webpack
    EnvProd --> Webpack
    Main --> Webpack
    Polyfills --> Webpack
    Webpack --> Dist
    Server -->|serves| Dist

    subgraph "Testing"
        Unit["Unit Tests (Karma + Jasmine)"]:::test
        E2E["E2E Tests (Protractor)"]:::test
    end

    Unit -->|"tests src/**/*.spec.ts"| AppComp
    E2E -->|"tests e2e specs"| Server

    click AppComp "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/app.component.ts"
    click MenuComp "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/menu/menu.component.ts"
    click ContactComp "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/contact/contact.component.ts"
    click TodoFormComp "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/todo/todo-form/todo-form.component.ts"
    click TodoListComp "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/todo/todo-list/todo-list.component.ts"
    click TodoService "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/todo/services/todo.service.ts"
    click TodoModel "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/todo/models/todo.ts"
    click TodoVM "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/todo/models/todo-view-model.ts"
    click AppModule "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/app.module.ts"
    click AppRouting "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/app-routing.module.ts"
    click EnvDev "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/environments/environment.ts"
    click EnvProd "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/environments/environment.prod.ts"
    click Main "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/main.ts"
    click Polyfills "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/polyfills.ts"
    click AngularJSON "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/angular.json"
    click Unit "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/src/app/**/*.spec.ts"
    click E2E "https://github.com/gavilanch/angular-7-cloud-firestore-demo/blob/master/e2e/src/app.e2e-spec.ts"

    classDef actor fill:#f9f,stroke:#333,stroke-width:2px
    classDef browser fill:#cff,stroke:#333
    classDef server fill:#cfc,stroke:#333
    classDef presentation fill:#bbdefb,stroke:#333
    classDef service fill:#c8e6c9,stroke:#333
    classDef model fill:#eeeeee,stroke:#333
    classDef config fill:#ffcc80,stroke:#333
    classDef assets fill:#ffe0b2,stroke:#333
    classDef test fill:#e1bee7,stroke:#333
```
