A full-stack monorepo with backend (Express.js) and frontend (Vue 3 + Vite + Element Plus) applications.
This monorepo contains two main applications:
- Backend: RESTful API built with Express.js
- Frontend: Web UI built with Vue 3, Vite, and Element Plus UI library
Both applications are organized in a single repository with shared tooling and npm workspaces configuration for streamlined development.
Before you begin, ensure you have installed:
- Node.js (v18.x or higher)
- npm (v9.x or higher) or yarn (v3.x or higher)
- MySQL (v5.7 or higher) - optional, if you plan to use database features
.
├── backend/ # Express.js backend API
│ ├── src/
│ │ └── index.js # Main server file
│ ├── dist/ # Built files (generated)
│ ├── tests/ # CI-ready test directory
│ ├── package.json
│ ├── .env.example
│ └── README.md
├── frontend/ # Vue 3 + Vite frontend
│ ├── src/
│ │ ├── main.js # Entry point
│ │ └── App.vue # Root component
│ ├── dist/ # Built files (generated)
│ ├── tests/ # CI-ready test directory
│ ├── index.html
│ ├── vite.config.js
│ ├── package.json
│ ├── .env.example
│ └── README.md
├── package.json # Root workspace configuration
├── .editorconfig
├── .eslintrc.json
├── .prettierrc
├── .prettierignore
├── .gitignore
└── README.md
git clone <repository-url>
cd monorepoUsing npm:
npm installUsing yarn:
yarn installCopy the example environment file and update with your settings:
cp backend/.env.example backend/.envKey environment variables:
PORT- Server port (default: 3000)NODE_ENV- Environment mode (development/production)DB_HOST- MySQL hostDB_PORT- MySQL portDB_USER- MySQL usernameDB_PASSWORD- MySQL passwordDB_NAME- Database nameJWT_SECRET- JWT signing secretCORS_ORIGIN- CORS allowed origin (frontend URL)
Copy the example environment file and update with your settings:
cp frontend/.env.example frontend/.env.localKey environment variables:
VITE_API_BASE_URL- Backend API base URL (default: http://localhost:3000)
npm run devThis will start:
- Backend server on
http://localhost:3000 - Frontend application on
http://localhost:5173
Backend only:
npm run dev --workspace=backendFrontend only:
npm run dev --workspace=frontend- Open
http://localhost:5173in your browser - The landing page should display
- Click "Check Backend Health" to verify backend connectivity
# Start development servers for both backend and frontend
npm run dev
# Build both applications
npm run build
# Lint all code
npm run lint
# Format code with Prettier
npm run format# Start development server with file watching
npm run dev --workspace=backend
# Build backend
npm run build --workspace=backend
# Start production server
npm run start --workspace=backend
# Lint backend code
npm run lint --workspace=backend# Start development server
npm run dev --workspace=frontend
# Build for production
npm run build --workspace=frontend
# Preview production build
npm run preview --workspace=frontend
# Lint frontend code
npm run lint --workspace=frontend-
Start both development servers:
npm run dev
-
The backend server will be available at
http://localhost:3000 -
The frontend application will be available at
http://localhost:5173 -
Make changes to code - both applications support hot module reloading
Before committing code, ensure it passes linting and formatting checks:
# Check for linting errors
npm run lint
# Format code
npm run formatGET /api/health
Returns:
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z",
"message": "Backend is running"
}GET /api
Returns:
{
"message": "Welcome to the API",
"version": "1.0.0"
}This project uses npm/yarn workspaces for efficient dependency management. Both backend and frontend are configured as workspaces in the root package.json.
- Shared development tools (ESLint, Prettier)
- Unified dependency management
- Convenient workspace scripts
- Simplified development workflow
Run commands in specific workspace:
npm run <script> --workspace=<workspace-name>Example:
npm run dev --workspace=backend
npm run build --workspace=frontendConfiguration files:
- Root:
.eslintrc.json(base configuration) - Backend:
backend/.eslintrc.json(Node.js specific) - Frontend:
frontend/.eslintrc.json(Vue 3 specific)
Configuration files:
- Root:
.prettierrc(shared formatting rules) - Root:
.prettierignore(ignore patterns)
- Root:
.editorconfig(editor settings across IDEs)
Both applications have tests/ directories prepared for future CI/CD integration:
backend/tests/ # CI-ready for backend tests
frontend/tests/ # CI-ready for frontend tests
If you get a "port already in use" error:
Backend (port 3000):
# Change PORT in backend/.env
PORT=3001 npm run dev --workspace=backendFrontend (port 5173):
# Vite will automatically use the next available port
npm run dev --workspace=frontendIf you encounter "module not found" errors:
-
Ensure all dependencies are installed:
npm install
-
Clear node_modules and reinstall:
rm -rf node_modules backend/node_modules frontend/node_modules npm install
If frontend cannot reach backend, ensure:
- Backend is running on the correct port
CORS_ORIGINinbackend/.envmatches your frontend URLVITE_API_BASE_URLinfrontend/.env.localmatches your backend URL
- Create a feature branch
- Make your changes
- Run linting and formatting:
npm run lint npm run format
- Submit a pull request
This project is proprietary.
For issues or questions, please contact the development team.