# omarrebai/angularproject architecture

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

- Interactive diagram: https://gitdiagram.com/omarrebai/angularproject
- Repository: https://github.com/omarrebai/angularproject

## Overview

##### Project type and purpose
- This is a front-end single‐page application built entirely in Angular (v16) using the Angular CLI.
- Purpose: A “Lab2023” management console that allows users to log in, view dashboards, and manage entities such as articles, events, tools, and members. It uses Firebase for authentication/data and a JSON data file (`_db.json`) as a mock DB.

##### File structure
- Top‐level Angular config and metadata: `angular.json`, `package.json`, `tsconfig.*.json`.
- `src/app/` – the core application:
- `app.module.ts` – root NgModule wiring up Components, Services, and the Firebase integration.
- `app-routing.module.ts` – routes, guards, and lazy-load (if any).
- `Firebase.module.ts` – a feature module that configures AngularFire/Auth.
- `src/app/<feature>/…` – feature folders for `login`, `dashboard`, `articles`, `events`, `tools`, `members`, each with `.ts`, `.html`, `.css`, spec tests.
- `src/services/` – injectable services (`AuthService`, `ArticleService`, etc.) encapsulating all HTTP/Firebase calls.
- `src/models/` – TypeScript interfaces/models for domain entities.
- `src/Gard/auth.guard.ts` – route guard implementing authorization flow.
- `src/environments/` – environment‐specific Firebase/endpoint settings.

##### Key points from the README
- Generated by Angular CLI; standard dev and build scripts (`ng serve`, `ng build`, `ng test`).
- No explicit back‐end in this repo: calls go to Firebase or a mock JSON.

a. Main components
- UI Layer (Components & Layout)
- Routing Layer (AppRoutingModule + AuthGuard)
- Business Logic Layer (Services)
- Data Layer (Firebase / REST endpoints / `_db.json`)
- Models (TypeScript interfaces)
- External Services (Firebase Auth, Firestore/Realtime DB)
b. Relationships and interactions
- AppComponent bootstraps → loads LayoutComponent containing `<router-outlet>`.
- Navigation triggers routes → routed Components (e.g. DashboardComponent, ArticlesComponent).
- Each Component injects relevant Service.
- Services call external APIs (Firebase SDK or REST against `_db.json`).
- AuthGuard protects secured routes by calling AuthService.
c. Architectural patterns
- Angular’s module-component-service pattern (MVVM / component-service separation).
- Dependency Injection for Services.
- Feature modules for Firebase and App.
- Route-based navigation with Guards.
d. Technologies & frameworks
- Angular CLI 16
- Angular Modules, Components, Services, Guards
- Angular Router
- AngularFire (Firebase.module)
- TypeScript models
- Karma + Jasmine for tests

