# nr-labs-digital/only-one-coin architecture

> Architecture diagram of the GitHub repository nr-labs-digital/only-one-coin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nr-labs-digital/only-one-coin
- Repository: https://github.com/nr-labs-digital/only-one-coin

## Overview

Only One Coin is an academic platform: a public multilingual site feeds a four-step enrollment journey, while students use a portal and staff manage academic and administrative work in a backoffice. The Fastify API supplies real enrollment, student, staff, and feature-flag capabilities, backed by Postgres; enrollment notifications use an outbox and email workers. The graph preserves the major documented surfaces and operational domains. Some app/API and worker wiring is not shown in the sampled source, so those relationships are cited to the README or omitted where uncertain.

Main entry points: [`apps/api/src/app.ts`](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/app.ts) (HTTP API), [`apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts`](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts) (Enrollment persistence), [`apps/app/src/app/[locale]/enrollment`](https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/enrollment) (Enrollment wizard), [`apps/api/src/workers/send-email.worker.ts`](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/workers/send-email.worker.ts) (Email workers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public discovery"]
  node_landing["Public site<br/>[ui.ts]"]
end

subgraph group_student["Enrollment and portal"]
  node_app["Web app"]
  node_checkout["Enrollment wizard"]
  node_portal["Student portal"]
end

subgraph group_staff["Staff operations"]
  node_backoffice["Staff backoffice"]
end

subgraph group_backend["API and domain"]
  node_api["HTTP API<br/>[app.ts]"]
  node_enrollment["Enrollment domain"]
  node_studentdomain["Student domain"]
  node_identity["Staff identity"]
  node_catalog["Course catalog"]
  node_flags["Feature flags<br/>[server.ts]"]
end

subgraph group_infra["Persistence and messaging"]
  node_db[("Postgres<br/>[schema.ts]")]
  node_enrollrepo["Enrollment persistence"]
  node_studentquery["Student directory query"]
  node_outbox[("Email outbox")]
  node_workers["Email workers"]
  node_queue["Job queue<br/>[connection.ts]"]
end

node_visitor(("Prospective student"))
node_email["Brevo email"]
node_payment["External payment"]

node_visitor -->|"browses"| node_landing
node_visitor -->|"starts enrollment"| node_checkout
node_landing -->|"redirects CTAs"| node_app
node_checkout -->|"uploads receipt for"| node_payment
node_checkout -->|"submits enrollment"| node_api
node_api -.->|"handles enrollment"| node_enrollment
node_api -.->|"handles students"| node_studentdomain
node_api -.->|"handles staff access"| node_identity
node_api -.->|"serves catalog"| node_catalog
node_backoffice -->|"uses API"| node_api
node_portal -.->|"uses API"| node_api
node_app -->|"gates sections"| node_flags
node_enrollrepo -->|"reads and writes"| node_db
node_enrollrepo -->|"queues email"| node_outbox
node_enrollrepo -->|"persists domain records"| node_enrollment
node_studentquery -->|"queries students"| node_db
node_workers -.->|"processes jobs"| node_queue
node_workers -.->|"delivers email"| node_email
node_outbox -.->|"relayed to"| node_queue

click node_landing "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/landing/src/i18n/ui.ts"
click node_app "https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D"
click node_checkout "https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/enrollment"
click node_portal "https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/portal"
click node_backoffice "https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/backoffice"
click node_api "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/app.ts"
click node_enrollment "https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/enrollment"
click node_studentdomain "https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/student"
click node_identity "https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/identity"
click node_catalog "https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/catalog"
click node_flags "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/app/src/lib/feature-flags/server.ts"
click node_db "https://github.com/nr-labs-digital/only-one-coin/blob/main/packages/db/src/schema.ts"
click node_enrollrepo "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts"
click node_studentquery "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/student/ListStudentsQuery.ts"
click node_outbox "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/notification/DrizzleOutboxRepository.ts"
click node_workers "https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/workers/send-email.worker.ts"
click node_queue "https://github.com/nr-labs-digital/only-one-coin/blob/main/packages/queue/src/connection.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_landing toneBlue
class node_app,node_checkout,node_portal toneAmber
class node_backoffice toneMint
class node_api,node_enrollment,node_studentdomain,node_identity,node_catalog,node_flags toneRose
class node_db,node_enrollrepo,node_studentquery,node_outbox,node_workers,node_queue,node_visitor,node_email,node_payment toneIndigo
```

## Components

### Public discovery

- [Public site](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/landing/src/i18n/ui.ts): `apps/landing/src/i18n/ui.ts`

### Enrollment and portal

- [Web app](https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D): `apps/app/src/app/[locale]`
- [Enrollment wizard](https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/enrollment): `apps/app/src/app/[locale]/enrollment`
- [Student portal](https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/portal): `apps/app/src/app/[locale]/portal`

### Staff operations

- [Staff backoffice](https://github.com/nr-labs-digital/only-one-coin/tree/main/apps/app/src/app/%5Blocale%5D/backoffice): `apps/app/src/app/[locale]/backoffice`

### API and domain

- [HTTP API](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Enrollment domain](https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/enrollment): `packages/domain/src/enrollment`
- [Student domain](https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/student): `packages/domain/src/student`
- [Staff identity](https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/identity): `packages/domain/src/identity`
- [Course catalog](https://github.com/nr-labs-digital/only-one-coin/tree/main/packages/domain/src/catalog): `packages/domain/src/catalog`
- [Feature flags](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/app/src/lib/feature-flags/server.ts): `apps/app/src/lib/feature-flags/server.ts`

### Persistence and messaging

- [Postgres](https://github.com/nr-labs-digital/only-one-coin/blob/main/packages/db/src/schema.ts): `packages/db/src/schema.ts`
- [Enrollment persistence](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts): `apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts`
- [Student directory query](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/student/ListStudentsQuery.ts): `apps/api/src/infra/persistence/student/ListStudentsQuery.ts`
- [Email outbox](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/infra/persistence/notification/DrizzleOutboxRepository.ts): `apps/api/src/infra/persistence/notification/DrizzleOutboxRepository.ts`
- [Email workers](https://github.com/nr-labs-digital/only-one-coin/blob/main/apps/api/src/workers/send-email.worker.ts): `apps/api/src/workers/send-email.worker.ts`
- [Job queue](https://github.com/nr-labs-digital/only-one-coin/blob/main/packages/queue/src/connection.ts): `packages/queue/src/connection.ts`

### Other components

- **Prospective student**
- **Brevo email**
- **External payment**

## Connections

- Prospective student → Public site: browses
- Prospective student → Enrollment wizard: starts enrollment
- Public site → Web app: redirects CTAs
- Enrollment wizard → External payment: uploads receipt for
- Enrollment wizard → HTTP API: submits enrollment
- HTTP API → Enrollment domain: handles enrollment
- HTTP API → Student domain: handles students
- HTTP API → Staff identity: handles staff access
- HTTP API → Course catalog: serves catalog
- Staff backoffice → HTTP API: uses API
- Student portal → HTTP API: uses API
- Web app → Feature flags: gates sections (evidence: `apps/app/src/lib/feature-flags/server.ts`)
- Enrollment persistence → Postgres: reads and writes (evidence: `apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts`)
- Enrollment persistence → Email outbox: queues email (evidence: `apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts`)
- Enrollment persistence → Enrollment domain: persists domain records (evidence: `apps/api/src/infra/persistence/enrollment/DrizzlePublicEnrollmentRepository.ts`)
- Student directory query → Postgres: queries students (evidence: `apps/api/src/infra/persistence/student/ListStudentsQuery.ts`)
- Email workers → Job queue: processes jobs
- Email workers → Brevo email: delivers email
- Email outbox → Job queue: relayed to
