# coder-pro10z/money-pilot architecture

> Architecture diagram of the GitHub repository coder-pro10z/money-pilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/coder-pro10z/money-pilot
- Repository: https://github.com/coder-pro10z/money-pilot

## Overview

##### Project Type and Purpose
- MoneyPilot is a full-stack, finance/productivity web application.
- Frontend: Angular SPA for expense tracking, budget planning, analytics.
- Backend: ASP.NET Core Web API (Clean Architecture) exposing secure endpoints, backed by SQL Server via EF Core.

##### File Structure
- Top-level “src” contains four .NET projects:
- MoneyPilot.API – Controllers, middleware, startup, HTTP file
- MoneyPilot.Application – DTOs, service & repository interfaces
- MoneyPilot.Infrastructure – EF Core DbContext, Migrations, Repositories, Services
- MoneyPilot.Domain – Entities, value objects, enums
- Tests in MoneyPilot.Tests (xUnit) exercising Controllers.
- Config files: appsettings.json, launchSettings.json.
- Migrations folder reflects EF Code-First approach.

##### README for Additional Insights
- System uses JWT/ASP.NET Identity for Auth.
- Clean Architecture / Layered design (Frontend → API → Application → Infrastructure → Domain → SQL DB).
- Angular 17, Chart.js/ngx-charts, Angular Material/Tailwind on the client.
- CI/CD via GitHub Actions/Jenkins, deployment targets Azure App Service/Netlify/Vercel.

##### Main Components & Boundaries
a. Client Layer
- Angular SPA running in the user’s browser
- Modules: Auth, Expenses, Budgets, Dashboard, Habits, Investments
b. API Layer
- MoneyPilot.API: Controllers (Auth, Expense, Budget, RecurringTransaction, Home)
- Middleware: JWT Authentication, Logging
- Extensions & Helpers (ClaimsPrincipalExtensions)
c. Application Layer
- Service interfaces (IBudgetService, IExpenseService, etc.)
- DTOs for input/output mapping
- Orchestrates business rules
d. Infrastructure Layer
- EF Core MoneyPilotDbContext (DbSets for Entities)
- Repositories (BudgetRepository, ExpenseRepository, generic Repository)
- UnitOfWork abstraction
- Domain services: RecurringTransactionService, AutoLoginTokenService, Test helpers
- Migrations for schema evolution
e. Domain Layer
- Core Entities (AppUser, Budget, Expense, RecurringTransaction, Category)
- BaseAuditableEntity and Enums (RecurrenceType)
f. Persistence
- SQL Server database
- EF Core Code-First migrations
g. External Services & DevOps
- JWT token issuer (ASP.NET Identity)
- Swagger/OpenAPI docs
- CI/CD pipelines (GitHub Actions, Jenkins, Octopus Deploy)
- Hosting: Azure App Service, Netlify/Vercel for frontend

##### Relationships and Data Flows
1. User in browser (Angular) invokes HTTP(S) → API
2. Controller receives request → validates/authenticates (JWT)
3. Controller calls Application Service via DI
4. Application Service uses UnitOfWork → Repository
5. Repository queries/updates SQL via DbContext
6. DbContext commits transaction → SQL Server
7. Data maps back up the chain through DTOs → Controller → Angular for UI update

##### Architectural Patterns & Principles
- Clean/Layered Architecture: strict separation of concerns
- Dependency Injection at each layer
- Repository + Unit of Work patterns for data access
- DTOs and AutoMapper for boundary mapping
- Code-First Migrations for schema management
- JWT/ASP.NET Identity for secure auth
- Testability: xUnit tests, mockable interfaces

##### Detailed Elements
- Angular modules and HTTP interceptor for JWT
- AuthController issuing tokens
- Expense & Budget Controllers → Application Services interfaces → Concrete Services in Infrastructure
- DbContext + Migrations aligned under Infrastructure
- UnitOfWork coordinating Repositories
- SQL Server (with EF Core) at the bottom

