# mohmmedbelhadj/wallet-api architecture

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

- Interactive diagram: https://gitdiagram.com/mohmmedbelhadj/wallet-api
- Repository: https://github.com/mohmmedbelhadj/wallet-api

## Overview

Wallet API serves wallet lookup/listing, transfers, and per-wallet transfer history. HTTP requests enter through the Starlette app and wallet routes, where Pydantic DTOs validate requests and shape responses; the service enforces transfer rules before repository operations query or update PostgreSQL. The repository also records transfers and retrieves history. The README is empty, so capabilities and relationships here are based on the sampled source; models.py is empty.

Main entry points: [`src/wallet/repositories.py`](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/repositories.py) (Wallet repository), [`main.py`](https://github.com/mohmmedbelhadj/wallet-api/blob/main/main.py) (Starlette app), [`src/wallet/routes.py`](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/routes.py) (Wallet routes), [`src/wallet/services.py`](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/services.py) (Wallet service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP interface"]
  node_app["Starlette app<br/>[main.py]"]
  node_wallet_routes["Wallet routes<br/>[routes.py]"]
  node_health["Health check<br/>[main.py]"]
  node_dto["Request/response DTOs<br/>[schemas.py]"]
end

subgraph group_logic["Wallet logic"]
  node_service["Wallet service<br/>[services.py]"]
end

subgraph group_data["Persistence"]
  node_repository["Wallet repository<br/>[repositories.py]"]
  node_postgres[("PostgreSQL")]
  node_wallet_records[("Wallet records")]
  node_transfer_ledger[("Transfer ledger")]
end

node_client(("HTTP client"))

node_client -->|"sends HTTP"| node_app
node_app -->|"registers routes"| node_wallet_routes
node_app -->|"serves health"| node_health
node_wallet_routes -->|"validates and shapes"| node_dto
node_wallet_routes -->|"calls"| node_service
node_service -->|"delegates"| node_repository
node_repository -->|"queries and updates"| node_postgres
node_repository -->|"reads and updates"| node_wallet_records
node_repository -->|"records and reads"| node_transfer_ledger

click node_app "https://github.com/mohmmedbelhadj/wallet-api/blob/main/main.py"
click node_wallet_routes "https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/routes.py"
click node_health "https://github.com/mohmmedbelhadj/wallet-api/blob/main/main.py"
click node_dto "https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/schemas.py"
click node_service "https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/services.py"
click node_repository "https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/repositories.py"

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_wallet_routes,node_health,node_dto,node_client toneBlue
class node_service toneAmber
class node_repository,node_postgres,node_wallet_records,node_transfer_ledger toneMint
```

## Components

### HTTP interface

- [Starlette app](https://github.com/mohmmedbelhadj/wallet-api/blob/main/main.py): `main.py`
- [Wallet routes](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/routes.py): `src/wallet/routes.py`
- [Health check](https://github.com/mohmmedbelhadj/wallet-api/blob/main/main.py): `main.py`
- [Request/response DTOs](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/schemas.py): `src/wallet/schemas.py`

### Wallet logic

- [Wallet service](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/services.py): `src/wallet/services.py`

### Persistence

- [Wallet repository](https://github.com/mohmmedbelhadj/wallet-api/blob/main/src/wallet/repositories.py): `src/wallet/repositories.py`
- **PostgreSQL**
- **Wallet records**
- **Transfer ledger**

### Other components

- **HTTP client**

## Connections

- HTTP client → Starlette app: sends HTTP (evidence: `main.py`)
- Starlette app → Wallet routes: registers routes (evidence: `main.py`)
- Starlette app → Health check: serves health (evidence: `main.py`)
- Wallet routes → Request/response DTOs: validates and shapes (evidence: `src/wallet/routes.py`)
- Wallet routes → Wallet service: calls (evidence: `src/wallet/routes.py`)
- Wallet service → Wallet repository: delegates (evidence: `src/wallet/services.py`)
- Wallet repository → PostgreSQL: queries and updates (evidence: `src/wallet/repositories.py`)
- Wallet repository → Wallet records: reads and updates (evidence: `src/wallet/repositories.py`)
- Wallet repository → Transfer ledger: records and reads (evidence: `src/wallet/repositories.py`)
