Skip to content

Backend for Carboard Vehicles Rental specializes in providing a wide range of rental vehicles, roast with backend experience

Notifications You must be signed in to change notification settings

Derida23/Carboard-Backend

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Carboard Application Documentation

Overview

Carboard Vehicles Rental specializes in providing a wide range of rental vehicles, from compact cars to luxury SUVs, catering to diverse transportation needs. Our fleet includes environmentally friendly options, ensuring both comfort and sustainability. Discover seamless rental experiences with flexible terms and exceptional customer service, tailored to meet every travel requirement.

Prerequisites

Before running the application, ensure you have the following installed:

  • Node.js
  • npm or yarn
  • PostgreSQL

Setup

  1. Clone this repository
git clone <repository-url>
cd <repository-name>
  1. Install dependencies:
$ npm install
# or
$ yarn install
  1. Set up environment variables: Create a .env file in the root directory and configure the DATABASE_URL for your PostgreSQL database.
PORT=
DATABASE_URL=
API_PREFIX=

JWT_SECRET=
JWT_EXPIRES_IN=

CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
CLOUDINARY_CLOUD_NAME=
  1. Run migrations:
npx prisma migrate dev

This will apply migrations defined in your Prisma schema to your database.

  1. Start the application:
$ npm run start
# or
$ yarn start

The application will be accessible at http://localhost:{port}.

Prisma Schema

Below is a summary of the Prisma schema used in this application:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model users {
  id           Int       @id @default(autoincrement())
  name         String
  email        String    @unique
  password     String
  address      String?
  avatar       String?
  phone_number String?
  role         String
  created_at   DateTime?  @default(now())
  updated_at   DateTime? @updatedAt
  deleted_at   DateTime?
}

model products {
  id              Int       @id @default(autoincrement())
  name            String
  description     String
  id_type         Int
  id_mark         Int
  price           Float
  seat            Int
  id_transmission Int
  id_fuel         Int
  image           String?
  created_at      DateTime?  @default(now())
  updated_at      DateTime? @updatedAt
  deleted_at      DateTime?

  type         types         @relation(fields: [id_type], references: [id])
  mark         marks         @relation(fields: [id_mark], references: [id])
  transmission transmissions @relation(fields: [id_transmission], references: [id])
  fuels        fuels         @relation(fields: [id_fuel], references: [id])
}

model types {
  id          Int        @id @default(autoincrement())
  name        String
  description String?
  products    products[]
  created_at  DateTime?   @default(now())
  updated_at  DateTime?  @updatedAt
  deleted_at  DateTime?
}

model marks {
  id          Int        @id @default(autoincrement())
  name        String
  description String?
  products    products[]
  created_at  DateTime?   @default(now())
  updated_at  DateTime?  @updatedAt
  deleted_at  DateTime?
}

model transmissions {
  id          Int        @id @default(autoincrement())
  name        String
  description String?
  products    products[]
  created_at  DateTime?   @default(now())
  updated_at  DateTime?  @updatedAt
  deleted_at  DateTime?
}

model fuels {
  id          Int        @id @default(autoincrement())
  name        String
  description String?
  products    products[]
  created_at  DateTime?   @default(now())
  updated_at  DateTime?  @updatedAt
  deleted_at  DateTime?
}

Usage

Auth

  • Register : POST /register
{
  "name": "John Doe",
  "email": "john.doe@example.com",
  "password": "password",
  "role": "user"
}
  • Login : POST /login
{
  "email": "john.doe@example.com",
  "password": "password",
}

Product

  • Create a Product: POST /products
{
  "name": "Product Name",
  "description": "Product Description",
  "id_type": 1, // unit of measurment relation
  "id_mark": 1, // unit of measurment relation
  "price": 99.99, // unit of measurment relation
  "seat": 5,
  "id_transmission": 1, // unit of measurment relation
  "id_fuel": 1, // unit of measurment relation
  "image": "http://example.com/image.jpg" //integrated with cloudinary
}
  • Get All Products: GET /products
  • Get Product by ID: GET /products/:id
  • Update Product: PATCH /products/:id
  • Delete Product: DELETE /products/:id

Service

Another endpoint service you can check in /src folder and response data from /dto

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

tldr

Hi, this is only product management cardboard vehicles, next version build with relation transaction and payment, cheers up!

About

Backend for Carboard Vehicles Rental specializes in providing a wide range of rental vehicles, roast with backend experience

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published