# sandip124/expensetracker architecture

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

- Interactive diagram: https://gitdiagram.com/sandip124/expensetracker
- Repository: https://github.com/sandip124/expensetracker

## Overview

##### Project Type and Purpose
- ExpenseTracker is a full-stack ASP.NET Core solution for managing incomes and expenses across multiple workspaces.
- It provides both a server‐rendered MVC web application and a RESTful Web API alongside core business logic and data access layers.
- The README confirms its goal: create workspaces and manage transactions (CRUD, reporting, budgets).

##### File Structure Analysis
- Top‐level solution file: ExpenseTracker.sln.
- src folder contains six projects, each representing a layer or component:
- ExpenseTracker.Common – shared helpers (pagination, transaction scope) and generic repository interface.
- ExpenseTracker.Contracts – DTO definitions for request/response messages.
- ExpenseTracker.Core – domain entities, DTOs, exceptions, service/repository interfaces, business logic implementations.
- ExpenseTracker.Infrastructure – EF Core DbContext, migrations, repository implementations, configuration, logging adapters.
- ExpenseTracker.Web – ASP.NET Core MVC web app (views, controllers, view models, services, middleware, DI setup).
- ExpenseTracker.WebApi – ASP.NET Core Web API (controllers, middleware, DI, response wrappers).
- tests folder holds unit tests for entities and core services.

