# bytium-labs/bytium-core architecture

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

- Interactive diagram: https://gitdiagram.com/bytium-labs/bytium-core
- Repository: https://github.com/bytium-labs/bytium-core

## Overview

bytium-core is a modular TypeScript framework for FiveM Enhanced. Its main workflow is to bootstrap a decorated resource, discover modules/controllers/providers, resolve dependencies, and dispatch FiveM commands, events, ticks, callbacks, or HTTP requests through handlers. The repository also provides browser-side NUI communication and optional feature packages for configuration, persistence, and localization. The graph follows the README’s documented lifecycle and the sampled HTTP/NUI implementations; unsampled package internals are represented at their exact enclosing directories, with links omitted where evidence does not establish a call.

Main entry points: [`packages/http/src/http/services/http-router.service.ts`](https://github.com/bytium-labs/bytium-core/blob/master/packages/http/src/http/services/http-router.service.ts) (HTTP router), [`packages/common/src/citizenfx/managers/citizenfx-runtime.manager.ts`](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/citizenfx/managers/citizenfx-runtime.manager.ts) (Runtime manager), [`packages/common/src/core/services/discovery.service.ts`](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/services/discovery.service.ts) (Provider discovery), [`packages/common/src/core/utils/bootstrap.utils.ts`](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/utils/bootstrap.utils.ts) (Resource bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Resource foundation"]
  node_app["Resource bootstrap<br/>[bootstrap.utils.ts]"]
  node_modules["Modules and metadata"]
  node_discovery["Provider discovery"]
  node_di["Dependency resolution"]
  node_handlers["Handler pipeline<br/>[handler.invoker.ts]"]
end

subgraph group_runtime["FiveM runtime"]
  node_runtime["Runtime manager"]
  node_decorators["Runtime decorators"]
  node_registries[("Event and task registries")]
  node_callbacks["Callback services"]
end

subgraph group_http["HTTP handling"]
  node_httpdecorators["HTTP route decorators"]
  node_router["HTTP router"]
  node_middleware["HTTP middleware<br/>[cors.middleware.ts]"]
  node_multipart["Multipart uploads"]
end

subgraph group_features["Feature packages"]
  node_config["Configuration<br/>[config.service.ts]"]
  node_database["TypeORM integration"]
  node_i18n["Translations<br/>[i18n.service.ts]"]
  node_math["Vector math<br/>[vector3.class.ts]"]
end

subgraph group_browser["NUI browser"]
  node_nui["NUI SDK<br/>[nui.ts]"]
  node_react["React hooks<br/>[use-nui-call.ts]"]
  node_nuiinterface["NUI call state"]
end

node_fivem(("FiveM runtime"))
node_httprequest(("HTTP request"))

node_app -->|"boots modules"| node_modules
node_modules -.->|"declares providers"| node_discovery
node_discovery -.->|"resolves providers"| node_di
node_di -.->|"supplies instances"| node_handlers
node_app -.->|"wires runtime"| node_runtime
node_runtime -.->|"registers handlers"| node_fivem
node_decorators -.->|"registers metadata"| node_registries
node_runtime -.->|"dispatches entries"| node_registries
node_httprequest -->|"dispatches request"| node_router
node_router -->|"registers HTTP handler"| node_fivem
node_router -->|"invokes handler"| node_handlers
node_router -->|"discovers controllers"| node_discovery
node_router -->|"runs middleware"| node_middleware
node_httpdecorators -->|"defines routes"| node_router
node_multipart -.->|"parses request body"| node_router
node_config -->|"reads resource config"| node_fivem
node_database -.->|"manages data sources"| node_fivem
node_i18n -->|"loads resource catalogs"| node_fivem
node_react -->|"calls SDK"| node_nui
node_react -->|"uses call state"| node_nuiinterface
node_nui -->|"calls NUI callback"| node_fivem

click node_app "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/utils/bootstrap.utils.ts"
click node_modules "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/decorators/bytium-resource-module.decorator.ts"
click node_discovery "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/services/discovery.service.ts"
click node_di "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/managers/bytium-dependency.manager.ts"
click node_handlers "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/invokers/handler.invoker.ts"
click node_runtime "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/citizenfx/managers/citizenfx-runtime.manager.ts"
click node_decorators "https://github.com/bytium-labs/bytium-core/tree/master/packages/common/src/citizenfx/decorators"
click node_registries "https://github.com/bytium-labs/bytium-core/tree/master/packages/common/src/citizenfx/registries"
click node_callbacks "https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/citizenfx/services/callbacks.service.ts"
click node_httpdecorators "https://github.com/bytium-labs/bytium-core/tree/master/packages/http/src/http/decorators"
click node_router "https://github.com/bytium-labs/bytium-core/blob/master/packages/http/src/http/services/http-router.service.ts"
click node_middleware "https://github.com/bytium-labs/bytium-core/blob/master/packages/http/src/http/middleware/cors.middleware.ts"
click node_multipart "https://github.com/bytium-labs/bytium-core/blob/master/packages/http-multipart/src/multipart/interceptors/multipart.interceptor.ts"
click node_config "https://github.com/bytium-labs/bytium-core/blob/master/packages/config/src/config/services/config.service.ts"
click node_database "https://github.com/bytium-labs/bytium-core/blob/master/packages/database/src/database/services/type-orm-core.service.ts"
click node_i18n "https://github.com/bytium-labs/bytium-core/blob/master/packages/i18n/src/i18n/services/i18n.service.ts"
click node_math "https://github.com/bytium-labs/bytium-core/blob/master/packages/math/src/math/classes/vector3.class.ts"
click node_nui "https://github.com/bytium-labs/bytium-core/blob/master/packages/nui/src/nui/nui.ts"
click node_react "https://github.com/bytium-labs/bytium-core/blob/master/packages/nui-react/src/use-nui-call.ts"
click node_nuiinterface "https://github.com/bytium-labs/bytium-core/blob/master/packages/nui-react/src/interfaces/nui-call-state.interface.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_app,node_modules,node_discovery,node_di,node_handlers toneBlue
class node_runtime,node_decorators,node_registries,node_callbacks toneAmber
class node_httpdecorators,node_router,node_middleware,node_multipart,node_httprequest toneMint
class node_config,node_database,node_i18n,node_math toneRose
class node_nui,node_react,node_nuiinterface,node_fivem toneIndigo
```

## Components

### Resource foundation

- [Resource bootstrap](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/utils/bootstrap.utils.ts): `packages/common/src/core/utils/bootstrap.utils.ts`
- [Modules and metadata](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/decorators/bytium-resource-module.decorator.ts): `packages/common/src/core/decorators/bytium-resource-module.decorator.ts`
- [Provider discovery](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/services/discovery.service.ts): `packages/common/src/core/services/discovery.service.ts`
- [Dependency resolution](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/managers/bytium-dependency.manager.ts): `packages/common/src/core/managers/bytium-dependency.manager.ts`
- [Handler pipeline](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/core/invokers/handler.invoker.ts): `packages/common/src/core/invokers/handler.invoker.ts`

### FiveM runtime

- [Runtime manager](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/citizenfx/managers/citizenfx-runtime.manager.ts): `packages/common/src/citizenfx/managers/citizenfx-runtime.manager.ts`
- [Runtime decorators](https://github.com/bytium-labs/bytium-core/tree/master/packages/common/src/citizenfx/decorators): `packages/common/src/citizenfx/decorators`
- [Event and task registries](https://github.com/bytium-labs/bytium-core/tree/master/packages/common/src/citizenfx/registries): `packages/common/src/citizenfx/registries`
- [Callback services](https://github.com/bytium-labs/bytium-core/blob/master/packages/common/src/citizenfx/services/callbacks.service.ts): `packages/common/src/citizenfx/services/callbacks.service.ts`

### HTTP handling

- [HTTP route decorators](https://github.com/bytium-labs/bytium-core/tree/master/packages/http/src/http/decorators): `packages/http/src/http/decorators`
- [HTTP router](https://github.com/bytium-labs/bytium-core/blob/master/packages/http/src/http/services/http-router.service.ts): `packages/http/src/http/services/http-router.service.ts`
- [HTTP middleware](https://github.com/bytium-labs/bytium-core/blob/master/packages/http/src/http/middleware/cors.middleware.ts): `packages/http/src/http/middleware/cors.middleware.ts`
- [Multipart uploads](https://github.com/bytium-labs/bytium-core/blob/master/packages/http-multipart/src/multipart/interceptors/multipart.interceptor.ts): `packages/http-multipart/src/multipart/interceptors/multipart.interceptor.ts`

### Feature packages

- [Configuration](https://github.com/bytium-labs/bytium-core/blob/master/packages/config/src/config/services/config.service.ts): `packages/config/src/config/services/config.service.ts`
- [TypeORM integration](https://github.com/bytium-labs/bytium-core/blob/master/packages/database/src/database/services/type-orm-core.service.ts): `packages/database/src/database/services/type-orm-core.service.ts`
- [Translations](https://github.com/bytium-labs/bytium-core/blob/master/packages/i18n/src/i18n/services/i18n.service.ts): `packages/i18n/src/i18n/services/i18n.service.ts`
- [Vector math](https://github.com/bytium-labs/bytium-core/blob/master/packages/math/src/math/classes/vector3.class.ts): `packages/math/src/math/classes/vector3.class.ts`

### NUI browser

- [NUI SDK](https://github.com/bytium-labs/bytium-core/blob/master/packages/nui/src/nui/nui.ts): `packages/nui/src/nui/nui.ts`
- [React hooks](https://github.com/bytium-labs/bytium-core/blob/master/packages/nui-react/src/use-nui-call.ts): `packages/nui-react/src/use-nui-call.ts`
- [NUI call state](https://github.com/bytium-labs/bytium-core/blob/master/packages/nui-react/src/interfaces/nui-call-state.interface.ts): `packages/nui-react/src/interfaces/nui-call-state.interface.ts`

### Other components

- **FiveM runtime**
- **HTTP request**

## Connections

- Resource bootstrap → Modules and metadata: boots modules (evidence: `README.md`)
- Modules and metadata → Provider discovery: declares providers
- Provider discovery → Dependency resolution: resolves providers
- Dependency resolution → Handler pipeline: supplies instances
- Resource bootstrap → Runtime manager: wires runtime
- Runtime manager → FiveM runtime: registers handlers
- Runtime decorators → Event and task registries: registers metadata
- Runtime manager → Event and task registries: dispatches entries
- HTTP request → HTTP router: dispatches request (evidence: `packages/http/src/http/services/http-router.service.ts`)
- HTTP router → FiveM runtime: registers HTTP handler (evidence: `packages/http/src/http/services/http-router.service.ts`)
- HTTP router → Handler pipeline: invokes handler (evidence: `packages/http/src/http/services/http-router.service.ts`)
- HTTP router → Provider discovery: discovers controllers (evidence: `packages/http/src/http/services/http-router.service.ts`)
- HTTP router → HTTP middleware: runs middleware (evidence: `packages/http/src/http/services/http-router.service.ts`)
- HTTP route decorators → HTTP router: defines routes (evidence: `packages/http/src/http/services/http-router.service.ts`)
- Multipart uploads → HTTP router: parses request body
- Configuration → FiveM runtime: reads resource config (evidence: `packages/config/src/config/services/config.service.ts`)
- TypeORM integration → FiveM runtime: manages data sources
- Translations → FiveM runtime: loads resource catalogs (evidence: `packages/i18n/src/i18n/services/i18n.service.ts`)
- React hooks → NUI SDK: calls SDK (evidence: `packages/nui-react/src/use-nui-call.ts`)
- React hooks → NUI call state: uses call state (evidence: `packages/nui-react/src/use-nui-call.ts`)
- NUI SDK → FiveM runtime: calls NUI callback (evidence: `packages/nui/src/nui/nui.ts`)
