Skip to content

TusharRoy23/food-app-nestjs

Repository files navigation

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

About

food app on nestjs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published