##### Architecture Insights
- Layered architecture (Presentation → Application/Service → Domain → Infrastructure/Data).
- Dependency injection (DiConfig classes in Core, Infrastructure, Web, WebApi).
- Repository pattern with generic and specific repositories.
- Contracts project enforces clear data exchange formats.
- Two frontends leverage the same core/infrastructure: MVC web UI and REST API.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Shared/Common Layer
    subgraph "Shared/Common" 
        direction TB
        TSHelper["TransactionScopeHelper"]:::shared
        Pagination["Pagination"]:::shared
        IGenRepo["IGenericRepository<T>"]:::shared
    end

    %% Contracts Layer
    subgraph "Contracts (DTOs)"
        direction TB
        ReqDTOs["Request DTOs"]:::shared
        ResDTOs["Response DTOs"]:::shared
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Entities["Entities"]:::domain
        Constants["Constants"]:::domain
        Exceptions["Exceptions"]:::domain
        EntityReg["EntityRegisterer"]:::domain
    end

    %% Application / Service Layer
    subgraph "Service Layer"
        direction TB
        SvcInterfaces["Service Interfaces"]:::service
        SvcImpl["Service Implementations"]:::service
        CoreDI["Core DiConfig"]:::service
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        DbContext["AppDbContext"]:::infra
        Migrations["Migrations"]:::infra
        RepoImpl["Repository Implementations"]:::infra
        InfraDI["Infrastructure DiConfig"]:::infra
        Extensions["Extensions"]:::infra
        Configs["Configurations"]:::infra
        Logger["LoggerAdapter"]:::infra
    end

    %% Presentation Layer - MVC Web App
    subgraph "Presentation - MVC Web App"
        direction TB
        WebProg["Program.cs"]:::presentation
        WebStart["Startup.cs"]:::presentation
        WebDI["Web DiConfig"]:::presentation
        Controllers["Controllers"]:::presentation
        Middleware["WorkspaceMiddleware"]:::presentation
        ViewModels["ViewModels"]:::presentation
        Views["Razor Views"]:::presentation
        Assets["Static Assets"]:::presentation
        Providers["Providers"]:::presentation
        Seeding["ISeedingService"]:::presentation
    end

    %% Presentation Layer - Web API
    subgraph "Presentation - Web API"
        direction TB
        ApiProg["Program.cs"]:::presentation
        ApiControllers["Controllers"]:::presentation
        ApiMiddleware["ExceptionMiddleware"]:::presentation
        RespWrappers["Response Wrappers"]:::presentation
        AppSettings["appsettings.json"]:::presentation
    end

    %% Data Store
    DB["Relational Database"]:::external
    Session["Session Store"]:::external
    LoggingExt["Logging Framework"]:::external

    %% Interactions
    Controllers -->|"uses DTOs"| ReqDTOs
    Controllers -->|"uses DTOs"| ResDTOs
    ApiControllers -->|"uses DTOs"| ReqDTOs
    ApiControllers -->|"uses DTOs"| ResDTOs

    Controllers -->|"calls"| SvcInterfaces
    ApiControllers -->|"calls"| SvcInterfaces

    SvcInterfaces -->|"implemented by"| SvcImpl
    SvcImpl -->|"uses"| IGenRepo
    SvcImpl -->|"uses shared helpers"| TSHelper
    SvcImpl -->|"uses pagination"| Pagination

    SvcImpl -->|"depends on"| RepoImpl
    RepoImpl -->|"uses"| DbContext
    DbContext -->|"migrates"| Migrations
    DbContext -->|"maps Entities"| Entities

    RepoImpl -->|"configured by"| InfraDI
    InfraDI -->|"extends"| Extensions
    InfraDI -->|"configures"| Configs
    InfraDI -->|"adapts logging"| Logger

    WebProg -->|"wires DI"| WebDI
    WebStart -->|"configures"| WebDI
    WebDI -->|"registers Core DI"| CoreDI
    WebDI -->|"registers Infra DI"| InfraDI

    ApiProg -->|"wires DI"| InfraDI
    ApiProg -->|"wires DI"| CoreDI
    ApiProg -->|"uses settings"| AppSettings

    Controllers -->|"uses middleware"| Middleware
    ApiControllers -->|"uses middleware"| ApiMiddleware

    DB --> Session
    Logger --> LoggingExt

    %% Click Events
    click TSHelper "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Common/Helpers/TransactionScopeHelper.cs"
    click Pagination "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Common/Pagination/Pagination.cs"
    click IGenRepo "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Common/Repositories/Interface/IGenericRepository.cs"
    click ReqDTOs "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Contracts/Dto/Request"
    click ResDTOs "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Contracts/Dto/Response"
    click Entities "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Core/Entities"
    click Constants "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Core/Constants"
    click Exceptions "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Core/Exceptions"
    click EntityReg "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Core/EntityRegisterer.cs"
    click SvcInterfaces "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Core/Services/Interface"
    click SvcImpl "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Core/Services"
    click CoreDI "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Core/DiConfig.cs"
    click DbContext "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Infrastructure/Data/AppDbContext.cs"
    click Migrations "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Infrastructure/Migrations"
    click RepoImpl "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Infrastructure/Repositories"
    click InfraDI "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Infrastructure/DiConfig.cs"
    click Extensions "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Infrastructure/Extensions"
    click Configs "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Infrastructure/Configurations"
    click Logger "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Infrastructure/Logging/LoggerAdapter.cs"
    click WebProg "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Web/Program.cs"
    click WebStart "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Web/Startup.cs"
    click WebDI "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Web/DiConfig.cs"
    click Controllers "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Web/Controllers"
    click Middleware "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Web/Middleware/WorkspaceMiddleware.cs"
    click ViewModels "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Web/ViewModels"
    click Views "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Web/Views"
    click Assets "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Web/wwwroot"
    click Providers "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.Web/Providers"
    click Seeding "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.Web/Services/ISeedingService.cs"
    click ApiProg "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.WebApi/Program.cs"
    click ApiControllers "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.WebApi/Controllers"
    click ApiMiddleware "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.WebApi/Middleware/ExceptionMiddleware.cs"
    click RespWrappers "https://github.com/sandip124/expensetracker/tree/master/src/ExpenseTracker.WebApi/Response"
    click AppSettings "https://github.com/sandip124/expensetracker/blob/master/src/ExpenseTracker.WebApi/appsettings.json"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#000
    classDef service fill:#d4edda,stroke:#000
    classDef domain fill:#fff3cd,stroke:#000
    classDef infra fill:#f8d7da,stroke:#000
    classDef shared fill:#e2e3e5,stroke:#000
    classDef external fill:#d1ecf1,stroke:#000
```
