A technical kit to quickly build new products from Open Government Products, Singapore.
- π§ββοΈ E2E typesafety with tRPC
- β‘ Full-stack React with Next.js
- π Database with Prisma
- πͺ³ CockroachDB
- π Image upload with R2
- βοΈ VSCode extensions
- π¨ ESLint + Prettier
- π CI setup using GitHub Actions:
- β E2E testing with Playwright
- β Linting
- π Env var validation
Follow these instructions if you are familiar with building applications, and/or are in a hurry to prepare an environment to work on your product.
If you are new, see our Getting Started guide.
If you are exploring what else you can do with Starter Kit, a more comprehensive set of documentation, including guides and tutorials, can be found here.
We recommend Vercel to deploy your application. A one-click deployment step is provided below, which will also set up your own copy of this codebase on GitHub for you to work on.
This needs a few prerequisites, detailed below.
The deployment needs a few environment variables to be set for it to function. They are:
Name | What It Is | How To Obtain |
---|---|---|
DATABASE_URL |
Where the database resides for the deployed application | Follow this guide to set up CockroachDB |
POSTMAN_API_KEY |
An API key to send email via Postman | Follow Postman's guide to Generate your API Key |
SESSION_SECRET |
A sequence of random characters used to protect session identifiers | Run the command npx uuid from your terminal |
You may work on the codebase with:
- A GitHub Codespace provided by us, or;
- With your local machine.
Follow the official GitHub guide for developing with a codespace.
In summary:
- Clone the repository to your local machine
- Follow instructions for running the app locally
npm i
cp .env.example .env
Set POSTMAN_API_KEY
- required for login
NEXT_PUBLIC_
to ensure that the variable is exposed to the browser. For example, if you want to add a variable called MY_ENV_VAR
, you should add it to your .env
file as NEXT_PUBLIC_MY_ENV_VAR
.
You will also need to update src/browserEnv.ts to explicitly reference the variable so NextJS will correctly bundle the environment variable into the client-side bundle.
npm run setup
npm run dev
TODO: CI/CD test with GitHub Actions
TODO: Github branch protection rules
npm run build # runs `prisma generate` + `prisma migrate` + `next build`
npm run db:reset # resets local db
npm run dev # starts next.js
npm run setup # starts cockroach db + runs migrations + seed
npm run test-dev # runs e2e tests on dev
npm run test-start # runs e2e tests on `next start` - build required before
npm run test:unit # runs normal Vitest unit tests
npm run test:e2e # runs e2e tests
Path | Description |
---|---|
./prisma/schema.prisma |
Prisma schema |
./src/pages/api/trpc/[trpc].ts |
tRPC response handler |
./src/server/routers |
Your app's different tRPC-routers |