Skip to content

kuldeepdebnath/PrimeTradeAi-Internship-Task

Repository files navigation

Internship Task Project

Project Setup

Follow the steps below to set up and run the project on your local machine.

Prerequisites

Ensure you have the following installed on your system:

  • Node.js (v24 or higher)
  • npm (v11.6.1 or higher)
  • PostgreSQL (v13 or higher)

Environment Variables

Create a .env file in the root directory of the project and configure the following variables:

NODE_ENV="development"
PORT="4000"
DATABASE_URL="postgresql://<username>:<password>@localhost:5432/internshipDB"
JWT_SECRET="<your-secret-key>"
SADMIN_ID="6df46fd7-d048-44c7-977b-a561c017e4a3"
CACHE_PROVIDER="node-cache"
STORAGE_DRIVER="fs"
APP_URL="http://localhost:4000"
UPLOAD_DIR="uploads"
MAX_FILE_SIZE_MB="20"
TX_MAX_WAIT_MS="120000"
TX_TIMEOUT_MS="120000"
COOKIE_DOMAIN=".localhost.com"
CORS_ORIGINS="http://localhost:3000"
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_SECURE="FALSE"
SMTP_USER="<your-smtp-email>"
SMTP_PASS="<your-smtp-password>"
SMTP_FROM="no-reply@localhost.com"
OTP_EXPIRY_MINUTES="5"

Database Setup

  1. Create a PostgreSQL database named internshipDB.
  2. Update the DATABASE_URL in the .env file with your PostgreSQL credentials.

Install Dependencies

Run the following command to install all required dependencies:

npm install

Run Migrations

Ensure the database schema is up-to-date by running:

npm run prisma:generate
npm run prisma:migrate

Seed the Database

Run the following commands to seed the database:

npx ts-node src/modules/auth/auth.seeder.ts
npx ts-node scripts/seed-csv.ts role ./data/seed-role.csv
npx ts-node scripts/seed-csv.ts permissionGroup ./data/seeders-permission_group.csv
npx ts-node scripts/seed-csv.ts permission ./data/seeders-permission.csv
npx ts-node scripts/seed-csv.ts rolePermission ./data/seeders-role_permission.csv
npx ts-node scripts/seed-csv.ts userRole ./data/seeders-user_roles.csv
npx ts-node scripts/seed-csv.ts metadataSchema ./data/seeders-meta_schema.csv
npx ts-node scripts/seed-csv.ts unit ./data/seeders-units.csv

SMTP Configuration

This project uses Gmail for SMTP. Follow this guide to generate SMTP credentials. Update the SMTP_USER and SMTP_PASS in the .env file with the generated credentials.

Run the Project

Start the development server using:

npm run dev

The server will be available at http://localhost:4000.

Project Structure

  • data/: Contains seeders data in CSV format.
  • scripts/: Contains logic for importing seeders.
  • postman-collection/: Contains Postman collections and environment files for API testing.
  • src/: Contains the main project source code.

Postman Collection

You can find the Postman collection and environment files in the postman-collection folder. Import these files into Postman to test the APIs.

Additional Notes

  • Ensure the UPLOAD_DIR specified in the .env file exists or create it manually.
  • The MAX_FILE_SIZE_MB specifies the maximum file upload size in MB.
  • The OTP_EXPIRY_MINUTES specifies the validity duration of OTPs in minutes.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors