# mohamedroshdyp/chatapp-client architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedroshdyp/chatapp-client
- Repository: https://github.com/mohamedroshdyp/chatapp-client

## Overview

##### Project type and purpose
- This is a front-end single-page application built with Angular (CLI v16.2.1).
- Its primary purpose is to provide an authenticated member portal with features like registration, login, member listing, messaging (with real-time presence), photo editing, and an admin panel for role management.

##### File structure
- Top-level config files: angular.json, tsconfig*.json, package.json.
- src/app: contains all Angular features, organized by folders:
- _directives, _forms, _resolvers: shared building blocks (custom directives, form inputs, route resolvers)
- admin: components for admin panel and management
- guards: route guards (AuthGuard, AdminGuard, PreventUnsavedChangesGuard)
- interceptors: HTTP interceptors (JWT, loading spinner)
- home, lists, members, messages, nav, register, not-found: feature areas, each with its own components
- modals: pop-up dialogs (role modals)
- services: business-logic layer for API calls (AuthService, MembersService, MessageService, AdminService, PresenceService, AlertifyService, LoaderService, PaginationHelper)
- modules: shared.module.ts – encapsulates common Angular Material modules, pipes, directives, etc.
- src/assets/environments/environment.ts: environment config for API URLs and feature flags.

##### Extract key technical stack from README
- Angular CLI
- Development server via ng serve
- Testing with Karma & e2e via your chosen framework
- Build output in dist/

##### Main components
a. Front-End (Angular SPA)
- Browser / Client (Angular App)
- AppModule & AppRoutingModule orchestrating feature modules and routes
- SharedModule for common imports (FormsModule, HttpClientModule, UI libraries, etc.)
- Feature components (HomeComponent, MemberListComponent, MemberDetailComponent, PhotoEditorComponent, MessagesComponent, AdminPanelComponent, etc.)
- Custom directives, pipes, and modals
- Guards & Resolvers
- HTTP Interceptors (JwtInterceptor, LoadingInterceptor)
- Services layer calling HTTP endpoints via HttpClient
b. API Layer (external)
- Authentication API (login, register, role-based JWT issuance)
- Members API (get all, get one, update profile, upload photos)
- Messaging API (REST for history + WebSocket/SignalR for real-time)
- Admin API (user/role management endpoints)
c. Data Stores & External Services
- Database (e.g., SQL/Postgres for users, messages, photos metadata)
- Cloud storage (e.g., Cloudinary or S3 for image hosting)
- Real-time hub (e.g., SignalR or WebSocket server for presence and chat)
d. Third-party Libraries
- AlertifyJS for notifications
- Angular Router for navigation
- Angular Forms (ReactiveFormsModule)
- HTTPClientModule for REST calls
- Any UI component libs (Bootstrap, Material, etc., if used)

##### Relationships and interactions
- Browser loads index.html → main.ts → imports AppModule
- AppModule initializes SharedModule, registers interceptors, declares root routes
- User actions in UI components invoke service methods
- Services issue HTTP requests; JwtInterceptor attaches JWT token to Authorization header
- LoadingInterceptor displays a spinner via LoaderService during pending HTTP calls
- Guards use AuthService to allow/deny navigation; Resolvers preload data before route activation
- PresenceService establishes a WebSocket/SignalR connection for real-time notifications and presence tracking
- PhotoEditorComponent uploads images to cloud storage API endpoint
- AdminPanelComponent calls AdminService to manage roles via Admin API
- All APIs talk to the database; real-time hub notifies connected clients

