# oxyidehq/oxyide-forge architecture

> Architecture diagram of the GitHub repository oxyidehq/oxyide-forge, 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/oxyidehq/oxyide-forge
- Repository: https://github.com/oxyidehq/oxyide-forge

## Overview

Oxyide Forge is a TypeScript/Fastify backend foundation, not a finished business application. Its main request workflow runs from application startup and route registration through authentication/authorization and domain handlers to persistence and HTTP responses. The graph also preserves the platform’s documented health, OpenAPI, email, Redis/cache, observability, and shared API-contract capabilities. Some subsystems are documented but unsampled; their internal links are omitted rather than inferred.

Main entry points: [`src/app/app.ts`](https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/app.ts) (Fastify application), [`src/app/routes.ts`](https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/routes.ts) (Route registry), [`src/modules/auth/services/auth.service.ts`](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/auth.service.ts) (Authentication services), [`src/modules/auth/routes/auth.routes.ts`](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/routes/auth.routes.ts) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Process entry<br/>[main.ts]"]
  node_config["Validated config<br/>[index.ts]"]
  node_app["Fastify application<br/>[app.ts]"]
  node_routes["Route registry<br/>[routes.ts]"]
  node_health["Health probes<br/>[health.route.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Authentication routes<br/>[auth.routes.ts]"]
  node_authservice["Authentication services<br/>[auth.service.ts]"]
  node_verification["Email verification"]
  node_securityevents["Security events"]
  node_authplugin["JWT authentication<br/>[auth.plugin.ts]"]
  node_authguard["Authentication guard<br/>[require-auth.ts]"]
  node_rbac["RBAC policies and guards"]
end

subgraph group_domains["Domain modules"]
  node_users["User services and routes"]
  node_notes["Notes example"]
  node_roles["Role routes<br/>[role.routes.ts]"]
end

subgraph group_platform["Platform services"]
  node_database[("Prisma database<br/>[prisma.ts]")]
  node_email["Email delivery"]
  node_cache["Redis cache<br/>[cache.service.ts]"]
  node_openapi["OpenAPI and Swagger<br/>[swagger.plugin.ts]"]
  node_observability["Metrics and tracing"]
end

subgraph group_contracts["Shared contracts"]
  node_errors["Error contract<br/>[error-mapper.ts]"]
  node_query["Query primitives<br/>[pagination.ts]"]
  node_deprecation["API deprecation<br/>[deprecation.ts]"]
  node_authcontext["Principal context<br/>[auth-context.ts]"]
end

node_caller(("API client"))

node_caller -->|"sends requests"| node_app
node_main -->|"creates"| node_app
node_main -->|"loads"| node_config
node_app -->|"uses"| node_config
node_app -->|"registers routes"| node_routes
node_routes -->|"registers"| node_authroutes
node_routes -->|"registers"| node_users
node_routes -->|"registers"| node_roles
node_routes -->|"registers"| node_notes
node_routes -->|"registers"| node_health
node_authroutes -->|"calls"| node_authservice
node_authroutes -->|"uses"| node_authguard
node_authroutes -->|"reads principal"| node_authcontext
node_authservice -->|"uses"| node_database
node_authservice -->|"calls"| node_verification
node_authservice -->|"emits events"| node_securityevents
node_authplugin -->|"attaches principal"| node_authcontext
node_authguard -->|"looks up user"| node_users
node_authguard -->|"logs decisions"| node_rbac
node_users -->|"persists users"| node_database
node_users -->|"uses principal"| node_authcontext
node_notes -->|"requires auth"| node_authguard
node_notes -->|"uses query rules"| node_query
node_notes -->|"reads and writes"| node_database
node_roles -->|"uses guards"| node_rbac
node_app -->|"registers"| node_openapi
node_app -->|"installs hooks"| node_deprecation
node_app -->|"registers"| node_observability
node_app -->|"maps failures"| node_errors
node_authservice -.->|"sends auth mail"| node_email
node_app -.->|"enables optionally"| node_cache

