Skip to content

The open-source database for improv games and lesson plans

Notifications You must be signed in to change notification settings

aberonni/improvdb

Repository files navigation

ImprovDB

This is a T3 Stack project bootstrapped with create-t3-app. The project is deployed at improvdb.com.

Tech Stack

Local development

Prerequisites

  • A Postgres database URL (you can get one for free at Planet Scale or use the docker compose file to run Postgres locally)
  • Google authentication credentials - Read more
  • (Optional) A free Upstash redis URL

Setup

cp .env.example .env
# edit the `.env` file with your configuration details, and then
npm install

Local Postgres database

You must have docker installed for this to work. You can use a local Postgres database with the following commands

docker-compose -f docker-compose.postgres.yml up
# Wait for postgres server to be ready, then run
npx prisma db push
npx prisma db seed

Then you can just update your .env file with DATABASE_URL=postgres://improvdb_user:secret@127.0.0.1:5432/improvdb_db.

If you ever need to reset the database, you have two options:

1. Soft reset

npx prisma db push --force-reset
npx prisma db seed

2. Hard reset

Run the following command to destroy the volumes associated with the postgres database, and then start again from scratch.

docker-compose -f docker-compose.postgres.yml down -v

Running the project

As simple as

npm run dev

You can also run prisma studio with the following command:

npx prisma studio

Running E2E tests locally

To be able to run all tests properly, you must have docker installed. That's because we want to use the same docker container that is used in CI, ensuring that there aren't differences when doing screenshot / visual regression testing.

You must also make sure that you are using a freshly seeded local Postgres database.

Build the image

docker build -t playwright-docker -f tests/Dockerfile-playwright .
docker image ls # Should output "playwright-docker"

Run the tests

docker run -p 9323:9323 --rm --name playwright-runner -it playwright-docker:latest /bin/bash
# From inside the container now you can run
npx playwright test

More detailed instructions on the Docker | Playwright documentation. Loosely based on this guide.

Updating screenshots

If you need to update the screenshots, then you can run this command instead:

npx playwright test --update-snapshots

And then, once you've run tests, you can update the snapshots in the git repository by running the following (while the docker container is still running, in a separate terminal):

docker cp playwright-runner:/app/tests .

Run E2E tests without docker

You can alternatively run a test directly without docker, skipping the screenshot comparison functionality altogether.

You can do this with the command:

SKIP_SCREENSHOT_COMPARISON=1 npx playwright test

Updating seed data

While connected to a production/staging database, run the following:

npx tsx prisma/updateSeedData.ts

This will pull all resources and all public lesson plans into the seedData.json file in the git repository.

Learn More about T3

To learn more about the T3 Stack, take a look at the following resources:

You can check out the create-t3-app GitHub repository

Contributing

Contributions are welcome! The best place to start is by opening an issue.

About

The open-source database for improv games and lesson plans

Topics

Resources

Stars

Watchers

Forks