# neylanio/gostack_challenge2-nodejs architecture

> Architecture diagram of the GitHub repository neylanio/gostack_challenge2-nodejs, 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/neylanio/gostack_challenge2-nodejs
- Repository: https://github.com/neylanio/gostack_challenge2-nodejs

## Overview

This is a small Express transaction API. Requests enter through the server and app, then reach transaction routes for listing, creating, or updating records. The repository keeps transactions in memory and calculates income, outcome, and total balances; services validate transaction types and prevent outcomes exceeding the current balance. The graph follows relationships shown in the sampled source and README; persistence is in-memory, and no external storage is shown.

Main entry points: [`src/routes/transaction.routes.ts`](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/transaction.routes.ts) (Transaction routes), [`src/repositories/TransactionsRepository.ts`](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/repositories/TransactionsRepository.ts) (Transaction repository), [`src/app.ts`](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/app.ts) (Express app), [`src/routes/index.ts`](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/index.ts) (Route registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP runtime"]
  node_server["HTTP server<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_routes["Route registry<br/>[index.ts]"]
  node_transaction_routes["Transaction routes"]
end

subgraph group_domain["Transaction domain"]
  node_create_service["Create service"]
  node_update_service["Update service"]
  node_transaction_model["Transaction model<br/>[Transaction.ts]"]
end

subgraph group_data["In-memory data"]
  node_repository["Transaction repository"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts"| node_routes
node_routes -->|"mounts"| node_transaction_routes
node_transaction_routes -->|"lists and reads balance"| node_repository
node_transaction_routes -->|"executes create"| node_create_service
node_transaction_routes -->|"executes update"| node_update_service
node_create_service -->|"checks and creates"| node_repository
node_update_service -->|"checks and updates"| node_repository
node_repository -->|"constructs records"| node_transaction_model

click node_server "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/server.ts"
click node_app "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/app.ts"
click node_routes "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/index.ts"
click node_transaction_routes "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/transaction.routes.ts"
click node_create_service "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/services/CreateTransactionService.ts"
click node_update_service "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/services/UpdateTransactionService.ts"
click node_repository "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/repositories/TransactionsRepository.ts"
click node_transaction_model "https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/models/Transaction.ts"

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_server,node_app,node_routes,node_transaction_routes,node_client toneBlue
class node_create_service,node_update_service,node_transaction_model toneAmber
class node_repository toneMint
```

## Components

### HTTP runtime

- [HTTP server](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/server.ts): `src/server.ts`
- [Express app](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/app.ts): `src/app.ts`
- [Route registry](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/index.ts): `src/routes/index.ts`
- [Transaction routes](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/routes/transaction.routes.ts): `src/routes/transaction.routes.ts`

### Transaction domain

- [Create service](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/services/CreateTransactionService.ts): `src/services/CreateTransactionService.ts`
- [Update service](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/services/UpdateTransactionService.ts): `src/services/UpdateTransactionService.ts`
- [Transaction model](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/models/Transaction.ts): `src/models/Transaction.ts`

### In-memory data

- [Transaction repository](https://github.com/neylanio/gostack_challenge2-nodejs/blob/master/src/repositories/TransactionsRepository.ts): `src/repositories/TransactionsRepository.ts`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests (evidence: `README.md`)
- HTTP server → Express app: starts (evidence: `src/server.ts`)
- Express app → Route registry: mounts (evidence: `src/app.ts`)
- Route registry → Transaction routes: mounts (evidence: `src/routes/index.ts`)
- Transaction routes → Transaction repository: lists and reads balance (evidence: `src/routes/transaction.routes.ts`)
- Transaction routes → Create service: executes create (evidence: `src/routes/transaction.routes.ts`)
- Transaction routes → Update service: executes update (evidence: `src/routes/transaction.routes.ts`)
- Create service → Transaction repository: checks and creates (evidence: `src/services/CreateTransactionService.ts`)
- Update service → Transaction repository: checks and updates (evidence: `src/services/UpdateTransactionService.ts`)
- Transaction repository → Transaction model: constructs records (evidence: `src/repositories/TransactionsRepository.ts`)