##### Detail
- Where AutoMapper, FluentValidation, Logging live (extensions/middleware)
- Asynchronous vs. synchronous flows if relevant (e.g., recurring transactions scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Angular SPA)" 
        direction TB
        Angular["Angular 17 SPA\nModules: Auth, Expenses, Budgets,\nDashboard, Habits, Investments"]:::frontend
        Interceptor["HTTP Interceptor\n(JWT)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer (MoneyPilot.API)" 
        direction TB
        ControllersDir["Controllers\n(src/MoneyPilot.API/Controllers)"]:::api
        AuthCtrl["AuthController"]:::api
        BudgetCtrl["BudgetController"]:::api
        ExpenseCtrl["ExpenseController"]:::api
        RecurringCtrl["RecurringTransactionController"]:::api
        HomeCtrl["HomeController"]:::api
        Middleware["JWT Authentication\n& Logging Middleware"]:::api
        Extensions["ClaimsPrincipalExtensions"]:::api
        Startup["Program.cs\n& Startup Config"]:::api
        AppSettings["appsettings.json\nappsettings.Development.json"]:::api
        Launch["launchSettings.json"]:::api

        ControllersDir --> AuthCtrl
        ControllersDir --> BudgetCtrl
        ControllersDir --> ExpenseCtrl
        ControllersDir --> RecurringCtrl
        ControllersDir --> HomeCtrl
    end

    %% Application Layer
    subgraph "Application Layer (MoneyPilot.Application)" 
        direction TB
        DTOs["DTOs"]:::app
        Interfaces["Service & Repository\nInterfaces + UnitOfWork"]:::app
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer (MoneyPilot.Infrastructure)" 
        direction TB
        DbContext["MoneyPilotDbContext"]:::infra
        MigrationsDir["Migrations\n(src/MoneyPilot.Infrastructure/Migrations)"]:::infra
        Repos["Repositories\n(Generic, Budget, Expense)"]:::infra
        UoW["UnitOfWork Implementation"]:::infra
        ServicesInfra["Domain Services\n(Recurring, Expense, Budget,\nAutoLoginToken)"]:::infra
        TestHelpers["Test Helpers\n(TestTokenHelper, TestUserService)"]:::infra
    end

    %% Domain Layer
    subgraph "Domain Layer (MoneyPilot.Domain)" 
        direction TB
        Entities["Entities\n(AppUser, Budget, Expense,\nRecurringTransaction, Category)"]:::domain
        BaseEntity["BaseAuditableEntity"]:::domain
        Enums["RecurrenceType Enum"]:::domain
    end

    %% Persistence
    SQL["SQL Server\n(Code-First EF Core)"]:::db

    %% External & DevOps
    subgraph "External & DevOps" 
        direction TB
        Swagger["Swagger/OpenAPI"]:::external
        CI["CI/CD Pipelines\n(GitHub Actions, Jenkins)"]:::external
        Hosting["Azure App Service\nNetlify/Vercel"]:::external
    end

    %% Connections
    Angular -->|"HTTP(S) with JWT"| AuthCtrl
    Angular -->|"HTTP(S) with JWT"| BudgetCtrl
    Angular -->|"HTTP(S) with JWT"| ExpenseCtrl
    Angular -->|"HTTP(S) with JWT"| RecurringCtrl
    Angular -->|"HTTP(S) with JWT"| HomeCtrl

    AuthCtrl -->|"calls"| Interfaces
    BudgetCtrl -->|"calls"| Interfaces
    ExpenseCtrl -->|"calls"| Interfaces
    RecurringCtrl -->|"calls"| Interfaces
    HomeCtrl -->|"calls"| Interfaces

    Middleware --> AuthCtrl
    Middleware --> BudgetCtrl
    Middleware --> ExpenseCtrl

    Interfaces -->|"uses DI"| Repos
    Interfaces -->|"uses DI"| ServicesInfra
    Interfaces -->|"uses DI"| UoW

    Repos --> DbContext
    DbContext --> SQL
    MigrationsDir --> DbContext

    ServicesInfra --> Repos
    TestHelpers --> ServicesInfra

    Swagger --> AuthCtrl
    CI --> Startup
    CI --> Hosting

    SQL -->|"<|-- migration"| MigrationsDir

    %% Click Events
    click ControllersDir "https://github.com/coder-pro10z/money-pilot/tree/main/src/MoneyPilot.API/Controllers"
    click AuthCtrl "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Controllers/AuthController.cs"
    click BudgetCtrl "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Controllers/BudgetController.cs"
    click ExpenseCtrl "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Controllers/ExpenseController.cs"
    click RecurringCtrl "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Controllers/RecurringTransactionController.cs"
    click HomeCtrl "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Controllers/HomeController.cs"
    click Extensions "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Extensions/ClaimsPrincipalExtensions.cs"
    click Startup "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Program.cs"
    click AppSettings "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/appsettings.json"
    click AppSettings "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/appsettings.Development.json"
    click Launch "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.API/Properties/launchSettings.json"

    click DbContext "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Data/MoneyPilotDbContext.cs"
    click MigrationsDir "https://github.com/coder-pro10z/money-pilot/tree/main/src/MoneyPilot.Infrastructure/Migrations"
    click Repos "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Repositories/Repository.cs"
    click Repos "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Repositories/BudgetRepository.cs"
    click Repos "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Repositories/ExpenseRepository.cs"
    click UoW "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Repositories/UnitOfWork.cs"
    click ServicesInfra "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/RecurringTransactionService.cs"
    click ServicesInfra "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/ExpenseService.cs"
    click ServicesInfra "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/BudgetService.cs"
    click ServicesInfra "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/AutoLoginTokenService.cs"
    click TestHelpers "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/TestTokenHelper.cs"
    click TestHelpers "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Infrastructure/Services/TestUserService.cs"

    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/Auth/LoginDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/Auth/RegisterDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/BudgetDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/BudgetResponseDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/ExpenseDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/ExpenseResponseDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/CreateRecurringTransactionDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/RecurringTransactionDto.cs"
    click DTOs "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/DTOs/UpdateRecurringTransactionDto.cs"

    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IBudgetService.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IExpenseService.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IRecurringTransactionService.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IBudgetRepository.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IExpenseRepository.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IRepository.cs"
    click Interfaces "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Application/Interfaces/IUnitofWork.cs"

    click Entities "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Entities/AppUser.cs"
    click Entities "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Entities/Budget.cs"
    click Entities "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Entities/Expense.cs"
    click Entities "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Entities/RecurringTransaction.cs"
    click Entities "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Entities/Category.cs"
    click BaseEntity "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Common/BaseAuditableEntity.cs"
    click Enums "https://github.com/coder-pro10z/money-pilot/blob/main/src/MoneyPilot.Domain/Enums/RecurrenceType.cs"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef api fill:#E8F4FD,stroke:#1C7ED6,color:#1C7ED6;
    classDef app fill:#E6F4EA,stroke:#2F9E44,color:#2F9E44;
    classDef infra fill:#FFF4E6,stroke:#F76707,color:#F76707;
    classDef domain fill:#E9ECEF,stroke:#495057,color:#495057;
    classDef db fill:#FFF3BF,stroke:#FCC419,color:#FCC419,stroke-dasharray: 5 5;
    classDef external fill:#F1F3F5,stroke:#868E96,color:#495057,stroke-dasharray: 5 5;
```
