# nikolas452/crypto-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/nikolas452/crypto-tracker
- Repository: https://github.com/nikolas452/crypto-tracker
- Video tour (about a minute): https://gitdiagram.com/nikolas452/crypto-tracker/video

## Overview

This repository is the Stage 0 foundation of a Crypto Tracker API: it starts an Express service, validates configuration, connects MongoDB, and exposes liveness/readiness checks with consistent request logging and error handling. The documented future polling, crypto-data, authentication, watchlist, and alert features are explicitly not part of this stage, so they are omitted. Readiness behavior is documented, but its implementation was not sampled; the graph shows only the supported relationship to its health module.

Main entry points: [`src/app.ts`](https://github.com/nikolas452/crypto-tracker/blob/master/src/app.ts) (Express app), [`src/server.ts`](https://github.com/nikolas452/crypto-tracker/blob/master/src/server.ts) (Process entrypoint), [`src/middlewares/errorHandler.ts`](https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/errorHandler.ts) (Error handler), [`src/lib/logger.ts`](https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/logger.ts) (Application logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and config"]
  node_server["Process entrypoint<br/>[server.ts]"]
  node_config["Validated config<br/>[env.ts]"]
end

subgraph group_http["HTTP service"]
  node_app["Express app<br/>[app.ts]"]
  node_health_routes["Health routes<br/>[health.routes.ts]"]
  node_request_id["Request IDs<br/>[requestId.ts]"]
  node_request_logger["Request logging<br/>[requestLogger.ts]"]
  node_not_found["Not-found handler<br/>[notFoundHandler.ts]"]
  node_error_handler["Error handler<br/>[errorHandler.ts]"]
end

subgraph group_support["Infrastructure support"]
  node_health_check["Readiness checks<br/>[health.ts]"]
  node_errors["Error types<br/>[errors.ts]"]
  node_logger["Application logger<br/>[logger.ts]"]
  node_db["Mongo connection<br/>[connect.ts]"]
end

node_operator(("Runtime environment"))
node_client(("HTTP client"))
node_mongo[("MongoDB")]

node_operator -->|"provides environment"| node_config
node_server -->|"reads config"| node_config
node_server -->|"logs lifecycle"| node_logger
node_server -->|"connects / disconnects"| node_db
node_db -->|"connects"| node_mongo
node_server -->|"creates after connect"| node_app
node_server -->|"listens for requests"| node_client
node_client -->|"sends HTTP requests"| node_server
node_app -->|"registers middleware"| node_request_id
node_app -->|"registers middleware"| node_request_logger
node_app -->|"mounts routes"| node_health_routes
node_app -->|"registers fallback"| node_not_found
node_app -->|"registers last"| node_error_handler
node_health_routes -->|"runs readiness checks"| node_health_check
node_health_check -->|"checks connectivity"| node_mongo
node_error_handler -->|"handles app errors"| node_errors
node_error_handler -->|"reads request ID"| node_request_id
node_error_handler -->|"logs failures"| node_logger
node_request_logger -->|"logs requests"| node_logger
node_not_found -->|"creates not-found error"| node_errors

click node_server "https://github.com/nikolas452/crypto-tracker/blob/master/src/server.ts"
click node_config "https://github.com/nikolas452/crypto-tracker/blob/master/src/config/env.ts"
click node_app "https://github.com/nikolas452/crypto-tracker/blob/master/src/app.ts"
click node_health_routes "https://github.com/nikolas452/crypto-tracker/blob/master/src/routes/health.routes.ts"
click node_health_check "https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/health.ts"
click node_request_id "https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/requestId.ts"
click node_request_logger "https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/requestLogger.ts"
click node_not_found "https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/notFoundHandler.ts"
click node_error_handler "https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/errorHandler.ts"
click node_errors "https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/errors.ts"
click node_logger "https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/logger.ts"
click node_db "https://github.com/nikolas452/crypto-tracker/blob/master/src/db/connect.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_config,node_client toneBlue
class node_app,node_health_routes,node_request_id,node_request_logger,node_not_found,node_error_handler,node_mongo toneAmber
class node_health_check,node_errors,node_logger,node_db toneMint
class node_operator toneIndigo
```

## Components

### Startup and config

- [Process entrypoint](https://github.com/nikolas452/crypto-tracker/blob/master/src/server.ts): `src/server.ts`
- [Validated config](https://github.com/nikolas452/crypto-tracker/blob/master/src/config/env.ts): `src/config/env.ts`

### HTTP service

- [Express app](https://github.com/nikolas452/crypto-tracker/blob/master/src/app.ts): `src/app.ts`
- [Health routes](https://github.com/nikolas452/crypto-tracker/blob/master/src/routes/health.routes.ts): `src/routes/health.routes.ts`
- [Request IDs](https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/requestId.ts): `src/middlewares/requestId.ts`
- [Request logging](https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/requestLogger.ts): `src/middlewares/requestLogger.ts`
- [Not-found handler](https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/notFoundHandler.ts): `src/middlewares/notFoundHandler.ts`
- [Error handler](https://github.com/nikolas452/crypto-tracker/blob/master/src/middlewares/errorHandler.ts): `src/middlewares/errorHandler.ts`

### Infrastructure support

- [Readiness checks](https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/health.ts): `src/lib/health.ts`
- [Error types](https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/errors.ts): `src/lib/errors.ts`
- [Application logger](https://github.com/nikolas452/crypto-tracker/blob/master/src/lib/logger.ts): `src/lib/logger.ts`
- [Mongo connection](https://github.com/nikolas452/crypto-tracker/blob/master/src/db/connect.ts): `src/db/connect.ts`

### Other components

- **Runtime environment**
- **HTTP client**
- **MongoDB**

## Connections

- Runtime environment → Validated config: provides environment
- Process entrypoint → Validated config: reads config
- Process entrypoint → Application logger: logs lifecycle
- Process entrypoint → Mongo connection: connects / disconnects
- Mongo connection → MongoDB: connects
- Process entrypoint → Express app: creates after connect
- Process entrypoint → HTTP client: listens for requests
- HTTP client → Process entrypoint: sends HTTP requests
- Express app → Request IDs: registers middleware
- Express app → Request logging: registers middleware
- Express app → Health routes: mounts routes
- Express app → Not-found handler: registers fallback
- Express app → Error handler: registers last
- Health routes → Readiness checks: runs readiness checks
- Readiness checks → MongoDB: checks connectivity
- Error handler → Error types: handles app errors
- Error handler → Request IDs: reads request ID
- Error handler → Application logger: logs failures
- Request logging → Application logger: logs requests
- Not-found handler → Error types: creates not-found error
