# bunhourlong/lern architecture

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

- Interactive diagram: https://gitdiagram.com/bunhourlong/lern
- Repository: https://github.com/bunhourlong/lern

## Overview

Lern is a small mobile-and-API starter: the mobile app currently renders a React Native starter screen, while the API exposes a health check. The principal API workflow is an HTTP health request routed to a controller, which asks a service to probe PostgreSQL and Redis and returns a shared health result. The API also has boot-time configuration and infrastructure wiring. The tree and excerpts show no mobile-to-API feature workflow; unsampled contracts and migration details are represented only where their paths and connections are supported.

Main entry points: [`apps/api/src/app.module.ts`](https://github.com/bunhourlong/lern/blob/main/apps/api/src/app.module.ts) (App composition), [`apps/api/src/health/health.controller.ts`](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.controller.ts) (Health endpoint), [`apps/api/src/health/health.service.ts`](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.service.ts) (Dependency probes), [`apps/api/src/health/health.module.ts`](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.module.ts) (Health module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_app["Starter screen<br/>[App.tsx]"]
end

subgraph group_api["API runtime"]
  node_api_boot["API bootstrap<br/>[main.ts]"]
  node_app_module["App composition<br/>[app.module.ts]"]
  node_env_config["Environment config<br/>[env.ts]"]
  node_request_id["Request IDs<br/>[request-id.ts]"]
  node_database_setup["Database setup<br/>[database.ts]"]
  node_redis_module["Redis client<br/>[redis.module.ts]"]
end

subgraph group_health["Health check"]
  node_health_module["Health module<br/>[health.module.ts]"]
  node_health_controller["Health endpoint"]
  node_health_service["Dependency probes<br/>[health.service.ts]"]
  node_health_dto["Health DTO<br/>[health.dto.ts]"]
end

subgraph group_shared["Shared contracts"]
  node_health_contract["Health contract<br/>[health.schema.ts]"]
end

node_mobile_user(("Mobile user"))
node_api_caller(("Health requester"))
node_postgres[("PostgreSQL")]
node_redis_service[("Redis")]

node_mobile_user -.->|"views"| node_mobile_app
node_api_boot -->|"parses"| node_env_config
node_api_boot -->|"creates"| node_app_module
node_app_module -->|"configures"| node_database_setup
node_app_module -->|"registers"| node_redis_module
node_app_module -->|"registers"| node_health_module
node_app_module -->|"configures"| node_request_id
node_database_setup -->|"configures"| node_postgres
node_redis_module -->|"connects"| node_redis_service
node_api_caller -.->|"requests"| node_health_controller
node_health_module -->|"registers"| node_health_controller
node_health_module -->|"provides"| node_health_service
node_health_controller -->|"checks"| node_health_service
node_health_service -->|"probes"| node_postgres
node_health_service -->|"pings"| node_redis_service
node_health_controller -->|"serializes with"| node_health_dto
node_health_controller -->|"types result"| node_health_contract
node_health_service -->|"returns shape"| node_health_contract

click node_mobile_app "https://github.com/bunhourlong/lern/blob/main/apps/mobile/App.tsx"
click node_api_boot "https://github.com/bunhourlong/lern/blob/main/apps/api/src/main.ts"
click node_app_module "https://github.com/bunhourlong/lern/blob/main/apps/api/src/app.module.ts"
click node_env_config "https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/config/env.ts"
click node_request_id "https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/logging/request-id.ts"
click node_database_setup "https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/database/database.ts"
click node_redis_module "https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/redis/redis.module.ts"
click node_health_module "https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.module.ts"
click node_health_controller "https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.controller.ts"
click node_health_service "https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.service.ts"
click node_health_dto "https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/dto/health.dto.ts"
click node_health_contract "https://github.com/bunhourlong/lern/blob/main/packages/contracts/src/health.schema.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_mobile_app,node_mobile_user toneBlue
class node_api_boot,node_app_module,node_env_config,node_request_id,node_database_setup,node_redis_module,node_postgres,node_redis_service toneAmber
class node_health_module,node_health_controller,node_health_service,node_health_dto,node_api_caller toneMint
class node_health_contract toneRose
```

## Components

### Mobile app

- [Starter screen](https://github.com/bunhourlong/lern/blob/main/apps/mobile/App.tsx): `apps/mobile/App.tsx`

### API runtime

- [API bootstrap](https://github.com/bunhourlong/lern/blob/main/apps/api/src/main.ts): `apps/api/src/main.ts`
- [App composition](https://github.com/bunhourlong/lern/blob/main/apps/api/src/app.module.ts): `apps/api/src/app.module.ts`
- [Environment config](https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/config/env.ts): `apps/api/src/shared/config/env.ts`
- [Request IDs](https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/logging/request-id.ts): `apps/api/src/shared/logging/request-id.ts`
- [Database setup](https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/database/database.ts): `apps/api/src/shared/database/database.ts`
- [Redis client](https://github.com/bunhourlong/lern/blob/main/apps/api/src/shared/redis/redis.module.ts): `apps/api/src/shared/redis/redis.module.ts`

### Health check

- [Health module](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.module.ts): `apps/api/src/health/health.module.ts`
- [Health endpoint](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.controller.ts): `apps/api/src/health/health.controller.ts`
- [Dependency probes](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/health.service.ts): `apps/api/src/health/health.service.ts`
- [Health DTO](https://github.com/bunhourlong/lern/blob/main/apps/api/src/health/dto/health.dto.ts): `apps/api/src/health/dto/health.dto.ts`

### Shared contracts

- [Health contract](https://github.com/bunhourlong/lern/blob/main/packages/contracts/src/health.schema.ts): `packages/contracts/src/health.schema.ts`

### Other components

- **Mobile user**
- **Health requester**
- **PostgreSQL**
- **Redis**

## Connections

- Mobile user → Starter screen: views
- API bootstrap → Environment config: parses (evidence: `apps/api/src/main.ts`)
- API bootstrap → App composition: creates (evidence: `apps/api/src/main.ts`)
- App composition → Database setup: configures (evidence: `apps/api/src/app.module.ts`)
- App composition → Redis client: registers (evidence: `apps/api/src/app.module.ts`)
- App composition → Health module: registers (evidence: `apps/api/src/app.module.ts`)
- App composition → Request IDs: configures (evidence: `apps/api/src/app.module.ts`)
- Database setup → PostgreSQL: configures (evidence: `apps/api/src/shared/database/database.ts`)
- Redis client → Redis: connects (evidence: `apps/api/src/shared/redis/redis.module.ts`)
- Health requester → Health endpoint: requests
- Health module → Health endpoint: registers (evidence: `apps/api/src/health/health.module.ts`)
- Health module → Dependency probes: provides (evidence: `apps/api/src/health/health.module.ts`)
- Health endpoint → Dependency probes: checks (evidence: `apps/api/src/health/health.controller.ts`)
- Dependency probes → PostgreSQL: probes (evidence: `apps/api/src/health/health.service.ts`)
- Dependency probes → Redis: pings (evidence: `apps/api/src/health/health.service.ts`)
- Health endpoint → Health DTO: serializes with (evidence: `apps/api/src/health/health.controller.ts`)
- Health endpoint → Health contract: types result (evidence: `apps/api/src/health/health.controller.ts`)
- Dependency probes → Health contract: returns shape (evidence: `apps/api/src/health/health.service.ts`)
