Skip to content
Melv1CPublic

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

299 Commits

Folders and files

Repository files navigation

ArtNote

ArtNote is a TanStack Start application that publishes scholarly notices about paintings for a French-speaking audience. It uses Prisma on a PostgreSQL database, MinIO for uploaded images, and Better Auth for authentication. It is self-hosted on Dokploy (docs/adr/0011-self-hosted-on-dokploy.md).

Setup

  1. Install Vite+, the one toolchain for this project: it manages Node.js and the package manager, and runs the dev server, build, tests, lint and format (ADR 0008).

    curl -fsSL https://vite.plus | bash

    No nvm or separate Node.js install: vp reads Node.js 26 from devEngines.runtime and Bun from packageManager in package.json, and downloads both on first use. Bun is only the package manager under vp; the app runs on Node.js. Change either version with vp env pin <version> or vp env pin bun@<version>, and keep the Dockerfile's node: image on the same Node.js version.

  2. Install dependencies:

    vp install

    Dependency lifecycle scripts only run for packages listed in trustedDependencies (currently just esbuild). Prisma's postinstall is skipped on purpose; the client is generated by worktree:setup, check, prisma:migrate and the Dockerfile.

  3. Environment variables: vp run worktree:setup (next step) writes .env on its first run: .env.example, overridden by the main checkout's .env when this is another worktree, with a database and dev port of its own for this checkout. .env and .env.local are loaded into process.env for server code (.env.local wins). The variables are validated in src/lib/env-schema.ts. Image uploads go to the local MinIO that worktree:setup starts (console at http://localhost:9001, user artnote, password artnote-dev-storage). A .env written before MinIO was added lacks the S3_* variables: copy them from .env.example.

  4. Start the local database and MinIO (Docker), create this checkout's database and the shared artnote bucket, apply migrations, generate the Prisma client and seed sample data:

    vp run worktree:setup

    Sign in with admin@example.com, writer@example.com (a second admin), user@example.com or banned@example.com (refused), password artnote-dev-password. Staging has the same accounts with other passwords (AGENTS.md, Environments and QA). worktree:setup, db:reset and the seed refuse to run against a non-local database.

  5. Run the development server:

    vp run dev

    The app is served at BASE_URL from .env.

Scripts

Run the package.json scripts with vp run <script>. vp dev, vp build, vp test, vp check, vp lint and vp fmt are Vite+'s built-in commands, so vp run dev is needed for the script that checks the setup first. vp exec <bin> runs a dependency's binary (vp exec prisma studio), vpx <file.ts> runs a TypeScript script, and vp add / vp remove / vp update change dependencies.

  • vp run dev – Vite dev server with TanStack Start, after checking this checkout is set up.
  • vp build – production build (client assets and the Nitro server output in .output/).
  • vp run start – serve the production build locally (node .output/server/index.mjs).
  • docker build . – the production image Dokploy builds; the container runs prisma migrate deploy, then the server on port 3000.
  • vp run check – everything CI runs: Prisma generate, validate and format check, vp check (Oxfmt, Oxlint and the TypeScript type check), vp test (Vitest), knip and the build (regenerates src/routeTree.gen.ts).
  • vp run fix – format and apply lint fixes.
  • vp run test:e2e – Playwright end-to-end tests (e2e/) on a throwaway copy of the seeded database (AGENTS.md, End-to-end tests). Install Chromium once with vp exec playwright install chromium.
  • vp run worktree:setup – set up this checkout: .env, Postgres and MinIO, its database, migrations, Prisma client and seed.
  • vp run db:seed / db:reset / db:down – re-seed, recreate this checkout's database, stop the shared containers.

Working with AI agents

AGENTS.md (imported by CLAUDE.md) is the guide for coding agents: setup, commands, conventions and how to verify a change.

Deployments

Dokploy, on our own server, builds the Dockerfile from GitHub (ADR 0011):

Environment Address Deploys on Database and MinIO
Production https://artnote.melvyn.be a push to production (only the Release workflow moves it) its own
Staging https://stg.artnote.melvyn.be a push to main its own
Preview a *.artnote.melvyn.be address a PR from this repository labelled preview staging's

Uploaded files are served from https://files.artnote.melvyn.be (production) and https://files.stg.artnote.melvyn.be (staging and previews). Every container runs prisma migrate deploy before it starts, so a preview's migration reaches the staging database (ADR 0006). Deploys don't wait for CI.

Nobody pushes to main, v* tags or production: rulesets allow it only to the release workflows' deploy key (ADR 0012).

To release, run the Release workflow from the Actions tab on main and pick patch, minor or major (or gh workflow run release.yml -f bump=minor). It requires a passing Check on main's HEAD, commits chore(release): vX.Y.Z bumping package.json, pushes it with its tag, creates the GitHub Release and moves production, which Dokploy deploys.

To roll back, run the Rollback workflow with an earlier tag (gh workflow run rollback.yml -f tag=v1.2.0). It moves production to that tag and changes nothing else.

Each Dokploy app sets these variables (src/lib/env-schema.ts): BASE_URL, PRISMA_DATABASE_URL, BETTER_AUTH_SECRET, CRON_SECRET, CLIENT_IP_HEADER=x-real-ip, the five S3_* variables, and UMAMI_WEBSITE_ID in production only. Previews get staging's values; Dokploy adds DOKPLOY_DEPLOY_URL, which replaces BASE_URL. A Dokploy schedule on production and staging calls the nightly cron from inside the container:

node -e "fetch('http://localhost:3000/api/cron/prune-view-records',{headers:{authorization:'Bearer '+process.env.CRON_SECRET}}).then(r=>r.text()).then(console.log)"

A new MinIO gets its bucket from scripts/storage/init-bucket.sh (public reads, no listing). There are no automatic backups.

Code structure

AGENTS.md describes the folder layout, how to write a server function (guard, Zod validator, errors), how the UI reads and mutates data, and audience measurement. GLOSSARY.md defines the domain terms, and docs/adr/ records the decisions behind the architecture.

Toolchain

Vite+ (vp) is the toolchain: Vite for dev and build, Vitest for tests, Oxlint for linting and Oxfmt for formatting, all configured in vite.config.ts. vp check formats, lints and type-checks in one pass. knip covers unused code. See docs/adr/0008-vite-plus-toolchain.md.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages