# kuadtrai/child-growth-tracking-system_be architecture

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

- Interactive diagram: https://gitdiagram.com/kuadtrai/child-growth-tracking-system_be
- Repository: https://github.com/kuadtrai/child-growth-tracking-system_be

## Overview

##### Project Type and Purpose
- This is a backend REST API for a Child Growth Tracking system.
- Its primary function is to manage and track child-related data, user authentication, feedback, metrics, and related information.
- Being the “_BE” (backend) part, it is designed to work as the API server supporting a likely frontend (web or mobile) by handling data processing, database interactions, and application logic.

##### File Structure and Key Components
- Top-Level Build & Configuration:
- Files like pom.xml, mvnw, and .mvn/ indicate that Maven is used for project management and build automation.
- Project Source Organization (src/main/java/G5_SWP391/ChildGrownTracking):
- configurations: Contains Spring configuration classes such as Database setup, GlobalExceptionHandler, and SwaggerConfig for API documentation.
- controllers: Houses REST controllers (e.g., AuthenticateController, ChildController, FeedbackController, MetricController, PostController, UserController) that expose endpoints to client applications.
- dtos: Contains Data Transfer Objects for incoming request data and outgoing responses, ensuring that data sent over the network adheres to a specific format.
- models: Represents the domain entities (Child, Doctor, Feedback, Metric, Post, and User models) corresponding to the business domain.
- repositories: Interfaces for persistence using Spring Data (e.g., ChildRepository, UserRepository) that enable CRUD operations on underlying data storage.
- responses: Contains custom response classes which might provide a consistent API response structure.
- services: Implements the business logic for each domain area (child tracking, authentication, doctor management, feedback, metrics, posts, and user operations).

a. Main Components to Include:
- External Clients (Frontend/Mobile Apps) that interact with the REST API.
- API Layer: REST Controllers that serve as the interface between clients and business logic.
- Service Layer: Business logic implementing application workflows.
- Data Access Layer: Repositories managing database operations.
- Domain Layer: Models, DTOs, and Response objects that define and transfer data.
- Configuration & Cross-Cutting Concerns: Global configuration components such as database configuration, exception handling, and API documentation via Swagger.
- External Dependencies: The Database (configured in Database.java) and any potential external services.

b. Relationships and Interactions:
- The Repositories interact with the Database (showing persistence).
- Cross-cutting components like GlobalExceptionHandler intercept failures in any layer.
- SwaggerConfig indicates that a separate pathway exists for API documentation access.

c. Architectural Patterns and Technologies:
- Layered Architecture: Separation into Controllers, Services, Repositories, and Domain Models.
- API Documentation: Integration with Swagger for documenting REST endpoints.
- Exception Management: A Global Exception Handler to manage errors centrally.
- Technology Stack: Spring Boot framework, Maven for build management, and likely a relational database (e.g., MySQL, PostgreSQL) based on the configuration class.

##### Comprehensive Coverage
- Every essential architectural element highlighted by the project’s file tree—especially each layer and component.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entity
    E["External Clients"]:::external

    %% Application Layers
    subgraph "Application Layers"
        C["API Controller Layer"]:::controller
        S["Service Layer"]:::service
        R["Data Access Layer (Repositories)"]:::repository
        DB["Database"]:::database
    end

    %% Data Representation Layer
    subgraph "Data Representation"
        DM["Domain Models"]:::model
        D["Data Transfer Objects (DTOs)"]:::dto
        RO["Response Objects"]:::response
    end

    %% Cross-Cutting and Build
    subgraph "Cross-Cutting & Build"
        CFG["Configuration & Cross-Cutting"]:::config
        BM["Build & Dependency Management (Maven)"]:::build
    end

    %% Main Flow
    E -->|"HTTP_Request"| C
    C -->|"Calls"| S
    S -->|"Data_Operations"| R
    R -->|"Performs_Crud"| DB

    %% Associations with Data Representation
    C ---|"Uses_DTOs"| D
    C ---|"Formats_Response"| RO
    S ---|"Utilizes_Models"| DM

    %% Configuration integration
    CFG ---|"Configures_DB"| DB
    CFG ---|"Intercepts_Errors"| C
    CFG ---|"Intercepts_Errors"| S
    CFG ---|"Intercepts_Errors"| R

    %% Maven supports configuration
    BM ---|"Manages_Build"| CFG

    %% Click Events
    click C "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/controllers"
    click S "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/services"
    click R "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/repositories"
    click DM "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/models"
    click D "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/dtos"
    click RO "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/responses"
    click CFG "https://github.com/kuadtrai/child-growth-tracking-system_be/tree/main/src/main/java/G5_SWP391/ChildGrownTracking/configurations"

    %% Styles
    classDef external fill:#c2f0c2,stroke:#2d7a2d,stroke-width:2px;
    classDef controller fill:#c2d6f0,stroke:#2d5a7a,stroke-width:2px;
    classDef service fill:#f0e6b2,stroke:#7a7a2d,stroke-width:2px;
    classDef repository fill:#f0c2d6,stroke:#7a2d5a,stroke-width:2px;
    classDef database fill:#e6e6e6,stroke:#333333,stroke-width:2px;
    classDef model fill:#f0c2a6,stroke:#a67a5a,stroke-width:2px;
    classDef dto fill:#d6f0c2,stroke:#5a7a2d,stroke-width:2px;
    classDef response fill:#c2d6f0,stroke:#2d5a7a,stroke-width:2px;
    classDef config fill:#f0a6c2,stroke:#7a2d5a,stroke-width:2px;
    classDef build fill:#d6d6f0,stroke:#5a5a7a,stroke-width:2px;
```
