# sdanielsilva/cultivua architecture

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

- Interactive diagram: https://gitdiagram.com/sdanielsilva/cultivua
- Repository: https://github.com/sdanielsilva/cultivua

## Overview

##### Main System Components

A. Frontend Layer (Angular)
- Present the user interface components:
- Dashboard Module
- Plant Management Module
- E-commerce Module
- Quiz System
- Authentication Module
- Blog Module

B. Backend Layer (Laravel)
- API structure with:
- Controllers Layer
- Models Layer
- Services Layer
- Authentication Middleware
- Database Layer

C. External Services Integration
- Connections to:
- PlantID API
- Perenual API
- IoT System (Arduino)

##### Detailed Component Breakdown

Frontend (Angular):
**[User Interface Layer]**
**↓**
**[Component Layer]**
- Dashboard Components
- Plant Management
- E-commerce Components
- Authentication Components
**↓**
**[Services Layer]**
- HTTP Services
- State Management
- Authentication Service

Backend (Laravel):
**[API Routes Layer]**
**↓**
**[Middleware Layer]**
- Authentication
- Admin Access
- User Verification
**↓**
**[Controllers]**
- Plant Controllers
- User Controllers
- Order Controllers
- Quiz Controllers
**↓**
**[Models Layer]**
- User/Admin Models
- Plant/Kit Models
- Order Models
**↓**
**[Database Layer]**

##### Data Flow Representation

- User interactions → Frontend
- Frontend → Backend API calls
- Backend → Database operations
- Backend → External API interactions
- IoT devices → Backend data flow

##### Key Integration Points

Crucial integration points:
- Authentication flow between frontend and backend
- Real-time sensor data integration
- External API communication paths
- Database interaction patterns

##### Specific Implementation Details

Technical elements:
- Docker container architecture
- MySQL database connections
- Angular-Laravel API communication
- IoT sensor data flow
- External API integration points

##### Security Layer

Security implementations:
- JWT/Token authentication flow
- Admin middleware protection
- API route protection
- User data encryption

##### Component Relationships
- Clear separation between frontend and backend
- Distinct service boundaries
- Data flow patterns

##### Technical Stack Integration
- Angular frontend architecture
- Laravel backend structure
- Database design
- External service integration

##### Deployment Architecture
- Docker container organization
- Development vs production environments
- Scaling considerations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f39c12,stroke:#f1c40f,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef iot fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        UI[User Interface]
        DashMod[Dashboard Module]:::frontend
        PlantMod[Plant Management]:::frontend
        EcomMod[E-commerce Module]:::frontend
        QuizMod[Quiz System]:::frontend
        AuthMod[Authentication Module]:::frontend
        BlogMod[Blog Module]:::frontend
        
        UI --> DashMod & PlantMod & EcomMod & QuizMod & AuthMod & BlogMod
    end

    %% Backend Layer
    subgraph Backend
        API[API Routes]:::backend
        
        subgraph Middleware
            AuthMW[Authentication Middleware]:::backend
            AdminMW[Admin Middleware]:::backend
        end
        
        subgraph Controllers
            PlantCtrl[Plant Controller]:::backend
            UserCtrl[User Controller]:::backend
            OrderCtrl[Order Controller]:::backend
            QuizCtrl[Quiz Controller]:::backend
            KitCtrl[Kit Reading Controller]:::backend
            AuthCtrl[Auth Controller]:::backend
        end
        
        subgraph Models
            PlantModel[Plant Model]:::backend
            UserModel[User Model]:::backend
            OrderModel[Order Model]:::backend
            KitModel[Kit Reading Model]:::backend
        end
        
        DB[(Database)]:::database
    end

    %% External Services
    subgraph External
        PlantID[PlantID API]:::external
        Perenual[Perenual API]:::external
        IoT[Arduino IoT System]:::iot
    end

    %% Connections
    DashMod & PlantMod & EcomMod & QuizMod & AuthMod & BlogMod --> API
    API --> AuthMW --> Controllers
    AuthMW --> AdminMW
    
    Controllers --> Models
    Models --> DB
    
    KitCtrl --> IoT
    PlantCtrl --> PlantID & Perenual

    %% Click Events
    click DashMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/components/dashboard/"
    click PlantMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/pages/planta/"
    click EcomMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/pages/loja-online/"
    click QuizMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/pages/quiz/"
    click AuthMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/pages/authentication/"
    click BlogMod "https://github.com/sDanielSilva/CultivUA/tree/main/template/starterkit/src/app/pages/blog/"
    click Controllers "https://github.com/sDanielSilva/CultivUA/tree/main/app/Http/Controllers/"
    click Models "https://github.com/sDanielSilva/CultivUA/tree/main/app/Models/"
    click AuthMW "https://github.com/sDanielSilva/CultivUA/tree/main/app/Http/Middleware/"
    click DB "https://github.com/sDanielSilva/CultivUA/tree/main/database/migrations/"
    click KitCtrl "https://github.com/sDanielSilva/CultivUA/blob/main/app/Http/Controllers/KitReadingController.php"
    click KitModel "https://github.com/sDanielSilva/CultivUA/blob/main/app/Models/KitReading.php"
    click AuthCtrl "https://github.com/sDanielSilva/CultivUA/blob/main/app/Http/Controllers/AuthController.php"
    click AdminMW "https://github.com/sDanielSilva/CultivUA/blob/main/app/Http/Middleware/AdminMiddleware.php"
    click PlantCtrl "https://github.com/sDanielSilva/CultivUA/blob/main/app/Http/Controllers/PlantController.php"
    click PlantModel "https://github.com/sDanielSilva/CultivUA/blob/main/app/Models/Plant.php"
    click OrderCtrl "https://github.com/sDanielSilva/CultivUA/blob/main/app/Http/Controllers/OrderController.php"
    click OrderModel "https://github.com/sDanielSilva/CultivUA/blob/main/app/Models/Order.php"
```
