An app for managing books you have read or would like to read.
- Vercel for app deployment and Vercel analytics.
- Supabase for database deployment.
- Backblaze B2 Cloud Storage for file storage for images.
- Sentry for monitoring.
- Setup the environment variables.
- Install the Vercel CLI
- Run
vercel linkin the root of the project to link it to our Vercel project. - Run
vercel env pullto download the development environment variables.
- Start the development environment:
pnpm dev. - Go to http://localhost:3000 to see the app.
We use Drizzle for our database schema and client management, and Supabase for database hosting.
The source of truth for our database schema is the Drizzle schema under drizzle/schema.ts.
We use Drizzle Migrations for updating the database.
- Update ./drizzle/schema.ts with any changes required to the database.
- Run
pnpm run drizzle-generateto create migration files to go from the current state of the database to the updated state. - Run
pnpm run drizzle-migrateto actually run the migration against the currently configured database.
TODO: Have this run automatically on CI for appropriate environments.
Note Supabase's free tier does not allow IPv4 to their direct connections, so we need to use the pooled connection for the database URL.
To make sure Drizzle works with connection pooling we need to add ?pgbouncer=true to the end of the database URL.
TODO: Is this still true since switching from Prisma?
| Command | Description |
|---|---|
pnpx drizzle-kit generate |
Generate another migration according to the latest schema changes. |
pnpx drizzle-kit migrate |
Run the latest Drizzle migration on the currently configured database. |
- Create a GitHub pull request to
main. - Merge the GitHub pull request to update the app.
- [If there are database changes]. Change your locale
DATABASE_URLto point to prod and runpnpm run drizzle-migrateto update the database.
We save our book cover images to Backblaze B2 Cloud Storage.
Currently when cover images are updated the old images are not deleted from Backblaze. This was not done at request time to keep the request as quick as possible.
Instead a housekeeping script was created which deletes image files from Backblaze that are no longer referenced in the database. The housekeeping script is under ./server/backblaze-housekeeping.ts.
Ideally the housekeeping script should be set to run on a schedule.
An important note on the AWS S3 SDK is it currently must be version 3.726.1 as Backblaze does not support extra headers added in versions since then.
See https://www.backblaze.com/docs/cloud-storage-use-the-aws-sdk-for-javascript-v3-with-backblaze-b2.
We use Playwright for our end to end tests. The following commands are useful:
pnpm run test:e2e: Run the E2E tests in the terminal.pnpm run test:e2e:ui: Run the E2E tests with the Playwright UI. Useful for dev.pnpm run test:e2e:generate: Run the Playwright test generator. Useful for creating tests.
If a Playwright component or E2E test job fails, we attach the Playwright report to the Action. To view this:
- Download the report, either by going to the upload artifacts part of the job and clicking on the download link, or by finding the Action here and going to the Artifacts section.
- Extract the zip to a folder in the root of this repository.
- View the report:
- For E2E tests use
pnpm run test:e2e:show-report - For component tests use
pnpm run test:component:show-report
- For E2E tests use