Skip to content

diptipradeep/bibsnbub

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bibs & Bub

This is a project for creating an app that makes it easy for families to locate changing and nursing rooms across Singapore.

Boilerplate and Starter for Next.js 15+, Tailwind CSS 4, and TypeScript.

This project uses the boilerplate and starter from https://github.com/ixartz/Next-js-Boilerplate.git.

Requirements

  • Node.js 20+ and npm

Getting started

Run the following command on your local environment:

git clone --depth=1 https://github.com/natashaannn/bibsnbub.git bibsnbub
cd bibsnbub
npm install

Then, you can run the project locally in development mode with live reload by executing:

npm run dev

Open http://localhost:3000 with your favorite browser to see your project.

Set up authentication

To get started, you will need to create a Clerk account at Clerk.com and create a new application in the Clerk Dashboard. Once you have done that, copy the NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY values and add them to the .env.local file (not tracked by Git):

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_pub_key
CLERK_SECRET_KEY=your_clerk_secret_key

Now you have a fully functional authentication system with Next.js, including features such as sign up, sign in, sign out, forgot password, reset password, update profile, update password, update email, delete account, and more.

Database setup

The project uses Drizzle ORM. In production it connects to PostgreSQL (e.g. Supabase). For local development, it can run a fully local Postgres-compatible database using PGlite with persistence on disk.

Local development (PGlite)

  • No remote DB is required.
  • If DATABASE_URL is not set, the app will automatically use PGlite locally and run migrations on startup.
  • Data is persisted to .pglite-data/ (git-ignored). You can customize by setting PGLITE_DATA_DIR.

Add the minimal env to .env.local (not tracked by Git):

# Required app/env settings
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_pub_key
CLERK_SECRET_KEY=your_clerk_secret_key

# Optional: configure where PGlite stores its files (default: .pglite-data)
PGLITE_DATA_DIR=.pglite-data

# Note: do NOT set DATABASE_URL locally if you want to use PGlite

Local DB commands:

# Apply migrations locally (PGlite or local Postgres if DATABASE_URL is set in .env.local)
npm run db:migrate:local

# Clear data (truncate tables and reset sequences)
npm run db:clear:local

# Seed with sample data from src/data/
npm run db:seed:local

# Reset (clear + migrate) and then seed
npm run db:fresh:local

Note

If you uploaded images via the Add Facility flow, your browser may still hold temporary state (e.g., uploaded image previews and wizard progress) in storage.

After running npm run db:clear:local or npm run db:fresh:local, clear your app storage before testing again:

  • In your browser devtools: Application → Storage → Clear site data
  • Or remove the session storage key: add-facility-form

Production (Supabase or any managed Postgres)

Define DATABASE_URL in your production environment. Example for Supabase:

DATABASE_URL=postgresql://postgres:[YOUR_PASSWORD]@db.[hash].supabase.co:5432/postgres

Production migration commands (use your .env.production):

# Generate migrations from schema changes
npm run db:generate

# Run migrations against production DB defined in .env.production
npm run db:migrate:prod

Notes:

  • In production, migrations are not auto-applied on app startup. Use the production migration command.
  • drizzle.config.ts reads DATABASE_URL for CLI operations like db:migrate:prod. For local PGlite, prefer the runtime script db:migrate:local.

Translation (i18n) setup

Translations are managed directly in this repo using next-intl JSON files located at src/locales/.

  • Default language is English at src/locales/en.json.
  • Other languages (e.g., src/locales/zh.json) can be edited by contributors.
  • Missing translations automatically fall back to English at runtime (so new keys won’t break the app).
  • In development, the app logs missing keys for the current locale to the console to help contributors see what needs translation.

Contributor workflow:

  1. Edit src/locales/en.json to add new keys/strings when introducing new UI text.
  2. Run the helper to see what’s missing in other locales:
npm run i18n:check
  1. Optionally, autofill missing keys in other locales with English placeholders (so translators can find and replace them later):
npm run i18n:fill
  1. Open a PR with changes to the locale JSON files.

Project structure

.
├── README.md                       # README file
├── .github                         # GitHub folder
├── .husky                          # Husky configuration
├── .storybook                      # Storybook folder
├── .vscode                         # VSCode configuration
├── migrations                      # Database migrations
├── public                          # Public assets folder
├── src
│   ├── app                         # Next JS App (App Router)
│   ├── components                  # React components
│   ├── libs                        # 3rd party libraries configuration
│   ├── locales                     # Locales folder (i18n messages)
│   ├── models                      # Database models
│   ├── styles                      # Styles folder
│   ├── templates                   # Templates folder
│   ├── types                       # Type definitions
│   ├── utils                       # Utilities folder
│   └── validations                 # Validation schemas
├── tests
│   ├── e2e                         # E2E tests, also includes Monitoring as Code
│   └── integration                 # Integration tests
├── tailwind.config.js              # Tailwind CSS configuration
└── tsconfig.json                   # TypeScript configuration

Change database schema

To modify the database schema in the project, you can update the schema file located at ./src/models/Schema.ts. This file defines the structure of your database tables using the Drizzle ORM library.

After making changes to the schema, generate a migration by running the following command:

npm run db:generate

