Skip to content

Backend for the case-study application with PostgreSQL, TypeScript, Node.js and Express.js Stack

License

Notifications You must be signed in to change notification settings

sandhyasrini/intervention-randomizer-api

Repository files navigation

intervention-randomizer-api

Backend for the case-study application with PostgreSQL, TypeScript, Node.js and Express.js Stack

Features

  • Display a table with details of developers
  • Ability to create a new User
  • Ability to Edit existing User
  • Generate a Random list for the intervention with a designated speaker
  • Generate an alphabetised list of speakers with a designated speaker
  • Pagination for the table component

Stacks used

  • Language: Typescript
  • Frontend development Library: ReactJS 18
  • State container: Redux, Redux Toolkit
  • CSS: Tailwind CSS
  • HTTP Client: Axios
  • Backend development Library: Node.js
  • ORM: Prisma
  • Database: Postgres
  • Web application framework: Express JS

Prerequisites

Prerequisite Link
Git 🔗
Node 16 🔗
Yarn 🔗
MongoDB* 🔗
Docker* 🔗

*You can have postgres either installed in your system or running in docker

Setup

Frontend

Install dependencies:

Clone the github repository: https://github.com/sandhyasrini/Intervention-Randomizer-UI.git

cd Intervention-Randomizer-UI
npm install

or

yarn install

Run the frontend:

npm run start

or

yarn start

Backend

Install dependencies:

Clone this git repository: https://github.com/sandhyasrini/intervention-randomizer-api.git

cd intervention-randomizer-api
npm install

or

yarn install

Run the backend

npm run serve

or

yarn serve

Database

  • If you have docker setup in your machine, you can follow the below steps to setup DB for the Application

Go to the API Project folder(intervention-randomizer-api) cloned in your local system

Build docker Image for Postgres:

docker build -t my-postgres-db ./ --no-cache

Check if image built:

docker images

eg:

$ docker images -a
REPOSITORY       TAG       IMAGE ID       CREATED        SIZE
my-postgres-db   latest    38036a25ec7b   13 hours ago   379MB

Run the image as a container:

docker run -d --name my-postgresdb-container -p 5432:5432 -e POSTGRES_PASSWORD={password} my-postgres-db

Make sure the beyond_play.sql file is present in the folder before running the container. This file creates the DB required for the application.

  • If you have Postgres installed in your local system, create a Database called beyond_play and run the beyond_play.sql in postgres to create the DB and inject data.

Create a .env file in the project folder, add your Database URL:

DATABASE_URL="postgres://{username}:{password}@localhost:5432/beyond_play"

If you're running in docker, the default username would be postgres unless specified otherwise

Environment vars

This project uses the following environment variables:

Name Description Default Value
ORIGIN Cors accepted values "http://localhost:3000"
PORT Port on which the server runs "3001"
DATABASE_URL Connection string for Postgres "postgres://{username}:{password}@localhost:5432/beyond_play"

API Endpoints

http://localhost:3001/api/docs/#/

Todos/Future Scope:

These were not implemented due to time constraints but can be done as part of a future scope

  • Unit Testing
  • Ability to search and find individual user
  • Error handling for custom error codes
  • Security implementation with JWT and Passport
  • Deploying to docker containers

About

Backend for the case-study application with PostgreSQL, TypeScript, Node.js and Express.js Stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published