This guide will help you set up a Node.js Backend project with a PostgreSQL database.
- Node.js: Ensure you have Node.js installed on your system.
- PostgreSQL: Install PostgreSQL on your machine.
- pg (Node.js client): This is a popular PostgreSQL client for Node.js. We'll install it using npm.
-
Clone the repository and navigate to the backend:
git clone [https://github.com/arifuzzaman31/manushtech_task.git](https://github.com/arifuzzaman31/manushtech_task.git) cd manushtech_task/backend/ -
Initialize a Node.js Project:
npm install
You'll need to create a file to store your database connection string. It is common to use a .env file for this, and the dotenv package to load it.
-
Create a Database:
-
Open the PostgreSQL command-line interface (e.g.,
psql) or a GUI tool like pgAdmin. -
Create a new database. For example:
CREATE DATABASE manushtech_pgdb;
-
-
Create a
.envfile:nano .env -
Add the Connection String to
.env:DATABASE_URL="postgresql://user:password@localhost:5432/manushtech_pgdb"- Important: Replace the values with your actual PostgreSQL credentials.
The connection string you provided, DATABASE_URL="postgresql://postgres:7575@localhost:5432/manushtech_pgdb", follows this general format:
postgresql://[user]:[password]@[host]:[port]/[database]
- Then, run the following commands:
npm install
npx prisma migrate dev --name initial
npx prisma generate
npm run seed
npm run devcd manushtech_task/frontend/
npm install
or
npm install -f
npm run dev
email: [email protected]
password: adminpassword