Skip to content

Latest commit

 

History

History
128 lines (93 loc) · 4.56 KB

DEVELOPMENT.md

File metadata and controls

128 lines (93 loc) · 4.56 KB

Development guide

The project uses pnpm for package management and scripts. Make sure to install it before getting your hands dirty with the code.

Table of Contents

Prerequisites

  • pnpm - >v9.0.0
  • node - >v20.0.0
  • docker - >v27.0.0

Environment Variables

The Project requires the following set of Environmental variables for running in development environment. Database related variables can be omitted for the production environment (as the backend lives on a different service).

Variable Name What It Does? Example
BACKEND_BASE_URL URL where the backend is running http://localhost:8080
SMTP_HOST Host URL for connection to the E-Mail Server smtp.ethereal.email
SMTP_PORT Port for connection to the E-Mail Server 587
SMTP_EMAIL E-mail used for E-Mail Server dummy.email@acm-pec.edu.in
SMTP_PASS Password for E-Mail Server AReally$tr0ngPa55w0rd
POSTGRES_DB Database name for the Postgres Database acm
POSTGRES_USER Username for the Postgres Database acmsecy
POSTGRES_PASSWORD Password for the Postgres Database acmhead

Available Scripts

Command Description
pnpm dev Start development server
pnpm build Build for production
pnpm serve Preview production build
pnpm fmt Run formatter
pnpm fmt:write Run formatter and fix issues
pnpm lint Run linting checks
pnpm lint:fix Run linting checks and fix issues
pnpm check Run all checks (format, lint, imports)
pnpm check:write Run checks and fix issues

Getting Started

  1. Set Environment Variables
    • Copy the example .env file and update it with your values (see the Environment Variables table above for details)
cp .env.example .env

Warning

Never commit your .env file to version control. Verify it's listed in .gitignore.

Tip

If you want to test routes that use the email server, You can use ethereal.email to generate SMTP credentials.

  1. Spin up a container with the postgres server and backend server using the compose file docker-compose.yml.
docker compose up -d

Important

Make sure to use the -v flag when destroying the container to remove volumes.

docker compose down -v
  1. Verify Services Are Running

    • Backend: http://localhost:8080
    • PostgreSQL: localhost:5432

    The database is pre-seeded with test data. Use these credentials:

    • Email: harshpreetsinghjohar.btcse20@pec.edu.in
    • Password: admin123

Check Docker logs if services fail to start:

docker compose logs
  1. Install Dependencies
pnpm install
  1. Run Dev Server
  • The frontend dev server should now be running on port 3000
pnpm dev

Path Aliases

The project includes path aliases for commonly used internal packages/libraries which should be used to avoid long import paths in the code. These are configured in the project typescript config tsconfig.json.

  • $components → src/components
  • $data → src/data
  • $env → src/lib/env
  • $emails → src/emails
  • $hooks → src/hooks
  • $lib → src/lib
  • $assets → src/lib/assets
  • $styles → src/styles

Code Style

This project uses Oxlint for formatting and linting. Pre-commit hooks are configured with Husky. You can install Oxlint's Extension for your code editor to show you linting hints and help you with formatting the files on save.

See the Available Scripts section for formatting and linting commands.

Husky runs the check script on the pre-commit event.

Read the full style guide: CODE_STYLE.md