click node_main "https://github.com/oxyidehq/oxyide-forge/blob/main/src/main.ts"
click node_config "https://github.com/oxyidehq/oxyide-forge/blob/main/src/config/index.ts"
click node_app "https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/app.ts"
click node_routes "https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/routes.ts"
click node_health "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/health/health.route.ts"
click node_authroutes "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/routes/auth.routes.ts"
click node_authservice "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/auth.service.ts"
click node_verification "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/email-verification.service.ts"
click node_securityevents "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/auth-security-events.ts"
click node_authplugin "https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/auth.plugin.ts"
click node_authguard "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/authorization/guards/require-auth.ts"
click node_rbac "https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/authorization"
click node_users "https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/users"
click node_notes "https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/notes"
click node_roles "https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/roles/routes/role.routes.ts"
click node_database "https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/database/prisma.ts"
click node_email "https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/email/smtp-email-provider.ts"
click node_cache "https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/cache/cache.service.ts"
click node_openapi "https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/swagger.plugin.ts"
click node_observability "https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/telemetry.plugin.ts"
click node_errors "https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/errors/error-mapper.ts"
click node_query "https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/pagination/pagination.ts"
click node_deprecation "https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/api-lifecycle/deprecation.ts"
click node_authcontext "https://github.com/oxyidehq/oxyide-forge/blob/main/src/types/auth-context.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_main,node_config,node_app,node_routes,node_health,node_caller toneBlue
class node_authroutes,node_authservice,node_verification,node_securityevents,node_authplugin,node_authguard,node_rbac toneAmber
class node_users,node_notes,node_roles toneMint
class node_database,node_email,node_cache,node_openapi,node_observability toneRose
class node_errors,node_query,node_deprecation,node_authcontext toneIndigo
```

## Components

### Application runtime

- [Process entry](https://github.com/oxyidehq/oxyide-forge/blob/main/src/main.ts): `src/main.ts`
- [Validated config](https://github.com/oxyidehq/oxyide-forge/blob/main/src/config/index.ts): `src/config/index.ts`
- [Fastify application](https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/app.ts): `src/app/app.ts`
- [Route registry](https://github.com/oxyidehq/oxyide-forge/blob/main/src/app/routes.ts): `src/app/routes.ts`
- [Health probes](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/health/health.route.ts): `src/modules/health/health.route.ts`

### Identity and access

- [Authentication routes](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/routes/auth.routes.ts): `src/modules/auth/routes/auth.routes.ts`
- [Authentication services](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/auth.service.ts): `src/modules/auth/services/auth.service.ts`
- [Email verification](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/email-verification.service.ts): `src/modules/auth/services/email-verification.service.ts`
- [Security events](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/auth/services/auth-security-events.ts): `src/modules/auth/services/auth-security-events.ts`
- [JWT authentication](https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/auth.plugin.ts): `src/plugins/auth.plugin.ts`
- [Authentication guard](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/authorization/guards/require-auth.ts): `src/modules/authorization/guards/require-auth.ts`
- [RBAC policies and guards](https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/authorization): `src/modules/authorization`

### Domain modules

- [User services and routes](https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/users): `src/modules/users`
- [Notes example](https://github.com/oxyidehq/oxyide-forge/tree/main/src/modules/notes): `src/modules/notes`
- [Role routes](https://github.com/oxyidehq/oxyide-forge/blob/main/src/modules/roles/routes/role.routes.ts): `src/modules/roles/routes/role.routes.ts`

### Platform services

- [Prisma database](https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/database/prisma.ts): `src/platform/database/prisma.ts`
- [Email delivery](https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/email/smtp-email-provider.ts): `src/platform/email/smtp-email-provider.ts`
- [Redis cache](https://github.com/oxyidehq/oxyide-forge/blob/main/src/platform/cache/cache.service.ts): `src/platform/cache/cache.service.ts`
- [OpenAPI and Swagger](https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/swagger.plugin.ts): `src/plugins/swagger.plugin.ts`
- [Metrics and tracing](https://github.com/oxyidehq/oxyide-forge/blob/main/src/plugins/telemetry.plugin.ts): `src/plugins/telemetry.plugin.ts`

### Shared contracts

- [Error contract](https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/errors/error-mapper.ts): `src/shared/errors/error-mapper.ts`
- [Query primitives](https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/pagination/pagination.ts): `src/shared/pagination/pagination.ts`
- [API deprecation](https://github.com/oxyidehq/oxyide-forge/blob/main/src/shared/api-lifecycle/deprecation.ts): `src/shared/api-lifecycle/deprecation.ts`
- [Principal context](https://github.com/oxyidehq/oxyide-forge/blob/main/src/types/auth-context.ts): `src/types/auth-context.ts`

### Other components

- **API client**

## Connections

- API client → Fastify application: sends requests (evidence: `README.md`)
- Process entry → Fastify application: creates (evidence: `src/main.ts`)
- Process entry → Validated config: loads (evidence: `src/main.ts`)
- Fastify application → Validated config: uses (evidence: `src/app/app.ts`)
- Fastify application → Route registry: registers routes (evidence: `src/app/routes.ts`)
- Route registry → Authentication routes: registers (evidence: `src/app/routes.ts`)
- Route registry → User services and routes: registers (evidence: `src/app/routes.ts`)
- Route registry → Role routes: registers (evidence: `src/app/routes.ts`)
- Route registry → Notes example: registers (evidence: `src/app/routes.ts`)
- Route registry → Health probes: registers (evidence: `src/app/routes.ts`)
- Authentication routes → Authentication services: calls (evidence: `src/modules/auth/routes/auth.routes.ts`)
- Authentication routes → Authentication guard: uses (evidence: `src/modules/auth/routes/auth.routes.ts`)
- Authentication routes → Principal context: reads principal (evidence: `src/modules/auth/routes/auth.routes.ts`)
- Authentication services → Prisma database: uses (evidence: `src/modules/auth/services/auth.service.ts`)
- Authentication services → Email verification: calls (evidence: `src/modules/auth/services/auth.service.ts`)
- Authentication services → Security events: emits events (evidence: `src/modules/auth/services/auth.service.ts`)
- JWT authentication → Principal context: attaches principal (evidence: `src/types/auth-context.ts`)
- Authentication guard → User services and routes: looks up user (evidence: `src/modules/authorization/guards/require-auth.ts`)
- Authentication guard → RBAC policies and guards: logs decisions (evidence: `src/modules/authorization/guards/require-auth.ts`)
- User services and routes → Prisma database: persists users (evidence: `src/modules/users/users.service.ts`)
- User services and routes → Principal context: uses principal (evidence: `src/modules/users/routes/user.routes.ts`)
- Notes example → Authentication guard: requires auth (evidence: `src/modules/notes/routes/note.routes.ts`)
- Notes example → Query primitives: uses query rules (evidence: `src/modules/notes/routes/note.routes.ts`)
- Notes example → Prisma database: reads and writes (evidence: `src/modules/notes/note.repository.ts`)
- Role routes → RBAC policies and guards: uses guards (evidence: `src/modules/roles/routes/role.routes.ts`)
- Fastify application → OpenAPI and Swagger: registers (evidence: `src/app/app.ts`)
- Fastify application → API deprecation: installs hooks (evidence: `src/app/app.ts`)
- Fastify application → Metrics and tracing: registers (evidence: `src/app/app.ts`)
- Fastify application → Error contract: maps failures (evidence: `src/app/app.ts`)
- Authentication services → Email delivery: sends auth mail
- Fastify application → Redis cache: enables optionally
