Build a NestJS Full Stack Application – Part I

With this post, we will start a series of posts to build a full-stack application using NestJS. NestJS is a popular framework to build scalable and efficient Node.JS server-side applications.

Techstack

To build this application, we will be using multiple different frameworks.

  • Backend – NestJS with Typescript
  • Frontend – NextJS with Typescript
  • Database – MySQL
  • ORM – Prisma
  • Cloud Provider – Amazon Web Services (AWS)

Application Ideation

Everything starts with an idea and execution. The idea for this application is to build an applicant tracking system for recruiting agencies.

There are two types of users in this application. A recruiter creates the job and an applicant who applies for that job. Once the applicants apply for the job, the recruiter reviews the application, contacts applicants, and invites them for an interview. Once the interview is complete, the result is updated in the system so that an applicant can view it at any time.

There are various stages that a job application goes through.

For recruiter – Job creation -> Interview in progress -> Candidate selected -> Job complete -> Job expired.

For candidate – Job application -> Interview if selected -> Result.

There will be a bunch of automation involved with respect to notification through the life-cycle of the job.

NestJS Setup

We will be using the NestJS framework with typescript to build the backend of this application. Additionally, we will use ReactJS with typescript for the front end of this application.

Nevertheless, we will set up our NestJS framework on our development machine.

Create a new app using NestJS with the following command:

nest new staffingapp

Just like in previous articles, we will use prisma as our ORM for creating this nestjs application.

  • Install Prisma dependencies

npm install prisma --save-dev

npm install @prisma/client

  • Create initial Prisma setup

npx prisma init

If you are using a Windows environment, you might run into an error while running the above command. So set environment variables

set PRISMA_CLI_QUERY_ENGINE_TYPE=binary

set PRISMA_CLIENT_ENGINE_TYPE=binary

This completes our initial backend app setup. Let’s create a data model for this application further.

Data Model for Staffing App

We have three main data objects.

  • User
  • Job
  • Company

There are more that we will require for a functioning app, but for now we will look at these three only.

These models will contain the following fields:


enum ROLE {
  CANDIDATE
  RECRUITER
  ADMIN
}

model User {
  id         String @id @default(uuid())
  email      String @unique
  first_name String 
  last_name  String 
  password   String 
  company  Company @relation(fields: [company_id], references: [id])
  company_id  String
  role       ROLE
  created_at DateTime @default(now())
  updated_at DateTime @default(now())  
}

model Company {
  id         String  @id @default(uuid())
  name       String  
  type       String 
  user       User[]
  job        Job[]
  created_at DateTime @default(now())
  updated_at DateTime @default(now())
}
enum JobType {
  FULLTIME
  PARTTIME
  CONTRACTOR
  INTERN
}
model Job {
  id         String   @id @default(uuid())
  job_type    JobType 
  job_name    String 
  job_role    String
  description String 
  job_details JobDetails @relation(fields: [job_details_id], references: [id])
  job_details_id String @unique
  company    Company @relation(fields: [company_id], references: [id])
  company_id  String
  expires_at DateTime
  created_at DateTime @default(now())
  updated_at DateTime @default(now())
}

model JobDetails {
  id              String @id @default(uuid())
  salary_details  String
  benefit_details String
  job             Job?
  created_at      DateTime @default(now())
  updated_at      DateTime @default(now())
}

With the above data model, we have set up the initial database and application. In the next post, we will create backend APIs and integrate them with the database.

Conclusion

In this post, we started building a full-stack application using NestJS framework. We set up the initial application and database along with Prisma ORM.