# lazarito444/proyecto-final-tds architecture

> Architecture diagram of the GitHub repository lazarito444/proyecto-final-tds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lazarito444/proyecto-final-tds
- Repository: https://github.com/lazarito444/proyecto-final-tds

## Overview

##### Project Type and Purpose
- This is a full-stack personal-finance management platform (“FinancIA”) with three clients (Web, Mobile, HTTP clients) and a layered ASP.NET Core backend exposing REST endpoints, real-time channels, and async messaging.
- The goal is to let users register, record transactions, view dashboards, set goals, and receive AI-powered recommendations and alerts.

##### Main Components
a. Clients
- Web App (Next.js + React): pages for login, signup, dashboard, transactions.
- Mobile App (Flutter): modules for auth, dashboard, transactions, onboarding.
- HTTP Client (Postman/Swagger – FinancIA.Api.http) for manual testing.
b. API Backend (ASP.NET Core)
- FinancIA.Api (Controllers, JWT authentication, SignalR hubs)
- FinancIA.Core.Application (DTOs, service interfaces, mapping, JwtService)
- FinancIA.Core.Domain (Entities: User, Role, Transaction, Category)
- FinancIA.Infrastructure.Persistence (EF Core DbContext, Configurations, Migrations)
c. Data Stores and Services
- SQL Server (ApplicationContext → Category, Transaction tables)
- RabbitMQ broker for background processing (e.g., bulk imports, notification tasks)
- SignalR Hub for pushing real-time alerts to Web/Mobile
- External OAuth providers (Google, Apple)
- AI/ML Service (classification, recommendations) – could be an internal microservice or external API

##### Relationships and Data Flows
- Web/Mobile clients → HTTP/HTTPS → ASP.NET Core API (JWT Bearer + OAuth flows)
- API → EF Core → SQL Server (synchronous reads/writes)
- API → RabbitMQ (publish events: transaction created, budget exceeded) → Worker/Subscriber → Database or Notification Service
- API ↔ SignalR Hub → real-time messaging to connected clients
- API → AI/ML Service (REST or gRPC calls) for classification and recommendations
- API → External OAuth Providers for social login

##### Architectural Patterns and Principles
- Layered (“Onion”/Clean) architecture: Controllers → Application Services → Domain Entities → Infrastructure
- Separation of concerns: Authentication, Business Logic, Persistence, Presentation are decoupled.
- Asynchronous messaging: decouple long-running tasks via RabbitMQ.
- Real-time updates: use SignalR for push notifications.
- DTO mapping: Automapper for translating between domain and transport models.
- Secure by design: JWT, OAuth, AES encryption, 2FA.

##### Technologies & Frameworks
- Backend: ASP.NET Core Web API, Entity Framework Core, SignalR, RabbitMQ .NET Client
- Database: SQL Server
- Web Frontend: Next.js (React + TypeScript), Axios for HTTP
- Mobile Frontend: Flutter (Dart), Dio for HTTP, shared themes/config
- CI/CD & Deployment: (if present) Dockerfiles, Kubernetes manifests, Azure/AWS pipelines

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients Layer
    subgraph "Clients"
        direction TB
        WebApp["Web App (Next.js + React)"]:::ui
        MobileApp["Mobile App (Flutter)"]:::ui
        HTTPClient["HTTP Client (Postman/Swagger)"]:::ui
    end

    %% API Layer
    subgraph "API Backend (ASP.NET Core)" 
        direction TB
        API["FinancIA.Api"]:::backend
        Controllers["Controllers"]:::backend
        Auth["Auth (JWT Bearer + OAuth)"]:::backend
        SignalR["SignalR Hub"]:::backend
        API --> Controllers
        API --> Auth
        API --> SignalR
    end

    %% Core Application Layer
    subgraph "Core Application Layer" 
        direction TB
        DTOs["DTOs"]:::backend
        ServiceContracts["Service Interfaces"]:::backend
        MappingProfiles["Mapping Profiles"]:::backend
        JwtService["JwtService"]:::backend
    end

    %% Core Domain Layer
    subgraph "Core Domain Layer"
        direction TB
        Entities["Entities (User, Role, Transaction, Category)"]:::backend
    end

    %% Infrastructure Persistence Layer
    subgraph "Infrastructure Persistence"
        direction TB
        DbContext["ApplicationContext (DbContext)"]:::infra
        Configurations["Entity Configurations"]:::infra
        Migrations["Migrations"]:::infra
    end

    %% Infra & External Services
    SQLServer["SQL Server"]:::infra
    RabbitMQ["RabbitMQ Broker"]:::infra
    AIMS["AI/ML Service"]:::external
    OAuthProviders["External OAuth Providers"]:::external

    %% Connections - Clients to API
    WebApp -->|HTTP/HTTPS| API
    MobileApp -->|HTTP/HTTPS| API
    HTTPClient -->|HTTP/HTTPS| API

    %% SignalR real-time
    WebApp <-->|WebSocket| SignalR
    MobileApp <-->|WebSocket| SignalR

    %% API to Core Layers
    Controllers -->|uses| DTOs
    Controllers -->|calls| ServiceContracts
    ServiceContracts -->|maps| MappingProfiles
    ServiceContracts -->|calls| JwtService
    ServiceContracts -->|manipulates| Entities
    Entities -->|persisted by| DbContext
    MappingProfiles -->|configures| Entities
    Configurations -->|applied in| DbContext
    Migrations -->|updates| SQLServer

    %% API to Infra/External
    API -->|SQL Queries| SQLServer
    API -->|AMQP| RabbitMQ
    API -->|REST/gRPC| AIMS
    API -->|OAuth Flows| OAuthProviders

    %% Asynchronous flow
    RabbitMQ -->|events| DbContext

    %% Click Events
    click WebApp "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_web"
    click MobileApp "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_mobile"
    click HTTPClient "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api/FinancIA.Api.http"
    click API "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api"
    click Controllers "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Api/Controllers"
    click Auth "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api/Program.cs"
    click SignalR "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api/Program.cs"
    click ConfigAppSettings "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api/appsettings.json"
    click ConfigAppSettingsDev "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Api/appsettings.Development.json"
    click DTOs "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Core.Application/Dtos"
    click ServiceContracts "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Core.Application/ServiceContracts"
    click MappingProfiles "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Core.Application/Mappings/GeneralProfile.cs"
    click JwtService "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Core.Application/Services/JwtService.cs"
    click Entities "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Core.Domain/Entities"
    click DbContext "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.Infrastructure.Persistence/ApplicationContext.cs"
    click Configurations "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Infrastructure.Persistence/Configurations"
    click Migrations "https://github.com/lazarito444/proyecto-final-tds/tree/main/src/financia_backend/FinancIA.Infrastructure.Persistence/Migrations"
    click SQLServerScript "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/Base_de_datos_FinancIA/Base_de_datos_FinancIA.sql"
    click Solution "https://github.com/lazarito444/proyecto-final-tds/blob/main/src/financia_backend/FinancIA.sln"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#036,stroke-width:1px;
    classDef backend fill:#E0FFE0,stroke:#060,stroke-width:1px;
    classDef infra fill:#FFE0B3,stroke:#C60,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#888,stroke-width:1px;
```
