Giter Club home page Giter Club logo

ogp-starter-sample's Introduction

Starter Kit

A technical kit to quickly build new products from Open Government Products, Singapore.

Features

  • ๐Ÿง™โ€โ™‚๏ธ 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

Quickstart

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.

One-click deploy

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.

Prerequisites

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

Deployment

Deploy with Vercel

Working on your product

You may work on the codebase with:

Using GitHub Codespaces

Follow the official GitHub guide for developing with a codespace.

Using your local developer environment

In summary:

Running the app locally

Install dependencies

npm i

Set environment variables

cp .env.example .env

Set POSTMAN_API_KEY - required for login

Retrieving client-side environment variables in code

โš ๏ธ When adding client-only environment variables in NextJS, you must prefix the variable with 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.

Start database

npm run setup

Start server

npm run dev

Developer Operations

TODO: CI/CD test with GitHub Actions

TODO: Github branch protection rules

Useful notes

Commands

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

Files of note

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

Example feature

Adding replies to posts

ogp-starter-sample's People

Contributors

prawiragenestonlia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.