# josinaldojunior/code_shopping architecture

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

- Interactive diagram: https://gitdiagram.com/josinaldojunior/code_shopping
- Repository: https://github.com/josinaldojunior/code_shopping

## Overview

##### Project type and purpose
- This is a full-stack application built in three layers:
- A Laravel back-end (REST API + MVC + Firebase integration)
- An Angular single-page web client (_angular-app)
- An Ionic mobile client (_whatsapp)
- Purpose: provide CRUD operations (products, categories, users, chat groups) via a Laravel API, web administration via Angular, mobile chat/messaging via Ionic + Firebase.

##### File structure
- Top-level directories:
- app, routes, database, config, resources, public → Laravel back-end
- _angular-app → Angular front-end
- _whatsapp → Ionic (Angular) mobile front-end
- Key patterns:
- Laravel follows MVC: Models (app/Models), Controllers (app/Http/Controllers), Resources (app/Http/Resources), Middleware, Events/Listeners
- Angular uses modules, components, services (src/app/services/http, guards, directives, pipes)
- Ionic uses pages, components, providers, Firebase config
- Config & build files:
- composer.json, webpack.mix.js → back-end build
- package.json, angular.json → Angular build
- package.json, config.xml, webpack.config.js → Ionic build

##### README
- Brief: “Projeto do curso Laravel-Angular-Ionic” confirms learning integration of Laravel API + Angular web + Ionic mobile.

##### Elements
- Green for API
- Orange for DB
- Purple for Firebase services

