Skip to main content

Overview

PC Fix uses NPM Workspaces to manage a monorepo containing the frontend (web) and backend (api) packages. This approach enables code sharing, unified dependency management, and streamlined development workflows.
All packages are located in the packages/ directory at the root of the repository.

Repository Structure

Root Configuration

package.json

packages.json
The workspaces field tells NPM to manage dependencies across all packages in packages/*.

Package Structure

Frontend Package (packages/web)

Backend Package (packages/api)

Workspace Commands

Running Commands in Specific Packages

Global Commands

Docker Setup

docker-compose.yml

The monorepo includes a Docker Compose configuration for local development:
docker-compose.yml
Run docker-compose up --build to start all services locally.

Benefits of Monorepo Architecture

Shared Code

Share TypeScript types, validation schemas (Zod), and utility functions between packages

Unified Dependencies

Single package-lock.json ensures consistent versions across the entire codebase

Atomic Changes

Make breaking changes to API and frontend in a single commit

Simplified Testing

Run tests across all packages with a single command

Shared Type Definitions

Example of sharing types between frontend and backend:
In practice, types are often duplicated or shared via a common package in larger monorepos. This project maintains types separately for deployment flexibility.

Development Workflow

1

Clone Repository

2

Install Dependencies

This installs dependencies for all workspaces.
3

Set Up Environment

Create .env files in both packages/api and packages/web
4

Start Development

CI/CD Integration

Vercel automatically detects the monorepo structure:
vercel.json

Best Practices

Keep Packages Independent

Each package should be runnable independently with its own package.json scripts

Use Workspace Protocol

Reference workspace packages using workspace:* protocol for internal dependencies

Centralize Tooling

Share configuration files (ESLint, Prettier, TypeScript) at the root level

Version Control

Use a single version number for the entire monorepo, or version packages independently

Next Steps

Frontend Architecture

Learn about the Astro + React setup

Backend Architecture

Explore the Express API structure

Database Schema

Understand the data model