# aprimeiradeads/rachadinha architecture

> Architecture diagram of the GitHub repository aprimeiradeads/rachadinha, 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/aprimeiradeads/rachadinha
- Repository: https://github.com/aprimeiradeads/rachadinha

## Overview

##### Project Overview and Purpose
- Rachadinha is a full-stack application designed to help users split bills seamlessly. It features a Java Spring Boot backend for API and business logic and a TypeScript/React frontend to provide a responsive user interface.
- The project emphasizes modularity, with distinct responsibilities for handling user groups, expenses, and the division logic (“racha” meaning to split).

##### Main Components
a. Frontend Component:
- Located under the “apps/agile-project-fe” directory.
- Utilizes React, configured with Storybook for UI component development and uses NX and pnpm for project management.
- Contains routes (e.g., login, sign-up, listing, detail) and various reusable components (buttons, cards, dialogs, inputs, side-menu).
- End-to-end tests are also included in “apps/agile-project-fe-e2e”.

b. Backend Component:
- Found in the “src/main/java” directory, under the package structure ifsul.agileproject.rachadinha.
- Implements the application’s business logic using Spring Boot. The main entry point is RachadinhaApplication.java.
- Organized in layers: Controller (API endpoints like RachaController and UserController), Service (business logic in services and their implementations), Repository (data access objects for User, Racha, Payment, etc.), and Domain (entities, DTOs, exception handling, and mappers).
- Configuration (such as CORS settings) is handled in src/main/java/.../config, while tests written using JUnit and Jasmine are located in src/test.

c. Database/External Dependencies:
- While the file tree does not show an explicit database directory, the application.properties configuration indicates that the backend connects to a relational database.
- External services like Swagger for API documentation (available at http://localhost:8080/swagger-ui.html) also serve as integration points.

##### Detailing Relationships and Interactions
- API endpoints exposed by controllers that manage expense splitting logic.
- A connection from the Services layer to the Domain and Repository layers to represent internal data processing and business logic.
- Optionally, illustrate testing frameworks as separate entities verifying both the Backend (JUnit tests and Swagger endpoint interactions) and Frontend (Playwright and Storybook components).

##### Architectural Patterns and Technologies
- Employ the MVC (Model-View-Controller) pattern on the backend. Controllers trigger Services, which in turn interact with the Domain (DTOs, Entities) and Repository (data access) layers.
- On the frontend, components, hooks, and routes define a clear separation of concerns.
- Use Spring Boot’s standard dependency injection and layered architecture.
- That the use of NX and Storybook supports modularity and component-driven development for the frontend, while Maven and traditional Java project structures handle backend builds.
- Noting the usage of middleware such as CORS configuration (CorsConfig.java) and middleware for error handling (custom exceptions).

##### Final Advice
- Be as detailed as possible. List every layer and significant component particularly to help stakeholders understand how responsibilities are separated (business logic, data persistence, UI rendering).
- Don’t over-simplify: include elements like testing and configuration (e.g., integration with Swagger, testing directories) if they impact the system's understanding.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FEApp["Frontend - React App"]:::frontend
        FEE2E["Frontend End-to-End Tests"]:::frontend
    end

    subgraph "Backend Layer"
        MainApp["Main Application"]:::backend
        APIControllers["API Controllers"]:::backend
        BusinessServices["Business Services"]:::backend
        DataRepositories["Data Repositories"]:::backend
        DomainEntities["Domain Entities & DTOs"]:::backend
        Config["Configuration"]:::backend
        BackendTests["Backend Testing"]:::backend
    end

    subgraph "External / Database"
        Database["Database (Relational)"]:::database
        Swagger["Swagger Documentation"]:::external
    end

    %% Connections between Frontend and Backend
    FEApp -->|"HTTP/REST"| APIControllers
    FEE2E -->|"simulateUI"| FEApp

    %% Internal Backend connections
    MainApp --> APIControllers
    APIControllers --> BusinessServices
    BusinessServices --> DomainEntities
    BusinessServices --> DataRepositories
    DataRepositories -->|"CRUD"| Database
    MainApp --> Config
    MainApp --> BackendTests

    %% External integration
    APIControllers -->|"exposesDocs"| Swagger

    %% Click Events
    click FEApp "https://github.com/aprimeiradeads/rachadinha/tree/main/apps/agile-project-fe"
    click FEE2E "https://github.com/aprimeiradeads/rachadinha/tree/main/apps/agile-project-fe-e2e"
    click MainApp "https://github.com/aprimeiradeads/rachadinha/blob/main/src/main/java/ifsul/agileproject/rachadinha/RachadinhaApplication.java"
    click APIControllers "https://github.com/aprimeiradeads/rachadinha/tree/main/src/main/java/ifsul/agileproject/rachadinha/controller"
    click BusinessServices "https://github.com/aprimeiradeads/rachadinha/tree/main/src/main/java/ifsul/agileproject/rachadinha/service"
    click DataRepositories "https://github.com/aprimeiradeads/rachadinha/tree/main/src/main/java/ifsul/agileproject/rachadinha/repository"
    click DomainEntities "https://github.com/aprimeiradeads/rachadinha/tree/main/src/main/java/ifsul/agileproject/rachadinha/domain"
    click Config "https://github.com/aprimeiradeads/rachadinha/blob/main/src/main/java/ifsul/agileproject/rachadinha/config/CorsConfig.java"
    click BackendTests "https://github.com/aprimeiradeads/rachadinha/tree/main/src/test/java/ifsul/agileproject/rachadinha"

    %% Style Definitions
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
