Before you begin, make sure you have the following installed:
| Requirement | Version | Notes |
|---|---|---|
| Node.js | >= 18.x | LTS recommended |
| npm | >= 9.x | Comes with Node.js |
| Git | Latest | For version control |
Verify your installation:
node --version # Should show v18.x or higher
npm --version # Should show 9.x or higher
git --version # Should show latest version# If using git
git clone <repository-url> js-boilerplate
cd js-boilerplatenpm installCopy the example environment file:
cp .env.example .envUpdate .env with your configuration:
VITE_API_BASE_URL=http://localhost:3001
VITE_APP_NAME=My Bootcamp App
VITE_JWT_EXPIRY=3600000# Start both Vite and JSON Server
npm run dev
# Or start individually:
npm run dev:vite # Only React app
npm run dev:server # Only JSON ServerThe app will be available at:
- React App: http://localhost:5173
- JSON Server: http://localhost:3001
| Command | Description |
|---|---|
npm run dev |
Start dev server + JSON Server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run format |
Format code with Prettier |
npm run test |
Run tests |
npm run test:ui |
Run tests with UI |
npm run test:coverage |
Run tests with coverage |
src/
├── features/ # Feature-based modules
│ ├── auth/ # Complete auth example
│ │ ├── components/
│ │ ├── hooks/
│ │ └── services/
│ ├── products/ # Complete CRUD example
│ │ ├── components/
│ │ ├── context/
│ │ ├── hooks/
│ │ └── services/
│ └── ai/ # AI integration example
│ ├── components/
│ ├── context/
│ ├── hooks/
│ └── services/
├── components/ # Shared UI components
│ ├── ui/ # Button, Input, Modal, etc.
│ └── layout/ # Header, Footer, Layout
├── context/ # Global contexts
│ └── AuthContext.jsx
├── pages/ # Route pages
├── services/ # API services
├── hooks/ # Custom hooks
└── utils/ # Helpers
| File | Purpose |
|---|---|
src/main.jsx |
Entry point with providers |
src/App.jsx |
Main app with routing |
src/context/AuthContext.jsx |
Auth state management |
src/services/api.js |
Axios instance with interceptors |
src/features/products/context/ProductContext.jsx |
Product CRUD state |
- User enters credentials in LoginForm
- Form calls
useAuthContext()hook - Context makes API call via authService
- On success: stores token in localStorage, updates user state
- ProtectedRoute checks user from context
- Redirects to original destination if authenticated
- Components use
useProducts()hook - Hook accesses ProductContext
- Context methods call productService
- State updates trigger re-renders
- Loading/error states managed in context
- Components use
useAi()hook - Hook accesses AiContext
- Context calls
/api/ai/plan/suggest - Returns task suggestions and summary
- UI displays with accept/reject options
- Read the Testing Guide - Learn how to write tests
- Explore the Examples - Understand the auth and products features
- Check Best Practices - Avoid common mistakes
- Learn Extension Guide - How to add new features
# Find process using port 5173
lsof -i :5173
# Kill the process
kill -9 <PID>Make sure port 3001 is available:
lsof -i :3001# Clear npm cache
npm cache clean --force
# Remove node_modules and reinstall
rm -rf node_modules
npm install- Check the Architecture Decisions to understand the code structure
- Review Best Practices & Pitfalls for common issues
- See Extension Guide for adding features