##### Detailed breakdown
- Top layer: AppModule
- Contains imports: BrowserModule, AppRoutingModule, FirebaseModule
- Declares AppComponent, LayoutComponent
- Routing layer:
- AppRoutingModule defines paths → FeatureModules or Components
- AuthGuard applied to protected paths
- Feature layer: For each feature (articles, events, tools, members, login, dashboard)
- Service layer:
- Each Service configured as a singleton injectable in AppModule
- Data layer:
- Firebase (Auth, Firestore / Realtime DB)
- Local mock `_db.json` (if in dev mode)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        AppModule["AppModule"]:::frontend
        AppComponent["AppComponent"]:::frontend
        LayoutComponent["LayoutComponent"]:::frontend
    end

    %% Routing Layer
    subgraph "Routing Layer"
        direction TB
        AppRoutingModule["AppRoutingModule"]:::routing
        AuthGuard["AuthGuard"]:::routing
        Router["Angular Router"]:::routing
    end

    %% Feature Components
    subgraph "Feature Components" 
        direction TB
        LoginComponent["LoginComponent"]:::frontend
        DashboardComponent["DashboardComponent"]:::frontend
        ArticlesComponent["ArticlesComponent"]:::frontend
        EventsComponent["EventsComponent"]:::frontend
        EventCreateComponent["EventCreateComponent"]:::frontend
        ToolsComponent["ToolsComponent"]:::frontend
        ToolsCreateComponent["ToolsCreateComponent"]:::frontend
        MemberListComponent["MemberListComponent"]:::frontend
        MemberFormComponent["MemberFormComponent"]:::frontend
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AuthService["AuthService"]:::service
        LoginService["LoginService"]:::service
        ArticleService["ArticleService"]:::service
        EventService["EventService"]:::service
        ToolService["ToolService"]:::service
        MemberService["MemberService"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        FirebaseModule["FirebaseModule"]:::data
        MockDB["_db.json (Mock DB)"]:::data
        EnvConfig["Environment Configs"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        FirebaseDB["Firestore/Realtime DB"]:::external
    end

    %% Models
    subgraph "Models"
        direction TB
        Evenement["Evenement"]:::model
        Publication["Publication"]:::model
        MemberModel["Member"]:::model
        ToolModel["Tool"]:::model
        UserModel["User"]:::model
    end

    %% Connections
    AppModule -->|imports| AppComponent
    AppModule -->|imports| AppRoutingModule
    AppModule -->|imports| FirebaseModule

    AppComponent -->|bootstraps| LayoutComponent
    LayoutComponent -->|contains <router-outlet>| Router

    Router -->|path: login| LoginComponent
    Router -->|path: dashboard| DashboardComponent
    Router -->|path: articles| ArticlesComponent
    Router -->|path: events| EventsComponent
    Router -->|path: events/create| EventCreateComponent
    Router -->|path: tools| ToolsComponent
    Router -->|path: tools/create| ToolsCreateComponent
    Router -->|path: members| MemberListComponent
    Router -->|path: members/form| MemberFormComponent

    AppRoutingModule -->|uses guard| AuthGuard
    AuthGuard -->|calls| AuthService

    LoginComponent -->|injects| AuthService
    DashboardComponent -->|injects| ArticleService
    ArticlesComponent -->|injects| ArticleService
    EventsComponent -->|injects| EventService
    EventCreateComponent -->|injects| EventService
    ToolsComponent -->|injects| ToolService
    ToolsCreateComponent -->|injects| ToolService
    MemberListComponent -->|injects| MemberService
    MemberFormComponent -->|injects| MemberService

    AuthService -->|firebaseAuth.signInWithEmailAndPassword| FirebaseAuth
    AuthService -->|reads/writes| FirebaseDB
    LoginService -->|HTTP calls| MockDB
    ArticleService -->|HTTP GET /articles| FirebaseDB
    EventService -->|HTTP GET /events| FirebaseDB
    ToolService -->|HTTP GET /tools| FirebaseDB
    MemberService -->|HTTP GET /members| FirebaseDB

    FirebaseModule -->|configures| FirebaseAuth
    FirebaseModule -->|configures| FirebaseDB
    MockDB -->|file| EnvConfig

    %% Models usage
    ArticleService -.->|uses| Publication
    EventService -.->|uses| Evenement
    ToolService -.->|uses| ToolModel
    MemberService -.->|uses| MemberModel
    AuthService -.->|uses| UserModel

    %% Click Events
    click AppModule "https://github.com/omarrebai/angularproject/blob/main/src/app/app.module.ts"
    click AppComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/app.component.ts"
    click LayoutComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/layout/layout.component.ts"
    click LoginComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/login/login.component.ts"
    click DashboardComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/dashboard/dashboard.component.ts"
    click ArticlesComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/articles/articles.component.ts"
    click EventsComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/events/events.component.ts"
    click EventCreateComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/event-create/event-create.component.ts"
    click ToolsComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/tools/tools.component.ts"
    click ToolsCreateComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/tools-create/tools-create.component.ts"
    click MemberListComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/member-list/member-list.component.ts"
    click MemberFormComponent "https://github.com/omarrebai/angularproject/blob/main/src/app/member-form/member-form.component.ts"
    click AppRoutingModule "https://github.com/omarrebai/angularproject/blob/main/src/app/app-routing.module.ts"
    click AuthGuard "https://github.com/omarrebai/angularproject/blob/main/src/Gard/auth.guard.ts"
    click AuthService "https://github.com/omarrebai/angularproject/blob/main/src/services/AuthService.ts"
    click LoginService "https://github.com/omarrebai/angularproject/blob/main/src/services/login.service.ts"
    click ArticleService "https://github.com/omarrebai/angularproject/blob/main/src/services/article.service.ts"
    click EventService "https://github.com/omarrebai/angularproject/blob/main/src/services/event.service.ts"
    click ToolService "https://github.com/omarrebai/angularproject/blob/main/src/services/tool.service.ts"
    click MemberService "https://github.com/omarrebai/angularproject/blob/main/src/services/member.service.ts"
    click FirebaseModule "https://github.com/omarrebai/angularproject/blob/main/src/app/Firebase.module.ts"
    click MockDB "https://github.com/omarrebai/angularproject/blob/main/src/assets/_db.json"
    click EnvConfig "https://github.com/omarrebai/angularproject/blob/main/src/environments/environment.ts"
    click EnvConfig "https://github.com/omarrebai/angularproject/blob/main/src/environments/environment.development.ts"
    click Evenement "https://github.com/omarrebai/angularproject/blob/main/src/models/evenement.ts"
    click Publication "https://github.com/omarrebai/angularproject/blob/main/src/models/publication.ts"
    click MemberModel "https://github.com/omarrebai/angularproject/blob/main/src/models/member.ts"
    click ToolModel "https://github.com/omarrebai/angularproject/blob/main/src/models/tool.ts"
    click UserModel "https://github.com/omarrebai/angularproject/blob/main/src/models/user.ts"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,stroke-width:1px
    classDef routing fill:#FCF3CF,stroke:#F1C40F,stroke-width:1px
    classDef service fill:#D4EFDF,stroke:#27AE60,stroke-width:1px
    classDef data fill:#FADBD8,stroke:#E74C3C,stroke-width:1px
    classDef external fill:#E8DAEF,stroke:#8E44AD,stroke-width:1px
    classDef model fill:#FDEDEC,stroke:#C0392B,stroke-width:1px
```
