This guide walks you through setting up the FastAPI Tutorial from scratch on a fresh Ubuntu 24.04 LTS installation.
Before starting, verify your system:
# Check Ubuntu version
lsb_release -a
# Should show: Ubuntu 24.04 LTS
# Check available disk space (need at least 2GB)
df -h
# Update system
sudo apt update && sudo apt upgrade -yNode.js 20.x LTS is recommended for this project.
# Install curl if not already installed
sudo apt install curl -y
# Add NodeSource repository for Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# Install Node.js (includes npm)
sudo apt-get install -y nodejs
# Verify installations
node --version # Should show v20.x.x
npm --version # Should show 10.x.x
# (Optional) Update npm to latest version
sudo npm install -g npm@latestIf you encounter permission errors:
# Create npm global directory in your home folder
mkdir ~/.npm-global
# Configure npm to use new directory
npm config set prefix '~/.npm-global'
# Add to PATH (add this line to ~/.bashrc or ~/.profile)
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
# Reload shell configuration
source ~/.bashrc# Create a directory for your projects (optional but recommended)
mkdir -p ~/projects
cd ~/projects
# Clone the repository
git clone https://github.com/lgtkgtv/fastapi_tutorial.git
cd fastapi_tutorial
# List files to verify
ls -la# Make sure you're in the project directory
cd ~/projects/fastapi_tutorial
# Install all dependencies from package.json
npm install
# This will take 2-5 minutes and install ~200+ packages
# You should see a progress baradded 234 packages, and audited 235 packages in 2m
42 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
# Clear npm cache
npm cache clean --force
# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Try again
npm installCheck that all required dependencies are installed:
# Check if key dependencies exist
npm list react react-dom lucide-react tailwindcss
# Should show versions like:
# react@18.3.1
# react-dom@18.3.1
# lucide-react@0.544.0
# tailwindcss@3.4.1Ensure these files exist in your project root:
# Check for required config files
ls -la tailwind.config.js postcss.config.js vite.config.js
# Display contents of tailwind.config.js
cat tailwind.config.js
# Display contents of postcss.config.js
cat postcss.config.jsCreate them manually:
tailwind.config.js:
cat > tailwind.config.js << 'EOF'
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
EOFpostcss.config.js:
cat > postcss.config.js << 'EOF'
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
EOF# Check src directory structure
tree src/ || ls -R src/
# Should show:
# src/
# ├── App.jsx
# ├── main.jsx
# ├── index.css
# └── assets/cat src/index.css
# Should contain:
# @tailwind base;
# @tailwind components;
# @tailwind utilities;If missing, create it:
cat > src/index.css << 'EOF'
@tailwind base;
@tailwind components;
@tailwind utilities;
EOF# Start the dev server
npm run dev
# Expected output:
# VITE v5.x.x ready in 500 ms
#
# ➜ Local: http://localhost:5173/
# ➜ Network: use --host to expose
# ➜ press h + enter to show help-
On the same machine:
- Open browser and go to:
http://localhost:5173
- Open browser and go to:
-
From another computer on same network:
# Stop the server (Ctrl+C) # Restart with --host flag npm run dev -- --host # Now accessible at: http://YOUR_IP:5173 # Find your IP with: hostname -I | awk '{print $1}'
-
Change the port:
# Stop the server (Ctrl+C) # Start on different port npm run dev -- --port 3000
Once the dev server is running:
-
Open browser to
http://localhost:5173 -
You should see:
- Page title: "FastAPI Interactive Tutorial"
- Blue/indigo gradient background
- Left sidebar with lesson navigation (15 lessons)
- Main content area showing Lesson 1
-
Test functionality:
- Click through different lessons
- Click "Copy" button on code blocks
- Click "Mark Complete" button
- Navigate with Previous/Next buttons
# Create optimized production build
npm run build
# Output will be in dist/ directory
ls -lh dist/
# Preview production build locally
npm run preview
# Opens at http://localhost:4173# Find and kill process using port 5173
sudo lsof -t -i:5173 | xargs kill -9
# Or use a different port
npm run dev -- --port 3000# Check if Node.js is installed
which node
# If not found, reinstall Node.js (see Step 1)# Don't use sudo with npm in project directory
# If you get permission errors, fix npm permissions:
sudo chown -R $USER:$USER ~/.npm
sudo chown -R $USER:$USER ~/projects/fastapi_tutorial# Verify Tailwind is installed
npm list tailwindcss
# Check index.css has Tailwind directives
cat src/index.css
# Restart dev server
# Ctrl+C to stop, then: npm run dev# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install# Check installed React version
npm list react
# If showing multiple versions, force single version
npm install react@18.2.0 react-dom@18.2.0If your project needs environment variables:
# Create .env file
cat > .env << 'EOF'
VITE_API_URL=http://localhost:8000
VITE_APP_NAME=FastAPI Tutorial
EOF
# Access in code with: import.meta.env.VITE_API_URL# Initialize Git (if not already done)
git init
# Add files
git add .
# Commit
git commit -m "Initial commit"
# Add remote (if not already added)
git remote add origin <your-repo-url>
# Push to GitHub
git push -u origin main# Pull latest changes
git pull origin main
# Make your changes to files
# ...
# Check what changed
git status
git diff
# Stage changes
git add .
# Commit with message
git commit -m "Description of changes"
# Push to remote
git push origin mainAdd to vite.config.js:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 5173,
hmr: {
overlay: true
}
},
build: {
sourcemap: false, // Faster builds
minify: 'terser'
}
})Already optimized with:
- Vite's tree-shaking
- Production build minification
- Code splitting
# Check disk usage
du -sh node_modules/ # ~200-300MB
du -sh dist/ # ~200KB after build
# Monitor dev server
# Dev server uses ~100-200MB RAM
# Build process uses ~500MB-1GB RAM temporarily# Check for outdated packages
npm outdated
# Update all to latest (careful - may break things)
npm update
# Update specific package
npm update lucide-react
# Update Node.js itself
# Use nvm (Node Version Manager) or download from nodejs.org# Remove node_modules (saves space when not developing)
rm -rf node_modules
# Clear npm cache
npm cache clean --force
# Reinstall when needed
npm install# Check for vulnerabilities
npm audit
# Fix vulnerabilities automatically
npm audit fix
# For high/critical issues requiring breaking changes
npm audit fix --force # Use with caution
# Update npm itself
npm install -g npm@latest- Customize the tutorial - Edit
src/App.jsxto modify lessons - Deploy - See
DEPLOYMENT_AWS.mdorDEPLOYMENT_GCP.md - Add features - Progress persistence, search, etc.
- Share - Push to GitHub and share the link
If you encounter issues:
- Check this guide's troubleshooting section
- Review the error message carefully
- Search GitHub issues
- Check Vite documentation: https://vitejs.dev
- Check React documentation: https://react.dev
- Node.js 20.x installed
- npm working
- Git installed and configured
- Repository cloned
- Dependencies installed (
npm install) - Config files present (tailwind.config.js, postcss.config.js)
- Dev server starts (
npm run dev) - Application loads in browser
- All 15 lessons visible
- Can navigate between lessons
- Copy buttons work
- Production build successful (
npm run build)
If all items are checked, you're ready to go!