# prerakhere/wallet-cli architecture

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

- Interactive diagram: https://gitdiagram.com/prerakhere/wallet-cli
- Repository: https://github.com/prerakhere/wallet-cli

## Overview

##### Project type and purpose
- This is a command-line interface (CLI) application written in TypeScript, centered around managing Users, Wallets, and Transactions entirely in memory.
- The README only shows install/start instructions, confirming it’s a small standalone CLI tool rather than a web or distributed service.

##### File structure
- Top-level files:
- main.ts: application entry point
- package.json, tsconfig.json, jest.config.js: build, run, and test configs
- Directories:
- cli/ : CLI bootstrap (`CLI.ts`)
- controllers/ : `CLIAppController.ts` (translates CLI commands into application calls)
- services/ : business logic (`UserService`, `WalletService`, `TransactionService`)
- domain/ : domain entities (`User`, `Wallet`, `Transaction`) and core types
- repositories/ : interfaces + in-memory implementations of repositories
- Pattern: a layered architecture (Presentation → Controller → Service → Repository → Domain)

##### README for additional insights
- No architecture docs or external dependencies beyond Node/TypeScript.
- Implies the architecture must be inferred from code layout.

##### Detailed capture of essential elements
- Main.ts as the composition root: wiring together CLI, Controller, Services, and Repositories

## Diagram (Mermaid)

```mermaid
flowchart TD
    main["main.ts"]:::root

    subgraph "Presentation Layer"
        CLI["CLI"]:::presentation
    end

    subgraph "Controller Layer"
        Controller["CLIAppController"]:::controller
    end

    subgraph "Service Layer"
        US["UserService"]:::service
        WS["WalletService"]:::service
        TSrv["TransactionService"]:::service
    end

    subgraph "Infrastructure Layer"
        subgraph "Interfaces"
            IUR["IUserRepository"]:::repo
            IWR["IWalletRepository"]:::repo
            ITR["ITransactionRepository"]:::repo
        end
        subgraph "In-Memory Implementations"
            IMUR["InMemoryUserRepository"]:::repo
            IMWR["InMemoryWalletRepository"]:::repo
            IMTR["InMemoryTransactionRepository"]:::repo
        end
    end

    subgraph "Domain Layer"
        U["User"]:::domain
        W["Wallet"]:::domain
        T["Transaction"]:::domain
        Core["core.ts"]:::domain
    end

    subgraph "Configuration & Documentation"
        TSConfig["tsconfig.json"]:::config
        Package["package.json"]:::config
        Jest["jest.config.js"]:::config
        Readme["README.md"]:::config
    end

    main --> CLI
    main --> Controller
    main --> US
    main --> WS
    main --> TSrv
    main --> IMUR
    main --> IMWR
    main --> IMTR

    CLI --> Controller
    Controller --> US
    Controller --> WS
    Controller --> TSrv

    US --> IUR
    WS --> IWR
    TSrv --> ITR

    IUR --> IMUR
    IWR --> IMWR
    ITR --> IMTR

    IMUR --> U
    IMWR --> W
    IMTR --> T

    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef controller fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef service fill:#FFFF99,stroke:#333,stroke-width:1px;
    classDef repo fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef domain fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef config fill:#E0E0E0,stroke:#333,stroke-width:1px;
    classDef root fill:#FFFFFF,stroke:#333,stroke-width:1px;

    click CLI "https://github.com/prerakhere/wallet-cli/blob/main/cli/CLI.ts"
    click Controller "https://github.com/prerakhere/wallet-cli/blob/main/controllers/CLIAppController.ts"
    click US "https://github.com/prerakhere/wallet-cli/blob/main/services/UserService.ts"
    click WS "https://github.com/prerakhere/wallet-cli/blob/main/services/WalletService.ts"
    click TSrv "https://github.com/prerakhere/wallet-cli/blob/main/services/TransactionService.ts"
    click U "https://github.com/prerakhere/wallet-cli/blob/main/domain/User.ts"
    click W "https://github.com/prerakhere/wallet-cli/blob/main/domain/Wallet.ts"
    click T "https://github.com/prerakhere/wallet-cli/blob/main/domain/Transaction.ts"
    click Core "https://github.com/prerakhere/wallet-cli/blob/main/domain/core.ts"
    click IUR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/interfaces/IUserRepository.ts"
    click IWR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/interfaces/IWalletRepository.ts"
    click ITR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/interfaces/ITransactionRepository.ts"
    click IMUR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/InMemoryUserRepository.ts"
    click IMWR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/InMemoryWalletRepository.ts"
    click IMTR "https://github.com/prerakhere/wallet-cli/blob/main/repositories/InMemoryTransactionRepository.ts"
    click main "https://github.com/prerakhere/wallet-cli/blob/main/main.ts"
    click TSConfig "https://github.com/prerakhere/wallet-cli/blob/main/tsconfig.json"
    click Package "https://github.com/prerakhere/wallet-cli/blob/main/package.json"
    click Jest "https://github.com/prerakhere/wallet-cli/blob/main/jest.config.js"
    click Readme "https://github.com/prerakhere/wallet-cli/blob/main/README.md"
```
