Coder Social home page Coder Social logo

food-app-nestjs's Introduction

What is this?

It's a simple food application on top of Nestjs & MongoDB. It can be used for learning purposes & will be extended bit by bit.

What are the features so far?

  • Possible to register as a customer & restaurant user.
  • Get verification link & verified by mail.
  • JWT token and role-based authentications are available.
  • Restaurant users can perform CRUD operations on the items.
  • Restaurant user is also allowed to give discount on the item & total amount of order as well.
  • Customer can perform CRUD operation on carts & also request for the orders.
  • Customers are allowed to give ratings for restaurants.
  • Users can search restaurants.
  • Rate limiting of requests.

ERD

Food App ERD

What has been used by far?

Name version
NestJS 10.2.10
MongoDB 7.0.4
Mongo-express latest
Elasticsearch 10.0.1
Kibana 10.0.1
@nestjs/swagger 7.1.16

Run the app using docker

# development (To start all the services)
$ docker-compose -f docker-compose.dev.yml --env-file env/.dev.env build --no-cache
$ docker-compose -f docker-compose.dev.yml --env-file env/.dev.env up

# development (To start any service)
$ docker-compose -f docker-compose.dev.yml --env-file env/.dev.env build --no-cache anyServiceName
$ docker-compose -f docker-compose.dev.yml --env-file env/.dev.env up anyServiceName

# production mode

Mongo Export

# Export results in a file
$ docker exec mongoContainerName mongoexport --uri="mongodb://UN:PWD@mongoContainerName:27017/DBName" --collection=CollectionName --type=json --fields=field1,field2 --out=collectionName.json --jsonArray 

# Copy the file from DB Container
$ docker cp DBcontainerName:/collectionName.json destinationFolderPath

More on - mongoexport

Mongo Shell

# Get inside the DB container
$ docker exec -it dbContainerName bash
# Use mongosh shell
$ mongosh -u username -p password dbName

More on - Mongosh shell doc

Setup ELK

This command will only work during the initial configuration of the Elasticsearch security features.For More Info - Elasticsearch Doc. On the other hand, by using kibana password can be changed for the user. Go to Management > Stack Management > Security > Users

# Set password for ELK
$ docker exec -it ESContainerName bin/elasticsearch-reset-password -u elastic -i
$ docker exec -it ESContainerName bin/elasticsearch-reset-password -u kibana_system -i

Insert Mapping for restaurant in ES by using Kibana Dev tools

PUT restaurants 
{
  "mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "name": {
        "type": "text"
      },
      "address": {
        "type": "text"
      },
      "opening_time": {
        "type": "date",
        "format": "HH:mm:ss"
      },
      "closing_time": {
        "type": "date",
        "format": "HH:mm:ss"
      },
      "current_status": {
        "type": "text"
      }
    }
  }
}

Add restaurants info to Elasticsearch (Executed in root path)

# Prepare restaurants data according to ES Mapping
$ docker exec food-dev npx ts-node streamData.js

# Insert data to ES
$ docker exec food-dev node_modules/elasticdump/bin/elasticdump --input=restaurant.json --output=http://esUN:esPW@esFood01:9200/ --type=data

To find Circular dependency (madge)

Graphviz (optional) - To see a graphical representation

$ npm install madge --save-dev
$ npx ts-node circular.js

Different URLs

Test

# unit tests
$ npm run test yourFolderPath/fileName.spec.ts

# e2e tests
$ npm run test:e2e test/fileName.e2e-spec.ts

# test coverage

CI/CD integration

Stay in touch

food-app-nestjs's People

Contributors

tusharroy23 avatar

Stargazers

Ansh Aggarwal avatar Ahmet AYDIN avatar Ahmed Ezzeldin avatar Fahim Hassan Mollah avatar Renato C. Francisco avatar Elder Samuel avatar Olawale Afuye  avatar Sourav Barua avatar

Watchers

 avatar

Forkers

jawad-jatri

food-app-nestjs's Issues

production docker COPY multistage typo (from staging)

food-app-nestjs/dockerfiles/Dockerfile-prod
https://github.com/TusharRoy23/food-app-nestjs/blob/master/dockerfiles/Dockerfile-prod#L20

has

# Stage 2
FROM node:18-alpine as productionBuild

but is using

COPY --from=stagingBuild /usr/src/app/node_modules ./node_modules
COPY --from=stagingBuild /usr/src/app/dist ./dist

shouldnt it be instead

COPY --from=productionBuild /usr/src/app/node_modules ./node_modules
COPY --from=productionBuild /usr/src/app/dist ./dist

Cant open PR (no permissions) so leaving details here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.