Follow these steps to set up the JavaDSA Learn project on your local machine.
Ensure you have the following installed:
- Node.js: Version 16.0.0 or higher. Download it from Node.js Official Website.
- npm: Comes bundled with Node.js. Verify installation using:
node -v npm -v
- Git: For cloning the repository. Download it from Git Official Website.
-
Navigate to the
backenddirectory: Ensure you are in the project root directory, then run:cd backend -
Install dependencies: Install all required Node.js packages:
npm install
-
Set up environment variables: Create a
.envfile by copying the example file:cp .env.example .env
Open the
.envfile and configure the following variables:PORT: The port number for the backend server (default:5000).JWT_SECRET: A secret key for JWT authentication.PISTON_API_URL: The URL for the Piston API (used for code execution).
-
Start the development server: Run the following command to start the backend server:
npm run dev
The backend server should now be running at
http://localhost:5000.
-
Navigate to the
frontenddirectory: From the project root directory, run:cd frontend -
Install dependencies: Install all required Node.js packages:
npm install
-
Set up environment variables: Create a
.envfile by copying the example file:cp .env.example .env
Open the
.envfile and configure the following variables:VITE_API_URL: The URL of the backend server (default:http://localhost:5000).
-
Start the development server: Run the following command to start the frontend application:
npm run dev
The frontend application should now be running at
http://localhost:5173.
This project uses JSON file storage for simplicity. Ensure the data directory exists in the backend folder. If not, create it manually:
mkdir backend/dataTo ensure everything is working correctly, you can run the test suite:
-
Backend Tests: Navigate to the
backenddirectory and run:npm test -
Frontend Tests: Navigate to the
frontenddirectory and run:npm test
-
Port Conflicts: If the default ports (
5000for backend,5173for frontend) are in use, update thePORTandVITE_API_URLvariables in the respective.envfiles. -
Dependency Issues: If you encounter dependency errors, try deleting the
node_modulesfolder and reinstalling:rm -rf node_modules npm install
-
Environment Variable Errors: Ensure all required variables are correctly set in the
.envfiles.
For further assistance, refer to the contact information provided in the README file.