# mefr-arch/tradingjournal architecture

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

- Interactive diagram: https://gitdiagram.com/mefr-arch/tradingjournal
- Repository: https://github.com/mefr-arch/tradingjournal

## Overview

Trading Journal is a Spring Boot API for recording trades and reviewing performance. Clients submit validated trade data to the controller, which delegates CRUD and statistics requests to the service; the service validates and calculates PnL, then uses the repository to access persisted trades. Statistics are aggregated from retrieved trades into a response DTO. The README also documents Swagger/OpenAPI, but its configuration is not represented in the sampled source. Edges reflect sampled calls; database wiring is inferred from the Spring Data repository and documented PostgreSQL/H2 stack.

Main entry points: [`src/main/java/com/feranmi/trading_journal/service/TradeService.java`](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/service/TradeService.java) (Trade service), [`src/main/java/com/feranmi/trading_journal/controller/TradeController.java`](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/controller/TradeController.java) (Trade controller), [`src/main/java/com/feranmi/trading_journal/model/Trade.java`](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/model/Trade.java) (Trade entity), [`src/main/java/com/feranmi/trading_journal/repository/TradeRepo.java`](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/repository/TradeRepo.java) (Trade repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_controller["Trade controller"]
end

subgraph group_domain["Trade domain"]
  node_service["Trade service<br/>[TradeService.java]"]
  node_trade["Trade entity<br/>[Trade.java]"]
  node_direction["Trade direction<br/>[Direction.java]"]
end

subgraph group_persistence["Persistence and stats"]
  node_repo["Trade repository<br/>[TradeRepo.java]"]
  node_database[("Trade database")]
  node_stats["Stats response"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_controller
node_controller -->|"returns results"| node_client
node_controller -->|"delegates requests"| node_service
node_service -->|"reads and writes"| node_repo
node_service -->|"validates and calculates"| node_trade
node_trade -->|"checks direction"| node_direction
node_repo -->|"persists trades"| node_database
node_service -->|"builds statistics"| node_stats

click node_controller "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/controller/TradeController.java"
click node_service "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/service/TradeService.java"
click node_trade "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/model/Trade.java"
click node_direction "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/model/Direction.java"
click node_repo "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/repository/TradeRepo.java"
click node_stats "https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/dto/TradeStatsResponse.java"

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_controller,node_client toneBlue
class node_service,node_trade,node_direction toneAmber
class node_repo,node_database,node_stats toneMint
```

## Components

### API

- [Trade controller](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/controller/TradeController.java): `src/main/java/com/feranmi/trading_journal/controller/TradeController.java`

### Trade domain

- [Trade service](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/service/TradeService.java): `src/main/java/com/feranmi/trading_journal/service/TradeService.java`
- [Trade entity](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/model/Trade.java): `src/main/java/com/feranmi/trading_journal/model/Trade.java`
- [Trade direction](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/model/Direction.java): `src/main/java/com/feranmi/trading_journal/model/Direction.java`

### Persistence and stats

- [Trade repository](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/repository/TradeRepo.java): `src/main/java/com/feranmi/trading_journal/repository/TradeRepo.java`
- **Trade database**
- [Stats response](https://github.com/mefr-arch/tradingjournal/blob/main/src/main/java/com/feranmi/trading_journal/dto/TradeStatsResponse.java): `src/main/java/com/feranmi/trading_journal/dto/TradeStatsResponse.java`

### Other components

- **API client**

## Connections

- API client → Trade controller: sends requests
- Trade controller → API client: returns results
- Trade controller → Trade service: delegates requests
- Trade service → Trade repository: reads and writes
- Trade service → Trade entity: validates and calculates
- Trade entity → Trade direction: checks direction
- Trade repository → Trade database: persists trades
- Trade service → Stats response: builds statistics
