# canyavuzdb/finance-app architecture

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

## Overview

##### Project Type & Purpose
- The project is a full-stack finance application that combines a .NET backend (API) with a TypeScript/React frontend.
- Its core purpose is to handle financial operations (e.g., managing user accounts, stocks, portfolios, and comments) with the API and provide a web interface for users. The system also utilizes Docker for containerizing the server and appears to use Azure Data Studio for database visualization.

##### Analyzing the File Structure
- Top-level directories:
- FinanceApp/api: Contains the backend code (controllers, models, data-access (repositories, EF Core’s ApplicationDBContext), DTOs, services, and migrations). Controllers include AccountController, CommentController, PortfolioController, and StockController.
- FinanceApp/frontend: Contains the frontend application built in TypeScript/React along with the usual React project structure (public, src, configuration files).
- Key architectural patterns in the API:
- Use of DTOs: Separate objects for data transfer between client and server.
- Repository Pattern: Interfaces and implementations for database operations (e.g., ICommentRepository, IStockRepository, IPortfolioRepository).
- Service Layer: Abstracting external calls and business logic (e.g., FMPService for external financial data and TokenService for authentication).
- Entity Framework Core and Migrations for data persistence and schema evolution.
- Configuration & Deployment:
- Docker is used for containerizing the server, as mentioned in the README.
- CI/CD workflows (.github/workflows/dotnet.yml) indicate continuous integration, building/testing strategies.
- Azure Data Studio is used for visualizing the database.

##### Main Components
a. Frontend:
- React application (TypeScript based) handling user interactions.
b. Backend (API):
- Controllers (Account, Comment, Portfolio, Stock) which expose RESTful endpoints.
- Service Layer:
- Business logic (e.g., TokenService for authentication).
- External API communication (e.g., FMPService for financial data).
- Data Access Layer:
- Repositories (CommentRepository, PortfolioRepository, StockRepository) managing database operations.
- Data models and Entity Framework’s ApplicationDBContext.
- Data Transfer Objects (DTOs) for input/output validation and transformation.
- Migrations to manage and version the database schema.
c. Database:
- Managed via the backend with an ORM (EF Core). Although the specific DB is not directly named, the presence of migrations suggests it is a relational database.
d. Infrastructure & Deployment:
- Docker container for the API server.
- Azure Data Studio for database visualization and management.
- CI/CD Pipeline configured in GitHub Actions.

##### Relationships & Interactions
- The Frontend issues HTTP requests (likely REST API calls) to the Backend.
- The Backend processes these requests through its Controllers which, in turn, interact with the Service and Repository layers.
- The Repository layer uses EF Core’s ApplicationDBContext to perform CRUD operations on the Database.
- External interactions such as calls to the FMP API are handled within the dedicated service (FMPService).
- Docker encapsulates the running API environment, assuring consistency in deployment.
- Cloud tools like Azure Data Studio interface with the Database for monitoring, visualization, or management.

##### Architectural Patterns to Emphasize
- Separation of Concerns: Clearly division between frontend and backend responsibilities.
- Layered Architecture in the API: Controllers -> Services -> Repositories -> Database.
- Use of DTOs to decouple internal data models from external API contracts.
- Deployment via Docker to ensure environment isolation and portability.

##### Elements
- Use clear, descriptive labels for each component (e.g., “React Frontend”, “.NET API Controllers”, “Service Layer”, “Repository Layer”, “Database (EF Core)”, “FMP External Service”, “Docker Container”).
- UI components (frontend),
- API layers (controllers, services, repositories),
- Infrastructure components (database, Docker container, external services).
- That the deployment (Docker) and data visualization (Azure Data Studio) tools are clearly depicted as part of the operational ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TD
    FE["React Frontend"]:::frontend
    CI["CI/CD Pipeline"]:::ci

    subgraph "Backend API (Docker Container)"
        API_C[".NET API Controllers"]:::api
        API_DTO["DTOs"]:::api
        API_S["Service Layer"]:::api
        API_TS["Authentication Service"]:::api
        API_FS["FMP External Data Service"]:::api
        API_R["Repository Layer"]:::api
        API_M["Database Migrations"]:::api
    end

    I["Database (EF Core)"]:::database
    ADS["Azure Data Studio"]:::infra

    FE -->|"HTTPcalls"| API_C
    CI -->|"Deploy"| API_C
    API_C -->|"UsesDTOs"| API_DTO
    API_C -->|"InvokeBusiness"| API_S
    API_S -->|"Calls"| API_TS
    API_S -->|"Calls"| API_FS
    API_S -->|"CRUDoperations"| API_R
    API_R -->|"EFCore"| I
    API_M -->|"Updateschema"| I
    ADS -->|"Manage"| I

    click FE "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/frontend"
    click API_C "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/api/Controllers"
    click API_DTO "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/api/Dtos"
    click API_S "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/api/Service"
    click API_TS "https://github.com/canyavuzdb/finance-app/blob/master/FinanceApp/api/Service/TokenService.cs"
    click API_FS "https://github.com/canyavuzdb/finance-app/blob/master/FinanceApp/api/Service/FMPService.cs"
    click API_R "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/api/Repository"
    click API_M "https://github.com/canyavuzdb/finance-app/tree/master/FinanceApp/api/Migrations"
    click I "https://github.com/canyavuzdb/finance-app/blob/master/FinanceApp/api/Data/ApplicationDBContext.cs"
    click CI "https://github.com/canyavuzdb/finance-app/blob/master/.github/workflows/dotnet.yml"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef api fill:#F2C1C1,stroke:#000,stroke-width:2px;
    classDef database fill:#FFE4B5,stroke:#000,stroke-width:2px;
    classDef ci fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef infra fill:#E6E6FA,stroke:#000,stroke-width:2px;
```
