# michaeljota/angular-microfrontend architecture

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

- Interactive diagram: https://gitdiagram.com/michaeljota/angular-microfrontend
- Repository: https://github.com/michaeljota/angular-microfrontend

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with Angular CLI (v15.2.2).
- Its purpose is to manage users: logging in/out, adding users, listing users, and displaying a dashboard.

##### File structure
- src/app/app.module.ts and app-routing.module.ts define the root module and top-level routes.
- src/app/features contains four lazily loaded feature modules:
- -user
- dashboard
- login
- user-list
- src/app/shared holds cross-cutting concerns:
- shared/auth (AuthService, guards)
- shared/users (UsersService)
- src/app/models contains data interfaces (User).
- Standard Angular config files at the root, no backend code here.

##### Key insights from README
- Angular CLI scaffolding, dev server, build, and test commands.

##### Main components & their interactions
a. Frontend SPA (Angular)
- Core Module (AppModule + AppComponent + AppRoutingModule)
- Feature Modules (lazily loaded by router): login, dashboard, add-user, user-list
- Shared Module (AuthService, UsersService, guards)
- Models (User)
- Assets (static files, styles)
b. External Backend API
- A REST service that AuthService and UsersService call over HTTP
c. Browser & User
- Browser makes HTTP requests and renders UI

##### Architectural patterns & principles
- Modularization: root, feature, and shared modules
- Lazy loading: each feature module is only loaded when its route is activated
- Dependency Injection: services are injected into components/guards
- Router-based navigation with guards enforcing authentication
- Separation of concerns: UI components vs. services vs. models

##### Summary of steps
6. Components to services (dependency injection).

## Diagram (Mermaid)

```mermaid
flowchart TD
    UB["User/Browser"]:::external

    subgraph "Angular SPA"
        subgraph "Core Module"
            AM["AppModule"]:::module
            AC["AppComponent"]:::component
            AR["AppRoutingModule"]:::module
        end

        subgraph "Feature Modules"
            subgraph "LoginModule"
                LM["LoginModule"]:::module
                LC["LoginComponent"]:::component
            end
            subgraph "DashboardModule"
                DM["DashboardModule"]:::module
                DC["DashboardComponent"]:::component
            end
            subgraph "AddUserModule"
                AUM["AddUserModule"]:::module
                AUC["AddUserComponent"]:::component
            end
            subgraph "UserListModule"
                ULM["UserListModule"]:::module
                ULC["UserListComponent"]:::component
            end
        end

        subgraph "Shared Module"
            S1["AuthService"]:::service
            S2["UsersService"]:::service
            G1["IsLoggedGuard"]:::guard
            G2["IsNotLoggedGuard"]:::guard
        end

        MD["User (Model)"]:::model
    end

    API["Backend REST API"]:::externaldb

    UB -->|"UI events"| AC
    AC -->|"bootstraps"| AM
    AM -->|"sets up routes"| AR

    AR -->|"route→ Login"| LM
    AR -->|"route→ Dashboard"| DM
    AR -->|"route→ AddUser"| AUM
    AR -->|"route→ UserList"| ULM

    AR -->|"guard auth→ Dashboard"| G1
    AR -->|"guard auth→ AddUser"| G1
    AR -->|"guard auth→ UserList"| G1
    AR -->|"guard guest→ Login"| G2

    LC -->|"injects→ AuthService"| S1
    DC -->|"injects→ UsersService"| S2
    AUC -->|"injects→ UsersService"| S2
    ULC -->|"injects→ UsersService"| S2

    LC -->|"passes| MD
    DC -->|"passes| MD
    AUC -->|"passes| MD
    ULC -->|"passes| MD

    S1 -->|"uses| MD
    S2 -->|"uses| MD

    S1 -->|"HTTP POST→"| API
    S2 -->|"HTTP GET/POST→"| API

    classDef module fill:#D0E6FF,stroke:#0366d6,stroke-width:1px
    classDef component fill:#DFFFE0,stroke:#20a020,stroke-width:1px
    classDef service fill:#FFE6B0,stroke:#d48e00,stroke-width:1px
    classDef guard fill:#F0F0F0,stroke:#888888,stroke-width:1px
    classDef model fill:#F0E0FF,stroke:#800080,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#444444,stroke-width:1px,stroke-dasharray: 5 5
    classDef externaldb fill:#FFEFEF,stroke:#d60000,stroke-width:1px,stroke-dasharray: 5 5

    click AM "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/app.module.ts"
    click AC "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/app.component.ts"
    click AR "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/app-routing.module.ts"
    click LM "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/login/login.module.ts"
    click LC "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/login/login.component.ts"
    click DM "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/dashboard/dashboard.module.ts"
    click DC "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/dashboard/dashboard.component.ts"
    click AUM "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/add-user/add-user.module.ts"
    click AUC "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/add-user/add-user.component.ts"
    click ULM "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/user-list/user-list.module.ts"
    click ULC "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/features/user-list/user-list.component.ts"
    click S1 "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/shared/auth/auth.service.ts"
    click G1 "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/shared/auth/is-logged.guard.ts"
    click G2 "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/shared/auth/is-not-logged.guard.ts"
    click S2 "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/shared/users/users.service.ts"
    click MD "https://github.com/michaeljota/angular-microfrontend/blob/main/src/app/models/user.ts"
```
