# farooq13/tradary architecture

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

- Interactive diagram: https://gitdiagram.com/farooq13/tradary
- Repository: https://github.com/farooq13/tradary

## Overview

Tradary is an Anchor/Solana on-chain trading journal. A wallet initializes a profile, then creates tagged trade records, can append notes while trades are open, and closes trades to record realized PnL and update aggregate statistics. The account layer stores user profiles, trades, and tags as separate on-chain accounts. The README is empty; edges reflect only the supplied instruction and account excerpts. The profile-update instruction is included, but its specific effects are not inferred from its path alone.

Main entry points: [`programs/tradary/src/state/user_account.rs`](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/user_account.rs) (User profile and stats), [`programs/tradary/src/instructions/create_trade.rs`](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_trade.rs) (Create trade), [`programs/tradary/src/instructions/close_trade.rs`](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/close_trade.rs) (Close trade), [`programs/tradary/src/instructions/create_tag.rs`](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_tag.rs) (Create tag)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Journal operations"]
  node_initialize["Initialize profile<br/>[initialize_user.rs]"]
  node_profile_update["Update profile"]
  node_create_trade["Create trade<br/>[create_trade.rs]"]
  node_close_trade["Close trade<br/>[close_trade.rs]"]
  node_add_notes["Append notes<br/>[add_trade_notes.rs]"]
  node_create_tag["Create tag<br/>[create_tag.rs]"]
end

subgraph group_records["On-chain records"]
  node_user_account[("User profile and stats<br/>[user_account.rs]")]
  node_trade_account[("Trade record<br/>[trade_account.rs]")]
  node_tag_account[("Trade tag<br/>[tag_account.rs]")]
end

node_wallet(("Trader wallet"))

node_wallet -->|"initializes"| node_initialize
node_initialize -->|"creates"| node_user_account
node_wallet -->|"creates"| node_create_trade
node_create_trade -->|"creates"| node_trade_account
node_create_trade -->|"increments counter"| node_user_account
node_wallet -->|"closes"| node_close_trade
node_close_trade -->|"records exit"| node_trade_account
node_close_trade -->|"updates stats"| node_user_account
node_wallet -->|"appends notes"| node_add_notes
node_add_notes -->|"updates notes"| node_trade_account
node_wallet -->|"creates tag"| node_create_tag
node_create_tag -->|"creates"| node_tag_account
node_create_tag -->|"increments count"| node_user_account

click node_initialize "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/initialize_user.rs"
click node_profile_update "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/update_user_profile.rs"
click node_create_trade "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_trade.rs"
click node_close_trade "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/close_trade.rs"
click node_add_notes "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/add_trade_notes.rs"
click node_create_tag "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_tag.rs"
click node_user_account "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/user_account.rs"
click node_trade_account "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/trade_account.rs"
click node_tag_account "https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/tag_account.rs"

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_initialize,node_profile_update,node_create_trade,node_close_trade,node_add_notes,node_create_tag toneBlue
class node_user_account,node_trade_account,node_tag_account toneAmber
class node_wallet toneIndigo
```

## Components

### Journal operations

- [Initialize profile](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/initialize_user.rs): `programs/tradary/src/instructions/initialize_user.rs`
- [Update profile](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/update_user_profile.rs): `programs/tradary/src/instructions/update_user_profile.rs`
- [Create trade](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_trade.rs): `programs/tradary/src/instructions/create_trade.rs`
- [Close trade](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/close_trade.rs): `programs/tradary/src/instructions/close_trade.rs`
- [Append notes](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/add_trade_notes.rs): `programs/tradary/src/instructions/add_trade_notes.rs`
- [Create tag](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/instructions/create_tag.rs): `programs/tradary/src/instructions/create_tag.rs`

### On-chain records

- [User profile and stats](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/user_account.rs): `programs/tradary/src/state/user_account.rs`
- [Trade record](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/trade_account.rs): `programs/tradary/src/state/trade_account.rs`
- [Trade tag](https://github.com/farooq13/tradary/blob/main/programs/tradary/src/state/tag_account.rs): `programs/tradary/src/state/tag_account.rs`

### Other components

- **Trader wallet**

## Connections

- Trader wallet → Initialize profile: initializes (evidence: `programs/tradary/src/instructions/initialize_user.rs`)
- Initialize profile → User profile and stats: creates (evidence: `programs/tradary/src/instructions/initialize_user.rs`)
- Trader wallet → Create trade: creates (evidence: `programs/tradary/src/instructions/create_trade.rs`)
- Create trade → Trade record: creates (evidence: `programs/tradary/src/instructions/create_trade.rs`)
- Create trade → User profile and stats: increments counter (evidence: `programs/tradary/src/instructions/create_trade.rs`)
- Trader wallet → Close trade: closes (evidence: `programs/tradary/src/instructions/close_trade.rs`)
- Close trade → Trade record: records exit (evidence: `programs/tradary/src/instructions/close_trade.rs`)
- Close trade → User profile and stats: updates stats (evidence: `programs/tradary/src/instructions/close_trade.rs`)
- Trader wallet → Append notes: appends notes (evidence: `programs/tradary/src/instructions/add_trade_notes.rs`)
- Append notes → Trade record: updates notes (evidence: `programs/tradary/src/instructions/add_trade_notes.rs`)
- Trader wallet → Create tag: creates tag (evidence: `programs/tradary/src/instructions/create_tag.rs`)
- Create tag → Trade tag: creates (evidence: `programs/tradary/src/instructions/create_tag.rs`)
- Create tag → User profile and stats: increments count (evidence: `programs/tradary/src/instructions/create_tag.rs`)
