# victoriaparraf/go_dely_back_verde architecture

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

- Interactive diagram: https://gitdiagram.com/victoriaparraf/go_dely_back_verde
- Repository: https://github.com/victoriaparraf/go_dely_back_verde

## Overview

##### Project Type and Purpose
- This is a backend server-side application for an e-commerce or delivery platform (named “GoDely”) with multiple bounded contexts (e.g., Auth, Product, Category, Combo, Coupon, Discount, Notification, Order, Payment Method, User, and Address).
- The README highlights several key modules (Auth, Product, Category, etc.) and external technology integrations (PostgreSQL, RabbitMQ, Cloudinary). Patterns of DDD and Hexagonal Architecture are explicitly mentioned.

##### File Structure
- The source code is organized in a “src” directory with multiple subdirectories corresponding to the bounded contexts.
- Each module (for example, src/auth, src/product, src/category) follows a layered structure with folders like application (commands, queries, DTOs), domain (entities, aggregates, value objects, events, exceptions), and infrastructure (controllers, repositories, mapping, TypeORM integrations).
- There is a “common” module that centralizes shared abstractions and integrations (e.g., Cloudinary, Email, Firebase, RabbitMQ).
- Configuration files (e.g., docker-compose.yml, .env.template) and Nest CLI settings indicate containerization and environment-based configuration.

##### Core Components to Highlight
- Auth Module (handles authentication and JWT services)
- User Module (user registration, profile, and user entity management)
- Product Module (CRUD operations related to products and catalog management)
- Category Module (managing product categories and hierarchy)
- Combo Module (bundling products together)
- Coupon Module (managing discount coupons)
- Discount Module (discount definitions and application logic)
- Order Module (managing orders, statuses, and order items)
- Payment Method Module (handling payment method details and integrations)
- Notification Module (for sending notifications)
- Address Module (user address management, although integrated within the User context if not separate)

b. Layers / Architectural Structure within Each Module:
- Application Layer: Contains DTOs, command and query services which orchestrate business logic.
- Domain Layer: Contains aggregates, entities, value objects, domain events, and exceptions that encapsulate business logic.
- Infrastructure Layer: Responsible for interacting with external systems (e.g., controllers for REST APIs, TypeORM repositories, external services integration such as RabbitMQ, Cloudinary, email, Firebase).

c. External Services & Technologies:
- PostgreSQL for persistent data (as hinted by the use of TypeORM configurations)
- RabbitMQ for messaging and asynchronous communications
- Cloudinary for image storage/processing
- External authentication using JWTs

##### Relationships and Interactions
- Controllers receive API calls, then forward applications commands/queries to services.
- Application layer services interact with the domain layer (aggregates, entities) and, if necessary, publish events for coordination (e.g., notification service or order status updates).
- Infrastructure layer’s repositories (e.g., TypeORM based) bridge the domain objects with the database.
- Shared/common services (in the “common” folder) interact with external systems like Cloudinary, RabbitMQ, and email gateways.
- Inter-module communications (e.g., Order module might need data from Product, Discount, and User modules) should be depicted by clearly showing the API or event-driven integration lines between these contexts.

##### Architectural Patterns and Design Principles
- Domain-Driven Design by grouping modules as bounded contexts with clear separation of concerns.
- Hexagonal architecture (ports and adapters): Display the domain core in the center with application ports (e.g., services, interfaces) and adapters such as controllers, repositories, and external service integrations surrounding them.
- Clean separation between the domain, application, and infrastructure layers to reflect the maintainability and scalability principles.

##### Final Elements
- Each major module (e.g., Auth, Product, Order, etc.) with its internal sublayers.
- External communication channels (API gateway, external integrations like Cloudinary, RabbitMQ, PostgreSQL).
- Green for application layer elements.

## Diagram (Mermaid)

