# spaghiajoeojo/express-beans architecture

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

- Interactive diagram: https://gitdiagram.com/spaghiajoeojo/express-beans
- Repository: https://github.com/spaghiajoeojo/express-beans

## Overview

ExpressBeans is a TypeScript IoC framework for organizing and running Express applications. The principal workflow is to register bean and router classes, inject bean instances, map route handlers onto Express routers, and execute application lifecycle phases so initialized routes can serve requests. Hooks, ordered tasks, method/route caching, and logging are additional capabilities. The graph includes the major documented features; links involving unsampled implementation are omitted or marked unverified rather than inferred from module names.

Main entry points: [`src/main.ts`](https://github.com/spaghiajoeojo/express-beans/blob/main/src/main.ts) (Public API), [`src/core/executor/Executor.ts`](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/executor/Executor.ts) (Phase executor), [`src/core/decorators/Route.ts`](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Route.ts) (Route mapping), [`src/core/index.ts`](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/index.ts) (Bean registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_public_api["Public API<br/>[main.ts]"]
end

subgraph group_beans["Beans and Routing"]
  node_app["Application<br/>[ExpressBeans.ts]"]
  node_bean["Bean registration<br/>[Bean.ts]"]
  node_injection["Bean injection<br/>[InjectBean.ts]"]
  node_router_bean["Router bean<br/>[RouterBean.ts]"]
  node_route["Route mapping<br/>[Route.ts]"]
  node_router_methods["HTTP methods<br/>[RouterMethods.ts]"]
  node_types["Framework types"]
end

subgraph group_lifecycle["Lifecycle"]
  node_executor["Phase executor<br/>[Executor.ts]"]
  node_task["Lifecycle task<br/>[Task.ts]"]
  node_hook["Lifecycle hooks<br/>[Hook.ts]"]
  node_order["Hook ordering<br/>[Order.ts]"]
end

subgraph group_support["Runtime Support"]
  node_cache[("Method cache<br/>[Cached.ts]")]
  node_logger["Logger<br/>[Logger.ts]"]
  node_logger_injection["Logger injection<br/>[InjectLogger.ts]"]
  node_registry[("Bean registry<br/>[index.ts]")]
  node_errors["Error handling<br/>[errors.ts]"]
  node_objects["Object utilities<br/>[Objects.ts]"]
end

node_developer(("Application developer"))
node_client(("HTTP client"))

node_developer -->|"uses"| node_public_api
node_public_api -->|"exports"| node_app
node_public_api -->|"exports"| node_bean
node_public_api -->|"exports"| node_injection
node_public_api -->|"exports"| node_route
node_public_api -->|"exports"| node_router_bean
node_public_api -->|"exports"| node_cache
node_public_api -->|"exports"| node_hook
node_public_api -->|"exports"| node_order
node_public_api -->|"exports"| node_logger_injection
node_public_api -->|"exports"| node_logger
node_app -->|"runs phases"| node_executor
node_app -->|"uses"| node_objects
node_bean -->|"registers instance"| node_registry
node_router_bean -->|"registers as"| node_bean
node_route -->|"registers routing task"| node_executor
node_route -->|"selects method"| node_router_methods
node_route -->|"serves requests"| node_client
node_injection -.->|"resolves beans"| node_registry
node_hook -->|"registers phase task"| node_executor
node_order -.->|"orders hooks"| node_executor
node_cache -->|"registers init task"| node_executor
node_executor -->|"creates tasks"| node_task
node_executor -->|"wraps failures"| node_errors
node_logger_injection -->|"injects logger"| node_logger
node_registry -->|"creates logger"| node_logger
node_cache -->|"reads registered methods"| node_registry

click node_public_api "https://github.com/spaghiajoeojo/express-beans/blob/main/src/main.ts"
click node_app "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/ExpressBeans.ts"
click node_bean "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Bean.ts"
click node_injection "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/InjectBean.ts"
click node_router_bean "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/RouterBean.ts"
click node_route "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Route.ts"
click node_router_methods "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/RouterMethods.ts"
click node_types "https://github.com/spaghiajoeojo/express-beans/blob/main/src/ExpressBeansTypes.ts"
click node_executor "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/executor/Executor.ts"
click node_task "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/executor/Task.ts"
click node_hook "https://github.com/spaghiajoeojo/express-beans/blob/main/src/hooks/decorators/Hook.ts"
click node_order "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Order.ts"
click node_cache "https://github.com/spaghiajoeojo/express-beans/blob/main/src/cache/decorators/Cached.ts"
click node_logger "https://github.com/spaghiajoeojo/express-beans/blob/main/src/logging/Logger.ts"
click node_logger_injection "https://github.com/spaghiajoeojo/express-beans/blob/main/src/logging/decorators/InjectLogger.ts"
click node_registry "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/index.ts"
click node_errors "https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/errors.ts"
click node_objects "https://github.com/spaghiajoeojo/express-beans/blob/main/src/utils/Objects.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_public_api,node_client toneBlue
class node_app,node_bean,node_injection,node_router_bean,node_route,node_router_methods,node_types toneAmber
class node_executor,node_task,node_hook,node_order toneMint
class node_cache,node_logger,node_logger_injection,node_registry,node_errors,node_objects toneRose
class node_developer toneIndigo
```

## Components

### Public API

- [Public API](https://github.com/spaghiajoeojo/express-beans/blob/main/src/main.ts): `src/main.ts`

### Beans and Routing

- [Application](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/ExpressBeans.ts): `src/core/ExpressBeans.ts`
- [Bean registration](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Bean.ts): `src/core/decorators/Bean.ts`
- [Bean injection](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/InjectBean.ts): `src/core/decorators/InjectBean.ts`
- [Router bean](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/RouterBean.ts): `src/core/decorators/RouterBean.ts`
- [Route mapping](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Route.ts): `src/core/decorators/Route.ts`
- [HTTP methods](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/RouterMethods.ts): `src/core/RouterMethods.ts`
- [Framework types](https://github.com/spaghiajoeojo/express-beans/blob/main/src/ExpressBeansTypes.ts): `src/ExpressBeansTypes.ts`

### Lifecycle

- [Phase executor](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/executor/Executor.ts): `src/core/executor/Executor.ts`
- [Lifecycle task](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/executor/Task.ts): `src/core/executor/Task.ts`
- [Lifecycle hooks](https://github.com/spaghiajoeojo/express-beans/blob/main/src/hooks/decorators/Hook.ts): `src/hooks/decorators/Hook.ts`
- [Hook ordering](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/decorators/Order.ts): `src/core/decorators/Order.ts`

### Runtime Support

- [Method cache](https://github.com/spaghiajoeojo/express-beans/blob/main/src/cache/decorators/Cached.ts): `src/cache/decorators/Cached.ts`
- [Logger](https://github.com/spaghiajoeojo/express-beans/blob/main/src/logging/Logger.ts): `src/logging/Logger.ts`
- [Logger injection](https://github.com/spaghiajoeojo/express-beans/blob/main/src/logging/decorators/InjectLogger.ts): `src/logging/decorators/InjectLogger.ts`
- [Bean registry](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/index.ts): `src/core/index.ts`
- [Error handling](https://github.com/spaghiajoeojo/express-beans/blob/main/src/core/errors.ts): `src/core/errors.ts`
- [Object utilities](https://github.com/spaghiajoeojo/express-beans/blob/main/src/utils/Objects.ts): `src/utils/Objects.ts`

### Other components

- **Application developer**
- **HTTP client**

## Connections

- Application developer → Public API: uses (evidence: `README.md`)
- Public API → Application: exports (evidence: `src/main.ts`)
- Public API → Bean registration: exports (evidence: `src/main.ts`)
- Public API → Bean injection: exports (evidence: `src/main.ts`)
- Public API → Route mapping: exports (evidence: `src/main.ts`)
- Public API → Router bean: exports (evidence: `src/main.ts`)
- Public API → Method cache: exports (evidence: `src/main.ts`)
- Public API → Lifecycle hooks: exports (evidence: `src/main.ts`)
- Public API → Hook ordering: exports (evidence: `src/main.ts`)
- Public API → Logger injection: exports (evidence: `src/main.ts`)
- Public API → Logger: exports (evidence: `src/main.ts`)
- Application → Phase executor: runs phases (evidence: `src/core/ExpressBeans.ts`)
- Application → Object utilities: uses (evidence: `src/core/ExpressBeans.ts`)
- Bean registration → Bean registry: registers instance (evidence: `src/core/decorators/Bean.ts`)
- Router bean → Bean registration: registers as (evidence: `src/core/decorators/RouterBean.ts`)
- Route mapping → Phase executor: registers routing task (evidence: `src/core/decorators/Route.ts`)
- Route mapping → HTTP methods: selects method (evidence: `src/core/decorators/Route.ts`)
- Route mapping → HTTP client: serves requests (evidence: `README.md`)
- Bean injection → Bean registry: resolves beans (evidence: `src/core/decorators/InjectBean.ts`)
- Lifecycle hooks → Phase executor: registers phase task (evidence: `src/hooks/decorators/Hook.ts`)
- Hook ordering → Phase executor: orders hooks
- Method cache → Phase executor: registers init task (evidence: `src/cache/decorators/Cached.ts`)
- Phase executor → Lifecycle task: creates tasks (evidence: `src/core/executor/Executor.ts`)
- Phase executor → Error handling: wraps failures (evidence: `src/core/executor/Executor.ts`)
- Logger injection → Logger: injects logger (evidence: `src/logging/decorators/InjectLogger.ts`)
- Bean registry → Logger: creates logger (evidence: `src/core/index.ts`)
- Method cache → Bean registry: reads registered methods (evidence: `src/cache/decorators/Cached.ts`)
