# teamc-swarchqua/cococash architecture

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

- Interactive diagram: https://gitdiagram.com/teamc-swarchqua/cococash
- Repository: https://github.com/teamc-swarchqua/cococash

## Overview

CocoCash is a digital wallet with a web interface, Cognito authentication, wallet operations, transaction history, and PDF reporting. The principal workflow is a signed-in user loading a wallet, depositing funds or initiating a transfer, and viewing balance/history; the wallet service persists account and transfer state and publishes domain events. The README documents AWS transaction-audit and report-processing capabilities whose detailed wiring is not shown. Edges for those unsampled integrations are omitted or marked unverified rather than inferred from filenames.

Main entry points: [`cococash-wfe/src/App.jsx`](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/App.jsx) (Web application), [`cococash-wallet-ms/src/services/transfer.service.ts`](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/services/transfer.service.ts) (Transfer operations), [`cococash-wallet-ms/src/repositories/account.repository.ts`](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/repositories/account.repository.ts) (Account repository), [`cococash-wfe/src/services/api.js`](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/services/api.js) (Wallet API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web wallet"]
  node_webapp["Web application<br/>[App.jsx]"]
  node_walletcontext["Wallet context<br/>[WalletContext.jsx]"]
  node_webapi["Wallet API client<br/>[api.js]"]
  node_wallet_pages["Wallet screens<br/>[Certificates.jsx]"]
end

subgraph group_identity["Identity"]
  node_authcontext["Auth context<br/>[AuthContext.jsx]"]
  node_cognito_client["Cognito client<br/>[cognito.js]"]
  node_cognito{{"Amazon Cognito"}}
  node_cognito_middleware["JWT middleware"]
end

subgraph group_wallet["Wallet service"]
  node_account_controller["Account routes"]
  node_transfer_controller["Transfer routes"]
  node_account_service["Account operations<br/>[account.service.ts]"]
  node_transfer_service["Transfer operations"]
  node_account_repo["Account repository"]
  node_transfer_repo["Transfer repository"]
  node_account_model["Account model<br/>[account.model.ts]"]
  node_transfer_model["Transfer model<br/>[transfer.model.ts]"]
  node_pg[("PostgreSQL")]
  node_publisher["Event publisher"]
  node_sns["Amazon SNS"]
end

subgraph group_history["Transaction history"]
  node_transaction_ms["Transaction service<br/>[main.go]"]
  node_transaction_handlers["History handlers<br/>[handler.go]"]
  node_transaction_store["History repository<br/>[repository.go]"]
  node_dynamodb[("Amazon DynamoDB")]
end

subgraph group_reports["Reports and utilities"]
  node_report_consumer["Report consumer<br/>[report_consumer.go]"]
  node_pdf_maker["PDF generator<br/>[main.go]"]
  node_account_tool["Account utility<br/>[main.go]"]
  node_link_tool["Link generator<br/>[main.go]"]
end

node_user(("Wallet user"))

node_user -.->|"uses"| node_webapp
node_webapp -->|"provides auth"| node_authcontext
node_webapp -->|"provides wallet"| node_walletcontext
node_webapp -->|"routes to"| node_wallet_pages
node_authcontext -->|"calls"| node_cognito_client
node_cognito_client -.->|"authenticates"| node_cognito
node_walletcontext -->|"requests"| node_webapi
node_webapi -.->|"calls API"| node_account_controller
node_webapi -.->|"calls API"| node_transfer_controller
node_account_controller -->|"delegates"| node_account_service
node_transfer_controller -->|"delegates"| node_transfer_service
node_transfer_controller -->|"requires JWT"| node_cognito_middleware
node_account_service -->|"reads/writes"| node_account_repo
node_transfer_service -->|"reads/writes"| node_account_repo
node_transfer_service -->|"reads/writes"| node_transfer_repo
node_account_repo -->|"maps records"| node_account_model
node_transfer_repo -->|"uses model"| node_transfer_model
node_account_repo -.->|"queries"| node_pg
node_transfer_repo -.->|"queries"| node_pg
node_account_service -->|"publishes events"| node_publisher
node_transfer_service -->|"publishes events"| node_publisher
node_publisher -->|"publishes"| node_sns
node_transaction_ms -.->|"routes"| node_transaction_handlers
node_transaction_handlers -.->|"uses"| node_transaction_store
node_transaction_store -.->|"persists history"| node_dynamodb
node_report_consumer -.->|"dispatches reports"| node_pdf_maker

click node_webapp "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/App.jsx"
click node_authcontext "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/context/AuthContext.jsx"
click node_cognito_client "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/services/cognito.js"
click node_walletcontext "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/context/WalletContext.jsx"
click node_webapi "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/services/api.js"
click node_wallet_pages "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/pages/Certificates.jsx"
click node_account_controller "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/controllers/account.controller.ts"
click node_transfer_controller "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/controllers/transfer.controller.ts"
click node_cognito_middleware "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/middleware/cognito.middleware.ts"
click node_account_service "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/services/account.service.ts"
click node_transfer_service "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/services/transfer.service.ts"
click node_account_repo "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/repositories/account.repository.ts"
click node_transfer_repo "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/repositories/transfer.repository.ts"
click node_account_model "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/models/account.model.ts"
click node_transfer_model "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/models/transfer.model.ts"
click node_publisher "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/events/publishers/transfer.publisher.ts"
click node_transaction_ms "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/main.go"
click node_transaction_handlers "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/handler.go"
click node_transaction_store "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/repository.go"
click node_report_consumer "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/report_consumer.go"
click node_pdf_maker "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-pdf-maker/main.go"
click node_account_tool "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-get-accounts/main.go"
click node_link_tool "https://github.com/teamc-swarchqua/cococash/blob/main/cococash-link-generator/main.go"

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_webapp,node_walletcontext,node_webapi,node_wallet_pages,node_user toneBlue
class node_authcontext,node_cognito_client,node_cognito,node_cognito_middleware toneAmber
class node_account_controller,node_transfer_controller,node_account_service,node_transfer_service,node_account_repo,node_transfer_repo,node_account_model,node_transfer_model,node_pg,node_publisher,node_sns toneMint
class node_transaction_ms,node_transaction_handlers,node_transaction_store,node_dynamodb toneRose
class node_report_consumer,node_pdf_maker,node_account_tool,node_link_tool toneIndigo
```

## Components

### Web wallet

- [Web application](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/App.jsx): `cococash-wfe/src/App.jsx`
- [Wallet context](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/context/WalletContext.jsx): `cococash-wfe/src/context/WalletContext.jsx`
- [Wallet API client](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/services/api.js): `cococash-wfe/src/services/api.js`
- [Wallet screens](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/pages/Certificates.jsx): `cococash-wfe/src/pages/Certificates.jsx`

### Identity

- [Auth context](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/context/AuthContext.jsx): `cococash-wfe/src/context/AuthContext.jsx`
- [Cognito client](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wfe/src/services/cognito.js): `cococash-wfe/src/services/cognito.js`
- **Amazon Cognito**
- [JWT middleware](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/middleware/cognito.middleware.ts): `cococash-wallet-ms/src/middleware/cognito.middleware.ts`

### Wallet service

- [Account routes](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/controllers/account.controller.ts): `cococash-wallet-ms/src/controllers/account.controller.ts`
- [Transfer routes](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/controllers/transfer.controller.ts): `cococash-wallet-ms/src/controllers/transfer.controller.ts`
- [Account operations](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/services/account.service.ts): `cococash-wallet-ms/src/services/account.service.ts`
- [Transfer operations](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/services/transfer.service.ts): `cococash-wallet-ms/src/services/transfer.service.ts`
- [Account repository](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/repositories/account.repository.ts): `cococash-wallet-ms/src/repositories/account.repository.ts`
- [Transfer repository](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/repositories/transfer.repository.ts): `cococash-wallet-ms/src/repositories/transfer.repository.ts`
- [Account model](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/models/account.model.ts): `cococash-wallet-ms/src/models/account.model.ts`
- [Transfer model](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/models/transfer.model.ts): `cococash-wallet-ms/src/models/transfer.model.ts`
- **PostgreSQL**
- [Event publisher](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-wallet-ms/src/events/publishers/transfer.publisher.ts): `cococash-wallet-ms/src/events/publishers/transfer.publisher.ts`
- **Amazon SNS**

### Transaction history

- [Transaction service](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/main.go): `cococash-transaction-ms/main.go`
- [History handlers](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/handler.go): `cococash-transaction-ms/handler.go`
- [History repository](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/repository.go): `cococash-transaction-ms/repository.go`
- **Amazon DynamoDB**

### Reports and utilities

- [Report consumer](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-transaction-ms/report_consumer.go): `cococash-transaction-ms/report_consumer.go`
- [PDF generator](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-pdf-maker/main.go): `cococash-pdf-maker/main.go`
- [Account utility](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-get-accounts/main.go): `cococash-get-accounts/main.go`
- [Link generator](https://github.com/teamc-swarchqua/cococash/blob/main/cococash-link-generator/main.go): `cococash-link-generator/main.go`

### Other components

- **Wallet user**

## Connections

- Wallet user → Web application: uses
- Web application → Auth context: provides auth (evidence: `cococash-wfe/src/App.jsx`)
- Web application → Wallet context: provides wallet (evidence: `cococash-wfe/src/App.jsx`)
- Web application → Wallet screens: routes to (evidence: `cococash-wfe/src/App.jsx`)
- Auth context → Cognito client: calls (evidence: `cococash-wfe/src/context/AuthContext.jsx`)
- Cognito client → Amazon Cognito: authenticates
- Wallet context → Wallet API client: requests (evidence: `cococash-wfe/src/context/WalletContext.jsx`)
- Wallet API client → Account routes: calls API
- Wallet API client → Transfer routes: calls API
- Account routes → Account operations: delegates (evidence: `cococash-wallet-ms/src/controllers/account.controller.ts`)
- Transfer routes → Transfer operations: delegates (evidence: `cococash-wallet-ms/src/controllers/transfer.controller.ts`)
- Transfer routes → JWT middleware: requires JWT (evidence: `cococash-wallet-ms/src/controllers/transfer.controller.ts`)
- Account operations → Account repository: reads/writes (evidence: `cococash-wallet-ms/src/services/account.service.ts`)
- Transfer operations → Account repository: reads/writes (evidence: `cococash-wallet-ms/src/services/transfer.service.ts`)
- Transfer operations → Transfer repository: reads/writes (evidence: `cococash-wallet-ms/src/services/transfer.service.ts`)
- Account repository → Account model: maps records (evidence: `cococash-wallet-ms/src/repositories/account.repository.ts`)
- Transfer repository → Transfer model: uses model (evidence: `cococash-wallet-ms/src/repositories/transfer.repository.ts`)
- Account repository → PostgreSQL: queries
- Transfer repository → PostgreSQL: queries
- Account operations → Event publisher: publishes events (evidence: `cococash-wallet-ms/src/services/account.service.ts`)
- Transfer operations → Event publisher: publishes events (evidence: `cococash-wallet-ms/src/services/transfer.service.ts`)
- Event publisher → Amazon SNS: publishes (evidence: `cococash-wallet-ms/src/events/publishers/transfer.publisher.ts`)
- Transaction service → History handlers: routes
- History handlers → History repository: uses
- History repository → Amazon DynamoDB: persists history
- Report consumer → PDF generator: dispatches reports
