How mohamedroshdyp/chatapp-client works
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