##### Detailed breakdown
- UI Components
- HTTP Services & Interceptors
- Routing & Guards
- Pages (chat, login, home)
- Providers (auth, chat-group-viewer, storage-permission)
- Firebase config
- Laravel API subdivided into:
- Controllers (Api/*)
- Models & Resources
- Events & Listeners
- Middleware (Auth, Cors)
- Data Layer:
- MySQL schema (users, products, chat_groups, etc.)
- Firebase Realtime DB / Firestore for chat messages
- FCM for notifications

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        AngularUI["UI Components"]:::frontend
        AngularRoutingModule["Routing Module"]:::frontend
        AngularAuthGuard["Auth Guard"]:::frontend
        AngularHTTPServices["HTTP Services"]:::frontend
        AngularRefreshInterceptor["Refresh Token Interceptor"]:::frontend
        AngularModel["Models & Config"]:::frontend
        IonicPages["Pages"]:::mobile
        AuthProvider["Firebase Auth Provider"]:::mobile
        ChatViewerProvider["Chat-Group Viewer"]:::mobile
        StoragePermissionProvider["Storage Permission"]:::mobile
        PushNotificationProvider["Push Notification"]:::mobile
        IonicFirebaseConfig["Firebase Config"]:::mobile
        IonicAppModule["App Module & Component"]:::mobile
    end

    %% API Layer
    subgraph "API Layer (Laravel)" 
        direction TB
        LaravelControllers["Controllers (Api)"]:::api
        LaravelModels["Models"]:::api
        LaravelRequests["API Requests Validation"]:::api
        LaravelResources["API Resources"]:::api
        ChatEvent["ChatMessageSent Event"]:::api
        UserEvent["UserCreated Event"]:::api
        LaravelListener["SendPushChatGroupMembers Listener"]:::api
        FirebaseAuthService["Firebase Auth Service"]:::api
        CloudMessagingService["Cloud Messaging Service"]:::api
        ChatMessageFbService["Chat Message Firebase Service"]:::api
        LaravelRoutes["API Routes"]:::api
        LaravelMigrations["Database Migrations"]:::api
        LaravelJWT["JWT Config"]:::api
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MySQL["Relational DB (MySQL/PostgreSQL)"]:::db
        FirebaseRealtime["Firebase Realtime/Firestore"]:::firebase
        FCM["FCM Push Service"]:::firebase
    end

    %% Interactions
    AngularHTTPServices -->|"HTTP GET/POST /api/... + JWT"| LaravelControllers
    AngularRefreshInterceptor --> AngularHTTPServices
    AngularRoutingModule --> AngularAuthGuard

    IonicPages -->|"HTTP GET/POST /api/... + Firebase Auth Token"| LaravelControllers
    AuthProvider -->|"Firebase Auth API"| FirebaseRealtime
    ChatViewerProvider -->|"WebSocket/Realtime Sync"| FirebaseRealtime
    PushNotificationProvider -->|"Receive FCM Push"| FCM
    IonicAppModule --> IonicFirebaseConfig

    LaravelControllers --> LaravelModels
    LaravelControllers --> LaravelRequests
    LaravelControllers --> LaravelResources
    LaravelControllers --> ChatEvent
    LaravelControllers --> UserEvent
    ChatEvent --> LaravelListener
    LaravelListener --> FCM
    FirebaseAuthService --> FirebaseRealtime
    CloudMessagingService --> FCM
    ChatMessageFbService --> FirebaseRealtime
    LaravelControllers --> MySQL
    LaravelMigrations --> MySQL
    LaravelRoutes --> LaravelControllers
    LaravelJWT --> LaravelControllers

    %% Click Events
    click AngularUI "https://github.com/josinaldojunior/code_shopping/tree/master/_angular-app/src/app/components"
    click AngularRoutingModule "https://github.com/josinaldojunior/code_shopping/blob/master/_angular-app/src/app/app-routing.module.ts"
    click AngularAuthGuard "https://github.com/josinaldojunior/code_shopping/blob/master/_angular-app/src/app/guards/auth.guard.ts"
    click AngularHTTPServices "https://github.com/josinaldojunior/code_shopping/tree/master/_angular-app/src/app/services/http"
    click AngularRefreshInterceptor "https://github.com/josinaldojunior/code_shopping/blob/master/_angular-app/src/app/services/refresh-token-interceptor.service.ts"
    click AngularModel "https://github.com/josinaldojunior/code_shopping/blob/master/_angular-app/src/app/model.ts"
    click AngularModel "https://github.com/josinaldojunior/code_shopping/blob/master/_angular-app/src/app/firebase-config.ts"
    click IonicPages "https://github.com/josinaldojunior/code_shopping/tree/master/_whatsapp/src/pages"
    click AuthProvider "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/providers/auth/firebase-auth.ts"
    click ChatViewerProvider "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/providers/chat-group-viewer/chat-group-viewer.ts"
    click StoragePermissionProvider "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/providers/storage-permission/storage-permission.ts"
    click PushNotificationProvider "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/providers/push-notification/push-notification.ts"
    click IonicFirebaseConfig "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/app/firebase-config.ts"
    click IonicAppModule "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/app/app.module.ts"
    click IonicAppModule "https://github.com/josinaldojunior/code_shopping/blob/master/_whatsapp/src/app/app.component.ts"
    click LaravelControllers "https://github.com/josinaldojunior/code_shopping/tree/master/app/Http/Controllers/Api"
    click LaravelModels "https://github.com/josinaldojunior/code_shopping/tree/master/app/Models"
    click LaravelRequests "https://github.com/josinaldojunior/code_shopping/tree/master/app/Http/Requests"
    click LaravelResources "https://github.com/josinaldojunior/code_shopping/tree/master/app/Http/Resources"
    click ChatEvent "https://github.com/josinaldojunior/code_shopping/blob/master/app/Events/ChatMessageSent.php"
    click UserEvent "https://github.com/josinaldojunior/code_shopping/blob/master/app/Events/UserCreatedEvent.php"
    click LaravelListener "https://github.com/josinaldojunior/code_shopping/blob/master/app/Listeners/SendPushChatGroupMembers.php"
    click FirebaseAuthService "https://github.com/josinaldojunior/code_shopping/blob/master/app/Firebase/Auth.php"
    click CloudMessagingService "https://github.com/josinaldojunior/code_shopping/blob/master/app/Firebase/CloudMessagingFb.php"
    click ChatMessageFbService "https://github.com/josinaldojunior/code_shopping/blob/master/app/Firebase/ChatMessageFb.php"
    click LaravelRoutes "https://github.com/josinaldojunior/code_shopping/blob/master/routes/api.php"
    click LaravelMigrations "https://github.com/josinaldojunior/code_shopping/tree/master/database/migrations"
    click LaravelJWT "https://github.com/josinaldojunior/code_shopping/blob/master/config/jwt.php"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#1f78b4
    classDef mobile fill:#e6f0ff,stroke:#1f78b4
    classDef api fill:#d5f5d5,stroke:#2e7d32
    classDef db fill:#fce8b2,stroke:#bf360c
    classDef firebase fill:#e1bee7,stroke:#4a148c
```
