Giter Club home page Giter Club logo

web-app-template's Introduction

๏ธ๏ธA minimal template for web app ๐ŸŽƒ


This template is based on create-next-app but has below new tech and configs.

Kind
App Next.js (Framework) Tailwind CSS (CSS)
React Hook Form (Form) Zod (Schema Validator)
Prisma (ORM) NextAuth.js (Auth)
Tools TypeScript (Language) pnpm (Package Manager) NVM (Node Version manager)
Biome (Linter, Formatter) Prettier (Formatter)
lint-staged (Pre Commit) Docker Compose (Docker)
Testing Vitest (Test Runner) Testing Library (React) Playwright (E2E Testing)
Others GitHub Workflows (CI) Renovate (Deps Manager) .vscode (Editor)

Just running create-next-app does not satisfy the dependencies, development environment, and CI environment to create a web application. In addition, many dependencies require setting configs for example, @next-auth/prisma-adapter requires adding many schemas to schema.prisma but we don't know what we add so always need to check the docs every time. This project is created as a template with minimal code in advance so that you can focus on development.

๐Ÿ• What does this project support?

Next.js
  • introducing parallel route and intercepting route
  • introducing server actions using Zod
  • setting common files like robots, opengraph-image, etc
  • supporting Docker
Prisma
  • introducing dev/test env using Docker Compose and PostgreSQL
  • fixing well-known Next.js issue
  • generating ERD automatically
  • running migration on github actions
NextAuth.js
  • introducing Google Oauth provider
  • defining Prisma schema and connecting database
  • setting Next.js api route using app router
Biome, Prettier
  • introducing how to control these when pre-commit
  • assigning Prisma, Biome, Prettier to each language for vscode
Playwright
  • introducing Page object models for e2e to make it resistant to change code
  • introducing how to avoid OAuth Providers with NextAuth.js
CI
  • CI tasks: lint, build, unit test, e2e test
  • Prod tasks: migrating DB when main branch

Install

GitHub Template

This repo is a github template so click the "Use this template" button and you will create your repo.

CLI

create-app-foundation creates a directory based on this template and skips the setup section automatically.

npx create-app-foundation

Setup

1. Installing Docker Compose

Please check Installation scenarios section.

2. Enabling git hook and corepack

npm run setup

3. Installing Deps

pnpm i

4. Creating .env.local and modifying environment variables

cp .env.sample .env.local

Set the following environment variables in .env.local.

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

If you don't use Google OAuth, you can remove a provider from _clients/NextAuth.ts.

5. Running init.mjs

  • generating DB migration files
  • removing unnecessary code
  • updating name in package.json using directory name
node init.mjs

Dev

# start docker-compose, migrations(generating the client), and next dev
pnpm dev
# create new migration
pnpm dev:db:migrate
# reset the DB
pnpm dev:db:reset
# view the contents
pnpm dev:db:studio

๐Ÿ“™ Database ER diagram

Test

Test uses also DB so need to start DB first.

# unit test

# run the DB and generate the client
pnpm test:db:setup
# execute
pnpm test
# watch the unit test
pnpm test:watch
# reset the DB
pnpm test:db:reset

# e2e

# install chrome
pnpm exec playwright install chrome
# run the DB and generate the client
pnpm test:db:setup
# test uses a built app since next.js has different cache behavior between development and production
pnpm build
# execute
pnpm test:e2e

๐Ÿ’โ€โ™€๏ธ This template recommends using a real database but when you face not keeping idempotency, you might consider using mock.

Prod

pnpm db:start
pnpm build
pnpm start

If you set POSTGRESQL_URL as GitHub secrets, you will be able to execute migration for database on GitHub actions(.github/workflows/migration.yml).

web-app-template's People

Contributors

hiroppy avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

stephanyvargas

web-app-template's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

docker-compose
docker-compose.yml
  • postgres 16
  • postgres 16
dockerfile
Dockerfile
  • node 20.12.2-slim
github-actions
.github/actions/setup-node/action.yml
  • actions/setup-node v4
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/checkout v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/download-artifact v4
.github/workflows/migration.yml
  • actions/checkout v4
npm
package.json
  • @auth/prisma-adapter 1.6.0
  • @hookform/resolvers 3.3.4
  • @prisma/client 5.12.1
  • next 14.2.1
  • next-auth 4.24.7
  • react 18.2.0
  • react-dom 18.2.0
  • react-hook-form 7.51.3
  • zod 3.22.4
  • @biomejs/biome 1.7.0
  • @playwright/test 1.43.1
  • @testing-library/react 15.0.2
  • @types/node 20.12.7
  • @types/react 18.2.79
  • @types/react-dom 18.2.25
  • @vitejs/plugin-react 4.2.1
  • autoprefixer 10.4.19
  • dotenv-cli 7.4.1
  • lint-staged 15.2.2
  • postcss 8.4.38
  • prettier 3.2.5
  • prisma 5.12.1
  • prisma-erd-generator 1.11.2
  • tailwindcss 3.4.3
  • typescript 5.4.5
  • vitest 1.5.0
  • pnpm 9.0.0
nvm
.nvmrc
  • node 20.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

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.