# Octimo Repositories and Environments

Version: 0.2
Status: Live record — update in the same change as any repository or database change  
Last verified: 2026-10-09 (Octimo database metadata, runtime, public HTTPS and DNS)
Companion documents: [Architecture](architecture.md) · [Database design](database-design.md) · [Database structure delivery plan](database-structure-plan.md)

This document records what actually exists today: the Git repositories and the
development database. The other blueprint documents describe the target design;
this one describes the provisioned reality so nobody has to rediscover it.

## 1. Git repositories

Both repositories live in the GitHub organisation
[`worksquares`](https://github.com/worksquares) and are **private**.

| Repository | URL | Holds | Default branch |
| --- | --- | --- | --- |
| `octimoui` | <https://github.com/worksquares/octimoui> | Frontend for the Student and Admin portals, the complete product blueprint (`docs/`), and the HTML screen prototype (`prototype/`) | `main` |
| `octimoapi` | <https://github.com/worksquares/octimoapi> | Backend API foundation, explicit SQL migrations, OpenAPI contract, reference files and OVH database provisioning workflow | `main` |

These are the only two runtime repositories. The worker is a second process
inside `octimoapi`, not a separate repository (see
[Architecture §4](architecture.md#4-container-and-deployment-shape)).

### 1.1 Clone

```bash
git clone https://github.com/worksquares/octimoui.git
git clone https://github.com/worksquares/octimoapi.git
```

Access requires membership of the `worksquares` organisation. The GitHub CLI
(`gh`) works with the same account for repository, issue, and workflow
operations.

### 1.2 Current contents (2026-10-09)

| Path | Purpose |
| --- | --- |
| `octimoui/README.md` | Product overview and links |
| `octimoui/docs/` | Product requirements, architecture, database design, delivery plan, UI/UX, screen mockup plan, this document |
| `octimoui/prototype/` | Static HTML prototype of the important Student and Admin screens |
| `octimoapi/README.md` | API overview, domain list, database summary |
| `octimoapi/src/`, `openapi/`, `test/` | NestJS/Fastify identity/admin/student read foundation, API contract and seven unit/static suites |
| `octimoapi/database/migrations/` | Six applied foundation migrations with a checksum-protected ledger |
| `octimoapi/docs/octimodocs/` | Sixteen Grade 2/5 reference files; not a published question bank |
| `octimoui/docs/olympiad-*.html` | Generated phasewise plan, syllabus/sample guide and OVH runbook |
| `octimoapi/.env.example` | Environment template; copy to `.env` (git-ignored) |
| `octimoapi/.github/workflows/provision-ovh.yml` | Idempotent database provisioning script |

The API foundation is implemented; the UI remains a landing page and static
prototype without a real application scaffold. The earlier flat-table API
design files listed in the September record are no longer present in the
current checkout. The UI [database design](database-design.md) remains the
technical blueprint, and the [phasewise plan](olympiad-platform-plan.html)
defines the current delivery sequence and status.

## 2. Development database

PostgreSQL on the shared Worksquares development host at OVH. The same host
serves the other Worksquares products (`crm_db`, `cpq_db`, `accounts_db`, and
others); those databases belong to other teams and must not be touched from
Octimo.

| Setting | Value |
| --- | --- |
| Host | `51.195.88.132` (OVH, Ubuntu 24.04, hostname `dev`) |
| Port | `5432` |
| Server version | PostgreSQL 17.11 (read-only verification 2026-10-09) |
| Database | `octimo_db` |
| Role | `octimo_app` — login role, owner of `octimo_db`, not a superuser |
| Password | **Not in Git.** Locally in `octimoapi/.env` (git-ignored); in CI as the `OCTIMO_DB_PASSWORD` secret |
| Authentication | September provisioning recorded SCRAM and a broad `host octimo_db octimo_app 0.0.0.0/0` rule; current host-wide rules were not re-audited in this pass |
| TLS | Current Octimo runtime has `DB_SSL=false`; enforcement/hardening remains a release task |
| Encoding / collation | `UTF8`, `LC_COLLATE=C`, `LC_CTYPE=C`, created from `template0` |
| Extensions | `pgcrypto`, `uuid-ossp`, `pg_trgm`, `citext`, `btree_gin`, `unaccent` |
| Schema state | Migrations `000001`–`000006` applied 2026-10-04 (schemas `core`, `iam`, `privacy`, `ops`; ledger `ops.schema_migrations`) |
| Provisioned | `octimo_db` on 2026-08-22; `unaccent` added 2026-09-05 |

There is **one** Octimo database on this host by decision (2026-09-05). It is
the shared development database: do not run parallel integration test suites
against it, and do not load unmasked child data into it. Staging and production
databases will be provisioned separately when those environments exist
(see [Architecture §4](architecture.md#4-container-and-deployment-shape)).

The September record reported broad PostgreSQL network access. Firewall and
host-wide access rules were not re-verified on 2026-10-09; inspect them before
changing shared host policy. The release plan requires scoped database access
and private/encrypted transport. Keep credentials out of chat and commits.

### 2.1 Environment variables

`octimoapi/.env.example` is the template. Copy it to `.env` and fill in the
password:

```dotenv
DB_HOST=51.195.88.132
DB_PORT=5432
DB_NAME=octimo_db
DB_USER=octimo_app
DB_PASSWORD=            # from .env / OCTIMO_DB_PASSWORD secret
DB_POOL_MIN=2
DB_POOL_MAX=20
DB_IDLE_TIMEOUT=10000
DB_CONNECTION_TIMEOUT=10000
DB_SSL=false
DB_SSL_REJECT_UNAUTHORIZED=false
```

Equivalent connection URL:

```text
postgresql://octimo_app:<password>@51.195.88.132:5432/octimo_db
```

### 2.2 Connecting from a workstation

```bash
psql "host=51.195.88.132 port=5432 dbname=octimo_db user=octimo_app"
```

`psql` prompts for the password. Any PostgreSQL client (DBeaver, pgAdmin,
DataGrip, the Node `pg` driver) works with the same five values.

### 2.3 Server-side administration

Anything `octimo_app` cannot do — creating roles, installing extensions that
need a superuser, resetting the password — is done on the host as the
`postgres` OS user:

```bash
ssh -i ~/.ssh/ovh_key ubuntu@51.195.88.132
sudo -u postgres psql -d octimo_db
```

The `ubuntu` account has passwordless `sudo`. The SSH private key is held by the
platform owner and stored in CI as the `OVH_SSH_KEY` secret.

### 2.4 Rotating the password

```bash
sudo -u postgres psql -c "ALTER ROLE octimo_app PASSWORD '<new-password>';"
```

Then update `octimoapi/.env` on every workstation and the `OCTIMO_DB_PASSWORD`
secret. Existing pooled connections keep working until they reconnect.

### 2.5 Re-provisioning

`octimoapi/.github/workflows/provision-ovh.yml` creates the role, the database,
the extensions, and the `pg_hba.conf` rule. It is idempotent and never changes
an existing password. GitHub Actions is currently unavailable for the
organisation, so run the workflow's script body over SSH instead of dispatching
it; the result is identical.

## 3. Environments

| Environment | UI | API | Database | Status |
| --- | --- | --- | --- | --- |
| Development | <https://octimo.worksquares.ai/> (landing page, from `site/`) and <https://octimo.worksquares.ai/prototype/> (HTML prototype) | Container `octimo-api` on `127.0.0.1:3140`; public only at <https://octimo.worksquares.ai/api/v1/health/live> and `/ready` | `octimo_db` on `51.195.88.132` | Live since 2026-10-04 |
| Staging | — | — | — | Not provisioned |
| Production | — | — | — | Not provisioned |

Development deployment on the OVH host:

- **nginx site** `/etc/nginx/sites-available/octimo-worksquares-ai`, TLS by certbot
  (certificate `octimo.worksquares.ai`). Static files are served from
  `/var/www/octimo`: the contents of `site/` at the root, plus `prototype/` and
  `docs/assets/`.
- **API** source in `/opt/octimo/api` (from `git archive`), image `octimo-api:<commit>`
  built from `octimoapi/Dockerfile`, environment in `/opt/octimo/api.env` (mode 600).
  The container runs `NODE_ENV=development`, `AUTH_MODE=dev`; because dev mode trusts
  identity headers, nginx exposes only `/api/v1/health/*` and returns 404 for the rest
  of `/api/` until an OIDC provider is configured.
- To redeploy the static files, `git archive HEAD site prototype docs/assets`, copy
  the archive to the host, and swap it into `/var/www/octimo` (`site/` contents at the root).

## 4. Change log

Current DNS verification: `octimo.worksquares.ai` has A record `51.195.88.132`;
`worksquares.ai` uses `ns53.domaincontrol.com` and `ns54.domaincontrol.com`.
The requested deployment retains this hostname and DNS authority. Public
landing, prototype and API live/ready checks return 200; `/api/v1/me` returns
404 as expected under the development-authentication guard. These checks do
not establish authenticated learning-platform acceptance. The current image
tag is `octimo-api:latest`, so exact release identity is a remaining gate.
The [OVH runbook](olympiad-ovh-deployment.html) records future staging/production
database and role provisioning; no new database was created for this plan.

| Date | Change |
| --- | --- |
| 2026-10-09 | Read-only verification of DNS, PostgreSQL 17.11, six applied migrations, 22 foundation tables and public development health; reconciled stale scaffold/deployment statements and added the phasewise HTML plan |
| 2026-08-22 | Repositories `octimoui` and `octimoapi` created; `octimo_db` and `octimo_app` provisioned |
| 2026-09-05 | `unaccent` extension added; a separate `octimo_test` database was created and dropped the same day (single-database decision); this document created |
| 2026-10-04 | API scaffold pushed; migrations 000001–000006 applied to `octimo_db`; development deployed to `octimo.worksquares.ai` (prototype + API health) |
| 2026-10-04 | Landing page (`site/`) published at the root of `octimo.worksquares.ai`; prototype moved under `/prototype/` only |
