# naamaevenozz/investments-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/naamaevenozz/investments-simulator
- Repository: https://github.com/naamaevenozz/investments-simulator

## Overview

Investment Simulator lets a user choose a virtual investment, submit it for queued processing, and see account changes and completion notifications in real time. The client fetches account data and investment options over HTTP, while SignalR carries live updates; the server validates and queues requests, persists investments, and processes their completion. The graph includes the principal domain models and the database layer. Some relationships are based on the supplied source index or README because those source excerpts were not provided.

Main entry points: [`investments-server/Services/InvestmentService.cs`](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentService.cs) (Investment service), [`investments-server/Controllers/InvestmentController.cs`](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Controllers/InvestmentController.cs) (Investment API), [`investments-client/src/App.tsx`](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-client/src/App.tsx) (Investment UI), [`investments-server/Services/InvestmentQueueWorker.cs`](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentQueueWorker.cs) (Queue worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_app["Investment UI<br/>[App.tsx]"]
  node_webvitals["Web vitals<br/>[reportWebVitals.ts]"]
end

subgraph group_api["API and realtime"]
  node_controller["Investment API"]
  node_hub["Update hub<br/>[InvestmentHub.cs]"]
end

subgraph group_processing["Investment processing"]
  node_queue["Request queue<br/>[InvestmentQueue.cs]"]
  node_worker["Queue worker"]
  node_background["Completion monitor"]
end

subgraph group_domain["Domain and persistence"]
  node_service["Investment service"]
  node_context["Database context"]
  node_database[("SQLite database<br/>[investments.db]")]
  node_request["Investment request<br/>[InvestRequest.cs]"]
  node_option["Investment option"]
  node_account["User account<br/>[UserAccount.cs]"]
  node_active["Active investment"]
  node_base["Investment fields<br/>[BaseInvestment.cs]"]
end

node_user(("Investor"))

node_user -->|"uses"| node_app
node_app -->|"requests data"| node_controller
node_app -->|"submits investment"| node_controller
node_app -->|"subscribes"| node_hub
node_controller -->|"fetches account"| node_service
node_controller -->|"validates request"| node_service
node_controller -->|"enqueues request"| node_queue
node_queue -->|"stores request"| node_request
node_worker -->|"dequeues request"| node_queue
node_worker -->|"starts investment"| node_service
node_worker -->|"sends updates"| node_hub
node_background -->|"checks completion"| node_service
node_background -->|"sends completion"| node_hub
node_service -->|"reads and writes"| node_context
node_context -.->|"persists data"| node_database
node_service -->|"uses options"| node_option
node_service -->|"loads account"| node_account
node_service -->|"creates and completes"| node_active
node_active -->|"inherits fields"| node_base
node_account -->|"holds investments"| node_active

click node_app "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-client/src/App.tsx"
click node_webvitals "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-client/src/reportWebVitals.ts"
click node_controller "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Controllers/InvestmentController.cs"
click node_hub "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Hubs/InvestmentHub.cs"
click node_queue "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentQueue.cs"
click node_worker "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentQueueWorker.cs"
click node_background "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentBackgroundService.cs"
click node_service "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentService.cs"
click node_context "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Data/InvestmentDbContext.cs"
click node_database "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/investments.db"
click node_request "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/InvestRequest.cs"
click node_option "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/InvestmentOption.cs"
click node_account "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/UserAccount.cs"
click node_active "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/ActiveInvestment.cs"
click node_base "https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/BaseInvestment.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_webvitals toneBlue
class node_controller,node_hub toneAmber
class node_queue,node_worker,node_background toneMint
class node_service,node_context,node_database,node_request,node_option,node_account,node_active,node_base toneRose
class node_user toneIndigo
```

## Components

### Client

- [Investment UI](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-client/src/App.tsx): `investments-client/src/App.tsx`
- [Web vitals](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-client/src/reportWebVitals.ts): `investments-client/src/reportWebVitals.ts`

### API and realtime

- [Investment API](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Controllers/InvestmentController.cs): `investments-server/Controllers/InvestmentController.cs`
- [Update hub](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Hubs/InvestmentHub.cs): `investments-server/Hubs/InvestmentHub.cs`

### Investment processing

- [Request queue](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentQueue.cs): `investments-server/Services/InvestmentQueue.cs`
- [Queue worker](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentQueueWorker.cs): `investments-server/Services/InvestmentQueueWorker.cs`
- [Completion monitor](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentBackgroundService.cs): `investments-server/Services/InvestmentBackgroundService.cs`

### Domain and persistence

- [Investment service](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Services/InvestmentService.cs): `investments-server/Services/InvestmentService.cs`
- [Database context](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Data/InvestmentDbContext.cs): `investments-server/Data/InvestmentDbContext.cs`
- [SQLite database](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/investments.db): `investments-server/investments.db`
- [Investment request](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/InvestRequest.cs): `investments-server/Models/InvestRequest.cs`
- [Investment option](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/InvestmentOption.cs): `investments-server/Models/InvestmentOption.cs`
- [User account](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/UserAccount.cs): `investments-server/Models/UserAccount.cs`
- [Active investment](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/ActiveInvestment.cs): `investments-server/Models/ActiveInvestment.cs`
- [Investment fields](https://github.com/naamaevenozz/investments-simulator/blob/main/investments-server/Models/BaseInvestment.cs): `investments-server/Models/BaseInvestment.cs`

### Other components

- **Investor**

## Connections

- Investor → Investment UI: uses (evidence: `README.md`)
- Investment UI → Investment API: requests data (evidence: `investments-client/src/App.tsx`)
- Investment UI → Investment API: submits investment (evidence: `investments-client/src/App.tsx`)
- Investment UI → Update hub: subscribes (evidence: `investments-client/src/App.tsx`)
- Investment API → Investment service: fetches account (evidence: `investments-server/Controllers/InvestmentController.cs`)
- Investment API → Investment service: validates request (evidence: `investments-server/Controllers/InvestmentController.cs`)
- Investment API → Request queue: enqueues request (evidence: `investments-server/Controllers/InvestmentController.cs`)
- Request queue → Investment request: stores request (evidence: `investments-server/Services/InvestmentQueue.cs`)
- Queue worker → Request queue: dequeues request (evidence: `investments-server/Services/InvestmentQueueWorker.cs`)
- Queue worker → Investment service: starts investment (evidence: `investments-server/Services/InvestmentQueueWorker.cs`)
- Queue worker → Update hub: sends updates (evidence: `investments-server/Services/InvestmentQueueWorker.cs`)
- Completion monitor → Investment service: checks completion (evidence: `investments-server/Services/InvestmentBackgroundService.cs`)
- Completion monitor → Update hub: sends completion (evidence: `investments-server/Services/InvestmentBackgroundService.cs`)
- Investment service → Database context: reads and writes (evidence: `investments-server/Services/InvestmentService.cs`)
- Database context → SQLite database: persists data
- Investment service → Investment option: uses options (evidence: `investments-server/Services/InvestmentService.cs`)
- Investment service → User account: loads account (evidence: `investments-server/Services/InvestmentService.cs`)
- Investment service → Active investment: creates and completes (evidence: `investments-server/Services/InvestmentService.cs`)
- Active investment → Investment fields: inherits fields (evidence: `investments-server/Models/ActiveInvestment.cs`)
- User account → Active investment: holds investments (evidence: `investments-server/Models/UserAccount.cs`)
