Follow the steps below to set up and run the project on your local machine.
# Replace `<repository-url>` with the actual GitHub repository URL
git clone https://github.com/vatsaaaal/dragon-craigslist.git
cd dragon-craigslist
Ensure you have PostgreSQL installed on your machine. If not, follow these steps:
sudo apt update
sudo apt install postgresql postgresql-contrib
brew install postgresql
brew services start postgresql
- Download PostgreSQL from https://www.postgresql.org/download/.
- Follow the installer instructions to set up PostgreSQL.
This file provides a template for your environment configuration:
{
"PG_USER": "your_database_user",
"PG_HOST": "localhost",
"PG_DATABASE": "dragon_db",
"PG_PASSWORD": "your_database_password",
"PG_PORT": 5432,
"JWT_SECRET": "your_jwt_secret_key",
"FRONTEND_URL": "http://localhost:5173"
}
Create a file named env.json
in the root directory based on the example below:
{
"PG_USER": "postgres",
"PG_HOST": "localhost",
"PG_DATABASE": "dragon_db",
"PG_PASSWORD": "Longingia@12",
"PG_PORT": 5432,
"JWT_SECRET": "u+OnGjhDu4GmMFcPJJSDmjq448tCvTVUMt8AYT9JDM8=",
"FRONTEND_URL": "http://localhost:5173"
}
Use the following command to generate a secure JWT secret:
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
Add the generated key to the JWT_SECRET
field in your env.json
file.
Create a file named .env.local
in the root directory with the following content:
VITE_API_URL=http://localhost:3000
Run the following command to install the required Node.js modules:
npm install
Run the following command to create the required database and tables in PostgreSQL:
npm run setup
Use two separate terminals to start the backend and frontend servers:
npm run start
npm run dev
- Backend API:
http://localhost:3000
- Frontend:
http://localhost:5173
- Ensure PostgreSQL is running before executing the
npm run setup
command. - If you encounter any issues, ensure your environment variables are correctly set in the
env.json
and.env.local
files.