##### Architectural patterns & design principles
- Module-based separation: SharedModule vs. feature modules
- Component-driven UI with single responsibility
- Service layer abstracts HTTP calls and business logic
- HTTP Interceptor pattern for cross-cutting concerns (auth, loading)
- Route guards and resolvers for secure, preloaded navigation
- Reactive programming (Observables) for async data streams and real-time events

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Entry"
    Browser["Browser / Client"]:::client
    Index["index.html"]:::client
    Main["main.ts"]:::client
  end
  Browser-->Index-->Main-->AppModule

  subgraph "Angular Modules"
    AppModule["AppModule"]:::module
    AppRouting["AppRoutingModule"]:::module
    SharedMod["SharedModule"]:::module
  end
  Main-->AppModule
  AppModule-->SharedMod
  AppModule-->AppRouting

  subgraph "Presentation Layer"
    Nav["NavComponent"]:::component
    Home["HomeComponent"]:::component
    Lists["ListsComponent"]:::component
    MemberList["MemberListComponent"]:::component
    MemberDetail["MemberDetailComponent"]:::component
    PhotoEditor["PhotoEditorComponent"]:::component
    Messages["MessagesComponent"]:::component
    AdminPanel["AdminPanelComponent"]:::component
    AdminMgmt["AdminManagementComponent"]:::component
    Register["RegisterComponent"]:::component
    NotFound["NotFoundComponent"]:::component
    DateInput["DateInputComponent"]:::component
    TextInput["TextInputComponent"]:::component
    HasRole["HasRoleDirective"]:::component
  end
  AppModule -->|"declares"| Nav
  AppModule --> Home
  AppModule --> Lists
  AppModule --> MemberList
  AppModule --> MemberDetail
  AppModule --> PhotoEditor
  AppModule --> Messages
  AppModule --> AdminPanel
  AppModule --> AdminMgmt
  AppModule --> Register
  AppModule --> NotFound
  SharedMod --> DateInput
  SharedMod --> TextInput
  SharedMod --> HasRole

  subgraph "Business Layer"
    AuthService["AuthService"]:::service
    MembersService["MembersService"]:::service
    MessageService["MessageService"]:::service
    AdminService["AdminService"]:::service
    PresenceService["PresenceService"]:::service
    Alertify["AlertifyService"]:::service
    Loader["LoaderService"]:::service
    Pagination["PaginationHelper"]:::service
    JwtInt["JwtInterceptor"]:::service
    LoadInt["LoadingInterceptor"]:::service
    AuthGuard["AuthGuard"]:::service
    AdminGuard["AdminGuard"]:::service
    PreventGuard["PreventUnsavedChangesGuard"]:::service
    MemberResolver["MemberDetailsResolver"]:::service
  end
  Nav -->|"invokes"| AuthService
  Home -->|"invokes"| AuthService
  Lists -->|"invokes"| MembersService
  MemberList -->|"invokes"| MembersService
  MemberDetail -->|"invokes"| MembersService
  PhotoEditor -->|"invokes"| MembersService
  Messages -->|"invokes"| MessageService
  AdminPanel -->|"invokes"| AdminService
  AdminMgmt -->|"invokes"| AdminService
  Register -->|"invokes"| AuthService
  JwtInt -->|"intercepts"| AuthService
  LoadInt -->|"intercepts"| AuthService
  AppRouting -->|"canActivate"| AuthGuard
  AppRouting -->|"canActivate"| AdminGuard
  AppRouting -->|"canDeactivate"| PreventGuard
  AppRouting -->|"resolve"| MemberResolver

  subgraph "External APIs"
    AuthAPI["Authentication API"]:::external
    MembersAPI["Members API"]:::external
    MsgAPI["Messaging API"]:::external
    AdminAPI["Admin API"]:::external
    RTHub["Real-time Hub"]:::external
    CloudStore["Cloud Storage"]:::external
  end
  AuthService -->|"HTTP/HTTPS"| AuthAPI
  MembersService -->|"HTTP/HTTPS"| MembersAPI
  MessageService -->|"HTTP/HTTPS"| MsgAPI
  AdminService -->|"HTTP/HTTPS"| AdminAPI
  PresenceService -->|WebSocket| RTHub
  RTHub -->|WebSocket| PresenceService
  PhotoEditor -->|"upload via HTTP"| CloudStore

  subgraph "Data Stores"
    DB["Database"]:::db
  end
  AuthAPI -->|"SQL"| DB
  MembersAPI -->|"SQL"| DB
  MsgAPI -->|"SQL"| DB
  AdminAPI -->|"SQL"| DB

  classDef client fill:#E0F7FA,stroke:#000
  classDef module fill:#BBDEFB,stroke:#000
  classDef component fill:#90CAF9,stroke:#000
  classDef service fill:#A5D6A7,stroke:#000
  classDef external fill:#FFE082,stroke:#000
  classDef db fill:#FFCC80,stroke:#000

  click AppModule "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/app.module.ts"
  click AppRouting "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/app-routing.module.ts"
  click SharedMod "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/modules/shared.module.ts"
  click Home "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/home/home.component.ts"
  click MemberList "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/members/member-list/member-list.component.ts"
  click MemberDetail "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/members/member-detail/member-detail.component.ts"
  click PhotoEditor "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/members/photo-editor/photo-editor.component.ts"
  click Messages "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/messages/messages.component.ts"
  click AdminPanel "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/admin/admin-panel/admin-panel.component.ts"
  click AdminMgmt "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/admin/admin-managment/admin-managment.component.ts"
  click Register "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/register/register.component.ts"
  click Nav "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/nav/nav.component.ts"
  click Lists "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/lists/lists.component.ts"
  click NotFound "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/not-found/not-found.component.ts"
  click HasRole "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/_directives/has-role.directive.ts"
  click DateInput "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/_forms/date-input/date-input.component.ts"
  click TextInput "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/_forms/text-input/text-input.component.ts"
  click MemberResolver "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/_resolvers/member-details-resolver.ts"
  click AuthGuard "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/guards/auth.guard.ts"
  click AdminGuard "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/guards/admin.guard.ts"
  click PreventGuard "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/guards/prevent-unsaved-changes.guard.ts"
  click JwtInt "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/interceptors/jwt.interceptor.ts"
  click LoadInt "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/interceptors/loading.interceptor.ts"
  click AuthService "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/auth.service.ts"
  click MembersService "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/members.service.ts"
  click MessageService "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/message.service.ts"
  click AdminService "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/admin.service.ts"
  click PresenceService "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/presence.service.ts"
  click Alertify "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/alertify.service.ts"
  click Loader "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/loader.service.ts"
  click Pagination "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/app/services/paginationHelper.ts"
  click Models "https://github.com/mohamedroshdyp/chatapp-client/tree/master/src/app/models"
  click EnvironmentConfig "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/assets/environments/environment.ts"
  click Main "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/main.ts"
  click Index "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/index.html"
  click Styles "https://github.com/mohamedroshdyp/chatapp-client/blob/master/src/styles.scss"
```
