# cfqueiroz/b3-invest architecture

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

- Interactive diagram: https://gitdiagram.com/cfqueiroz/b3-invest
- Repository: https://github.com/cfqueiroz/b3-invest

## Overview

##### Main components
- Front-End Client: The Angular application in “calc-b3” (including its app module, components such as “calculadora-cdb.component”, services like “calculadora-cdb.service”, and configuration files found in package.json and angular.json).
- Back-End API: The ASP.NET application in “b3-invest” which contains:
- Controllers (e.g., CdbController, HomeController) that expose HTTP endpoints.
- Services (e.g., CdbService) and interfaces (e.g., ICdbService) encapsulating business logic.
- Configuration and startup classes (e.g., from App_Start such as UnityConfig, RouteConfig, WebApiConfig) that set up dependency injection (using Unity) and routing.
- The “Areas/HelpPage” which documents the API.
- Testing Suite: The “b3-invest.Tests” project that contains tests for controllers and services.
- External Entities: End user’s browser accessing the front-end and making HTTP calls to the API.

##### System relationships and interactions
- Within the back-end API, illustrate the separation of concerns by showing:
- Controllers handling incoming requests.
- Services implementing business logic (using dependency injection configured via Unity).
- Models (e.g., CdbRequest and CdbResponse) used to transfer data between layers.

##### Architectural patterns and principles
- Use the Model-View-Controller (MVC) pattern on the back-end:
- Controllers for handling HTTP requests.
- Services and interfaces for business logic abstraction.
- Models for data representation.
- Use of dependency injection (via “UnityConfig”) in the ASP.NET project.
- On the front-end, note that Angular’s component-based and service-driven architecture is used.
- The separation between the API and the front-end (client-server architecture) is a key principle here.

##### Relevant technologies and frameworks
- ASP.NET Web API (including routing, configuration, and DI via Unity).
- Angular framework for the front-end, along with its TypeScript-based components and services.
- Visual Studio 2022 as the development environment and test execution tool.
- Standard testing frameworks utilized in the “b3-invest.Tests” project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global external entity
    Browser["User Browser"]:::external

    %% Front-End Layer
    subgraph "Angular Front-End"
        AngularApp["Calc-B3 Angular Application"]:::frontend
        AppModule["App Module & Configurations"]:::frontend
        CalculadoraComponent["CalculadoraCDB Component"]:::frontend
        CalculadoraService["CalculadoraCDB Service"]:::frontend
    end

    %% Back-End API Layer
    subgraph "B3-Invest API"
        subgraph "Controllers"
            CdbController["CdbController"]:::backend
            HomeController["HomeController"]:::backend
        end
        subgraph "Services & Interfaces"
            CdbService["CdbService"]:::backend
            ICdbService["ICdbService"]:::backend
        end
        subgraph "Data Models"
            CdbRequest["CdbRequest"]:::backend
            CdbResponse["CdbResponse"]:::backend
        end
        subgraph "Configuration & Startup"
            UnityConfig["UnityConfig"]:::backend
            RouteConfig["RouteConfig"]:::backend
            WebApiConfig["WebApiConfig"]:::backend
        end
        HelpPage["HelpPage (API Documentation)"]:::backend
    end

    %% Testing Suite
    subgraph "Test Suite (b3-invest.Tests)"
        ControllerTests["CdbControllerTests"]:::testing
        ServiceTests["CdbServiceTests"]:::testing
    end

    %% Connections
    Browser -->|"HTTP_requests"| AngularApp
    AngularApp -->|"API_calls"| CdbController

    %% API internal flow
    CdbController -->|"calls"| CdbService
    HomeController -->|"routes"| CdbService
    CdbService -->|"processes"| CdbRequest
    CdbService -->|"generates"| CdbResponse

    %% DI and Configuration flow (annotation)
    UnityConfig ---|"Configures_DI"| CdbService
    RouteConfig ---|"Sets_Routing"| CdbController
    WebApiConfig ---|"Configures_API"| CdbController

    %% HelpPage annotation
    CdbController ---|"Documented_in"| HelpPage

    %% Test suite interactions
    ControllerTests ---|"tests"| CdbController
    ServiceTests ---|"tests"| CdbService

    %% Click Events for Front-End
    click AngularApp "https://github.com/cfqueiroz/b3-invest/tree/master/calc-b3"
    click AppModule "https://github.com/cfqueiroz/b3-invest/tree/master/calc-b3/src/app"
    click CalculadoraComponent "https://github.com/cfqueiroz/b3-invest/tree/master/calc-b3/src/app/calculadora-cdb"
    click CalculadoraService "https://github.com/cfqueiroz/b3-invest/blob/master/calc-b3/src/app/services/calculadora-cdb.service.ts"

    %% Click Events for Back-End API - Controllers
    click CdbController "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Controllers/CdbController.cs"
    click HomeController "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Controllers/HomeController.cs"

    %% Click Events for Back-End API - Services & Interfaces
    click CdbService "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Services/CdbService.cs"
    click ICdbService "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Interfaces/ICdbService.cs"

    %% Click Events for Back-End API - Data Models
    click CdbRequest "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Models/CdbRequest.cs"
    click CdbResponse "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/Models/CdbResponse.cs"

    %% Click Events for Back-End API - Configuration & Startup
    click UnityConfig "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/App_Start/UnityConfig.cs"
    click RouteConfig "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/App_Start/RouteConfig.cs"
    click WebApiConfig "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest/App_Start/WebApiConfig.cs"

    %% Click Event for API Documentation
    click HelpPage "https://github.com/cfqueiroz/b3-invest/tree/master/b3-invest/Areas/HelpPage"

    %% Click Events for Testing Suite
    click ControllerTests "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest.Tests/Controllers/CdbControllerTests.cs"
    click ServiceTests "https://github.com/cfqueiroz/b3-invest/blob/master/b3-invest.Tests/Services/CdbServiceTests.cs"

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