Setup Local Development
This guide will walk you through setting up a local development environment for the Blog HIMARPL website.
Prerequisites
Before installing the application, ensure you have:
- Node.js and npm installed
- Git installed
- Access to the following services:
- CockroachDB account
- Google OAuth credentials
- Upstash account
- PostHog account (optional)
Environment Setup Details
The project requires several environment variables to be set up in a .env
file for proper functionality:
Required Services Setup
-
CockroachDB Setup
- Follow the CockroachDB Quickstart Guide to get your
DATABASE_URL
- Follow the CockroachDB Quickstart Guide to get your
-
Google OAuth Setup
- Follow Google OAuth Guide to get:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
- Follow Google OAuth Guide to get:
-
Upstash Rate Limiting Setup
- Follow Upstash Ratelimiting Guide to get:
UPSTASH_REDIS_REST_URL
UPSTASH_REDIS_REST_TOKEN
- Follow Upstash Ratelimiting Guide to get:
-
Bot API Setup (optional)
- Follow Bot API Guide to get:
BOT_API_URL
BOT_API_TOKEN
- Follow Bot API Guide to get:
Setup Steps
-
Fork and clone the repository:
HTTPS git clone https://github.com/himarplupi/blog-himarpl.gitSSH git clone git@github.com:himarplupi/blog-himarpl.gitGitHub CLI gh repo clone himarplupi/blog-himarpl -
Navigate to project directory:
Terminal window cd blog-himarpl -
Create environment variables file: Create a
.env
file in the root directory with the following variables:Terminal window NEXT_PUBLIC_BASE_URL="http://localhost:3000"NEXT_PUBLIC_BASE_PATH=""NEXT_BASE_URL="http://localhost:3000"# DatabaseDATABASE_URL=# AuthenticationNEXTAUTH_SECRET=NEXTAUTH_URL="http://localhost:3000"GOOGLE_CLIENT_ID=GOOGLE_CLIENT_SECRET=# Rate LimitingUPSTASH_REDIS_REST_URL=UPSTASH_REDIS_REST_TOKEN=# PostHog (optional)NEXT_PUBLIC_POSTHOG_KEY=NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com# Bot API (optional)BOT_API_URL=BOT_API_TOKEN= -
Set up remote upstream:
HTTPS git remote add upstream https://github.com/himarplupi/blog-himarpl.gitSSH git remote add upstream git@github.com:himarplupi/blog-himarpl.gitGitHub CLI gh repo sync himarplupi/blog-himarpl -
Install dependencies and start development server:
Terminal window npm ci # Install dependenciesnpm run db:push # Push database schema to CockroachDBnpm run dev # Start development serverThe application should now be running at
http://localhost:3000
. -
Create a new branch for your changes:
Terminal window git checkout -b my-feature-branch -
After you are satisfied with your changes, add and commit them to your branch, then push your branch to your fork.
Terminal window git add .git commit # Please follow the commit guidelines belowgit push -u origin my-feature-branch -
Create Pull Request.
Available Scripts
npm run dev
- Starts development server with Turbonpm run build
- Creates production buildnpm run start
- Starts production servernpm run db:push
- Pushes database schema to CockroachDBnpm run db:studio
- Opens Prisma Studio for database managementnpm run lint
- Runs linting checksnpm run test
- Runs Jest testsnpm run test:watch
- Runs Jest tests in watch mode