```mermaid
flowchart TD
    API["API Client"]:::external
    PG["PostgreSQL DB"]:::external
    RM["RabbitMQ"]:::external
    CL["Cloudinary"]:::external

    subgraph "Auth Module"
        AModule["Auth Module"]:::module
        A_infra["Auth Controller"]:::infrastructure
        A_app["Auth Service"]:::application
        A_domain["Auth Domain"]:::domain
        A_repo["Auth Repository"]:::infrastructure
        AModule --> A_infra
        A_infra --> A_app
        A_app --> A_domain
        A_domain --> A_repo
        A_repo --> PG
    end

    subgraph "Product Module"
        PModule["Product Module"]:::module
        P_infra["Product Controller"]:::infrastructure
        P_app["Product Service"]:::application
        P_domain["Product Domain"]:::domain
        P_repo["Product Repository"]:::infrastructure
        PModule --> P_infra
        P_infra --> P_app
        P_app --> P_domain
        P_domain --> P_repo
        P_repo --> PG
    end

    subgraph "Category Module"
        CModule["Category Module"]:::module
        C_infra["Category Controller"]:::infrastructure
        C_app["Category Service"]:::application
        C_domain["Category Domain"]:::domain
        C_repo["Category Repository"]:::infrastructure
        CModule --> C_infra
        C_infra --> C_app
        C_app --> C_domain
        C_domain --> C_repo
        C_repo --> PG
    end

    subgraph "Combo Module"
        ComboModule["Combo Module"]:::module
        Combo_infra["Combo Controller"]:::infrastructure
        Combo_app["Combo Service"]:::application
        Combo_domain["Combo Domain"]:::domain
        Combo_repo["Combo Repository"]:::infrastructure
        ComboModule --> Combo_infra
        Combo_infra --> Combo_app
        Combo_app --> Combo_domain
        Combo_domain --> Combo_repo
        Combo_repo --> PG
    end

    subgraph "Coupon Module"
        CouponModule["Coupon Module"]:::module
        Coupon_infra["Coupon Controller"]:::infrastructure
        Coupon_app["Coupon Service"]:::application
        Coupon_domain["Coupon Domain"]:::domain
        Coupon_repo["Coupon Repository"]:::infrastructure
        CouponModule --> Coupon_infra
        Coupon_infra --> Coupon_app
        Coupon_app --> Coupon_domain
        Coupon_domain --> Coupon_repo
        Coupon_repo --> PG
    end

    subgraph "Discount Module"
        DiscountModule["Discount Module"]:::module
        Discount_infra["Discount Controller"]:::infrastructure
        Discount_app["Discount Service"]:::application
        Discount_domain["Discount Domain"]:::domain
        Discount_repo["Discount Repository"]:::infrastructure
        DiscountModule --> Discount_infra
        Discount_infra --> Discount_app
        Discount_app --> Discount_domain
        Discount_domain --> Discount_repo
        Discount_repo --> PG
    end

    subgraph "Notification Module"
        NotificationModule["Notification Module"]:::module
        Notification_infra["Notification Controller"]:::infrastructure
        Notification_app["Notification Service"]:::application
        Notification_domain["Notification Domain"]:::domain
        Notification_repo["Notification Repository"]:::infrastructure
        NotificationModule --> Notification_infra
        Notification_infra --> Notification_app
        Notification_app --> Notification_domain
        Notification_domain --> Notification_repo
        Notification_repo --> PG
    end

    subgraph "Order Module"
        OrderModule["Order Module"]:::module
        Order_infra["Order Controller"]:::infrastructure
        Order_app["Order Service"]:::application
        Order_domain["Order Domain"]:::domain
        Order_repo["Order Repository"]:::infrastructure
        OrderModule --> Order_infra
        Order_infra --> Order_app
        Order_app --> Order_domain
        Order_domain --> Order_repo
        Order_repo --> PG
    end

    subgraph "Payment Method Module"
        PaymentMethodModule["Payment Method Module"]:::module
        PaymentMethod_infra["Payment Method Controller"]:::infrastructure
        PaymentMethod_app["Payment Method Service"]:::application
        PaymentMethod_domain["Payment Method Domain"]:::domain
        PaymentMethod_repo["Payment Method Repository"]:::infrastructure
        PaymentMethodModule --> PaymentMethod_infra
        PaymentMethod_infra --> PaymentMethod_app
        PaymentMethod_app --> PaymentMethod_domain
        PaymentMethod_domain --> PaymentMethod_repo
        PaymentMethod_repo --> PG
    end

    subgraph "User Module"
        UserModule["User Module"]:::module
        User_infra["User Controller"]:::infrastructure
        User_app["User Service"]:::application
        User_domain["User Domain"]:::domain
        User_repo["User Repository"]:::infrastructure
        UserModule --> User_infra
        User_infra --> User_app
        User_app --> User_domain
        User_domain --> User_repo
        User_repo --> PG
    end

    subgraph "Common Services & External Integrations"
        Common["Common Services"]:::module
    end

    %% Connections from API Client to Module Controllers
    API --> A_infra
    API --> P_infra
    API --> C_infra
    API --> Combo_infra
    API --> Coupon_infra
    API --> Discount_infra
    API --> Notification_infra
    API --> Order_infra
    API --> PaymentMethod_infra
    API --> User_infra

    %% Connections from Module Controllers to Common Services
    A_infra --> Common
    P_infra --> Common
    C_infra --> Common
    Combo_infra --> Common
    Coupon_infra --> Common
    Discount_infra --> Common
    Notification_infra --> Common
    Order_infra --> Common
    PaymentMethod_infra --> Common
    User_infra --> Common

    %% Connections from Common Services to External Integrations
    Common --> RM
    Common --> CL

    %% Click Events
    click AModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/auth"
    click PModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/product"
    click CModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/category"
    click ComboModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/combo"
    click CouponModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/coupon"
    click DiscountModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/discount"
    click NotificationModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/notification"
    click OrderModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/order"
    click PaymentMethodModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/payment-method"
    click UserModule "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/user"
    click Common "https://github.com/victoriaparraf/go_dely_back_verde/tree/main/src/common"

    %% Styles
    classDef domain fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef application fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef infrastructure fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef module fill:#F5DEB3,stroke:#000,stroke-width:1px;
```
