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)
Directory Structure
Directory Structure
Key Dependencies
Key Dependencies
Backend Package (packages/api)
Directory Structure
Directory Structure
Key Dependencies
Key Dependencies
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
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 codebaseAtomic 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
3
Set Up Environment
Create
.env files in both packages/api and packages/web4
Start Development
CI/CD Integration
- Vercel (Frontend)
- Railway (Backend)
Vercel automatically detects the monorepo structure:
vercel.json
Best Practices
Keep Packages Independent
Each package should be runnable independently with its own
package.json scriptsUse Workspace Protocol
Reference workspace packages using
workspace:* protocol for internal dependenciesCentralize 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