This will create a migration file that reflects your schema changes. The migration is automatically applied during the next database interaction, so there is no need to run it manually or restart the Next.js server.

Commit Message Format

The project follows the Conventional Commits specification, meaning all commit messages must be formatted accordingly. To help you write commit messages, the project uses Commitizen, an interactive CLI that guides you through the commit process. To use it, run the following command:

npm run commit

One of the benefits of using Conventional Commits is the ability to automatically generate a CHANGELOG file. It also allows us to automatically determine the next version number based on the types of commits that are included in a release.

Testing

All unit tests are located alongside the source code in the same directory, making them easier to find. The project uses Vitest and React Testing Library for unit testing. You can run the tests with the following command:

npm run test

Integration & E2E Testing

The project uses Playwright for integration and end-to-end (E2E) testing. You can run the tests with the following commands:

npx playwright install # Only for the first time in a new environment
npm run test:e2e

In the local environment, visual testing is disabled, and the terminal will display the message [percy] Percy is not running, disabling snapshots.. By default, visual testing only runs in GitHub Actions.

Deploy to production

During the build process, database migrations are automatically executed, so there's no need to run them manually. However, you must define DATABASE_URL in your environment variables.

Then, you can generate a production build with:

$ npm run build

It generates an optimized production build of the boilerplate. To test the generated build, run:

$ npm run start

You also need to define the environment variables CLERK_SECRET_KEY using your own key.

This command starts a local server using the production build. You can now open http://localhost:3000 in your preferred browser to see the result.

Error Monitoring

The project uses Sentry to monitor errors. In the development environment, no additional setup is needed: Next.js Boilerplate is pre-configured to use Sentry and Spotlight (Sentry for Development). All errors will automatically be sent to your local Spotlight instance, allowing you to experience Sentry locally.

For production environment, you'll need to create a Sentry account and a new project. Then, in next.config.mjs, you need to update the org and project attributes in withSentryConfig function. Additionally, add your Sentry DSN to sentry.client.config.ts, sentry.edge.config.ts and sentry.server.config.ts.

Code coverage

Next.js Boilerplate relies on Codecov for code coverage reporting solution. To enable Codecov, create a Codecov account and connect it to your GitHub account. Your repositories should appear on your Codecov dashboard. Select the desired repository and copy the token. In GitHub Actions, define the CODECOV_TOKEN environment variable and paste the token.

Make sure to create CODECOV_TOKEN as a GitHub Actions secret, do not paste it directly into your source code.

Logging

The project uses Pino.js for logging. In the development environment, logs are displayed in the console by default.

For production, the project is already integrated with Better Stack to manage and query your logs using SQL. To use Better Stack, you need to create a Better Stack account and create a new source: go to your Better Stack Logs Dashboard > Sources > Connect source. Then, you need to give a name to your source and select Node.js as the platform.

After creating the source, you will be able to view and copy your source token. In your environment variables, paste the token into the LOGTAIL_SOURCE_TOKEN variable. Now, all logs will automatically be sent to and ingested by Better Stack.

Arcjet security and bot protection

The project uses Arcjet, a security as code product that includes several features that can be used individually or combined to provide defense in depth for your site.

To set up Arcjet, create a free account and get your API key. Then add it to the ARCJET_KEY environment variable.

Arcjet is configured with two main features: bot detection and the Arcjet Shield WAF:

  • Bot detection is configured to allow search engines, preview link generators e.g. Slack and Twitter previews, and to allow common uptime monitoring services. All other bots, such as scrapers and AI crawlers, will be blocked. You can configure additional bot types to allow or block.
  • Arcjet Shield WAF will detect and block common attacks such as SQL injection, cross-site scripting, and other OWASP Top 10 vulnerabilities.

Arcjet is configured with a central client at src/libs/Arcjet.ts that includes the Shield WAF rules. Additional rules are configured in src/app/[locale]/layout.tsx based on the page type.

Useful commands

Bundle Analyzer

Next.js Boilerplate includes a built-in bundle analyzer. It can be used to analyze the size of your JavaScript bundles. To begin, run the following command:

npm run build-stats

By running the command, it'll automatically open a new browser window with the results.

Database Studio

The project is already configured with Drizzle Studio to explore the database. You can run the following command to open the database studio:

npm run db:studio

Then, you can open https://local.drizzle.studio with your favorite browser to explore your database.

VSCode information (optional)

If you are VSCode user, you can have a better integration with VSCode by installing the suggested extension in .vscode/extension.json. The starter code comes up with Settings for a seamless integration with VSCode. The Debug configuration is also provided for frontend and backend debugging experience.

With the plugins installed in your VSCode, ESLint and Prettier can automatically fix the code and display errors. The same applies to testing: you can install the VSCode Vitest extension to automatically run your tests, and it also shows the code coverage in context.

Pro tips: if you need a project wide-type checking with TypeScript, you can run a build with Cmd + Shift + B on Mac.

Contributions

Everyone is welcome to contribute to this project. Feel free to open an issue if you have any questions or find a bug. Totally open to suggestions and improvements.

License

Licensed under the MIT License, Copyright © 2025

See LICENSE for more information.

About

An app to help parents find childcare facilities in Singapore!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.0%
  • CSS 2.0%
  • Other 1.0%