Bart Dorsey

VSCode Workspace Guide for Full-Stack Development

What are VSCode Workspaces?

A VSCode workspace is a collection of one or more folders that are opened together in a single VSCode window. Think of it as a container that holds multiple related projects, allowing you to work on them simultaneously.

Why VSCode Needs to Know Project Root Folders

VSCode relies on knowing the root folder of each project to function properly. Here’s why this matters:

Language Support and IntelliSense

File Path Resolution

Tool Integration

Example Problem Without Proper Root Setup: If you open your entire my-fullstack-app folder as a single project, VSCode might get confused:

By setting up a workspace with proper root folders, you tell VSCode: “This frontend folder is a complete React project” and “This backend folder is a complete Python project.”

Why Use Workspaces for Full-Stack Development?

When working on full-stack applications in a monorepo, you have separate codebases for your frontend and backend in the same repository. Using workspaces provides several key benefits:

Unified Development Environment

Enhanced Productivity

Setting Up a Workspace: React + FastAPI Monorepo Example

Let’s walk through creating a workspace for a full-stack project with a React Vite frontend and Python FastAPI backend in a single repository.

Step 1: Organize Your Monorepo Structure

Your monorepo should be organized with clear separation between projects:

my-fullstack-app/
├── .git/              # Single Git repository
├── README.md          # Project documentation
├── .gitignore         # Shared gitignore
├── frontend/          # React Vite project
│   ├── src/
│   ├── public/
│   ├── package.json
│   └── vite.config.js
└── backend/           # FastAPI project
    ├── main.py
    ├── requirements.txt
    └── app/

Step 2: Create the Workspace

Method 1: Using the File Menu

  1. Open VSCode
  2. Go to FileAdd Folder to Workspace...
  3. Select your frontend folder
  4. Repeat: FileAdd Folder to Workspace...
  5. Select your backend folder
  6. (Optional) Add monorepo root: FileAdd Folder to Workspace... and select the parent my-fullstack-app folder
  7. Save the workspace: FileSave Workspace As...
  8. Save it in your monorepo root as project.code-workspace

Method 2: Create Workspace File Manually Create a file called project.code-workspace in your monorepo root with this content:

{
    "folders": [
        {
            "name": "Monorepo Root",
            "path": "."
        },
        {
            "name": "Frontend (React)",
            "path": "./frontend"
        },
        {
            "name": "Backend (FastAPI)",
            "path": "./backend"
        }
    ]
}

Including the monorepo root gives you easy access to:

Working with Your Monorepo Workspace

File Navigation

Important: When working on frontend or backend code, always open files from their respective workspace folders (Frontend or Backend), not from the Monorepo Root. This ensures VSCode uses the correct project context for language support, IntelliSense, and tool integration. The Monorepo Root folder should primarily be used for accessing top-level files like README.md, .gitignore, or project configuration files.

Integrated Terminal Management

Open separate terminals for each project:

  1. Open terminal (Ctrl + `)
  2. Click the + dropdown next to the terminal tabs
  3. Select the folder where you want the terminal to open
  4. Run your development servers:
    • Frontend terminal: npm run dev
    • Backend terminal: fastapi dev main.py

Git Management

Since everything is in one repository:

Common Workflows

Starting Development

  1. Open your project.code-workspace file in VSCode
  2. Open integrated terminal for backend folder
  3. Activate virtual environment: source venv/bin/activate (Linux/Mac) or venv\Scripts\activate (Windows)
  4. Start FastAPI server: fastapi dev main.py
  5. Open new terminal for frontend folder
  6. Start React development server: npm run dev

Making Changes Across Projects

  1. Modify your FastAPI endpoints in the backend folder
  2. Switch to frontend folder to update API calls
  3. Update documentation in the monorepo root if needed
  4. All changes appear in one Git panel for easy committing

Managing Documentation and Configuration

Best Practices

Workspace File Location

Folder Organization

Terminal Management

Opening Your Workspace

Once you’ve created your workspace file, you can:

Why Monorepos Work Well for Full-Stack Projects

Using a monorepo structure with VSCode workspaces is particularly beneficial for full-stack development because:

Using VSCode workspaces with a monorepo structure streamlines your full-stack development workflow while keeping everything organized and easily accessible. This setup is ideal for developers working with multiple technologies in a single, cohesive project.