This is a Next.js project bootstrapped with create-next-app
. It uses shadcn/ui for components, PostgreSQL for the database, Prisma as an ORM and database migration tool, and the Vercel Platform for deployment.
- Run
npm install
to install dependencies. - Define the environment variables (see below).
- Run
npx prisma migrate reset
to create the database schema and seed it with data. - Run
npm run dev
to start the development server. - Open http://localhost:3000 with your browser to see the result.
The file env.example
contains the required environment variables.
Create a .env
file in the root directory, and copy the contents of env.example
.
This project uses PostgreSQL for its database. Set up an instance of this yourself, and then set DATABASE_URL
and DIRECT_URL
accordingly.
Note: DIRECT_URL
is only used for compatibility with pgBouncer in production, but still must be declared when running locally. It should have the same value as DATABASE_URL
.
The hosted version of this project uses Supabase's PostgreSQL service as a database host, but does not use any additional features of Supabase.
The database seeding script used in development is set up to copy non-sensitive data on the current public website through the /api/data-export
endpoint. Set the environment variable SEED_DATA_SOURCE
to the URL of the website (as of writing, https://algdb.vercel.app/api/data-export
) and the populated data will be copied to the local database.
Set NEXTAUTH_URL
to the canonical URL of the site. Use http://localhost:3000
for development.
Set NEXTAUTH_SECRET
to a random value generated by:
openssl rand -base64 32
More details here.
- Create an OAuth application.
- Set the Redirect URI to
http://localhost:3000/api/auth/callback/wca
for development, orhttps://{YOUR_DOMAIN}/api/auth/callback/wca
for production. - Set the Scopes to
public email
and click Submit. - Update your
.env
file with the credentials shown on the page. "Application ID" is theWCA_CLIENT_ID
, and "Secret" is theWCA_CLIENT_SECRET
.
- Create a new Google Cloud project.
- On the Credentials page, click "Create credentials" and select "OAuth client ID".
- Select "Web application" for Application type.
- Enter the following information:
For development | For production | |
---|---|---|
Authorized JavaScript origins | http://localhost:3000 |
https://{YOUR_DOMAIN} |
Authorized redirect URIs | http://localhost:3000/api/auth/callback/google |
https://{YOUR_DOMAIN}/api/auth/callback/google |
- Update your
.env
file with the Google Client ID and Client secret shown in the "OAuth client created" dialog. - Update the OAuth consent screen.