V
V
Volodymyr Palamar2021-07-30 16:21:37
MongoDB
Volodymyr Palamar, 2021-07-30 16:21:37

How to properly build the architecture of the admin panel and bot?

Hello,
there is a Viber bot written in nodejs that uses Mongoose to connect to MongoDB .
I wanted to use PHP for the admin. It should take orders from the database and if the operator accepts the order, send a hook to the bot address. But there was a problem that I have no idea how to implement another functionality, or rather menu editing .... The problem is that my php hosting does not have the ability to connect to MongoDB, using a bot as a proxy is also not the best idea....
I'm currently thinking of using Firebase realtime database but not sure yet.
Because in the near future I would like to connect several bots and have one admin panel for everyone... But I don’t want to keep dozens of connections in the background (Or maybe it’s not so scary ??)
Can someone suggest something

PS:
This bot for a restaurant menu is a category with inheritance and menu items

Category
import mongoose from "mongoose";

const Category = mongoose.model("Category",mongoose.Schema({
    name:{
        type:String,
        required:true
    },
    top:Boolean,
    childs:[
        {type:mongoose.Schema.Types.ObjectId,ref:"Category"}
    ]
},{versionKey: false}))

export default Category;
MenuItem
import mongoose from "mongoose";

const MenuItem = mongoose.model("MenuItem",mongoose.Schema({
    name:{
        type:String,
        required:true
    },
    category:{
        type:mongoose.Schema.Types.ObjectId,
        ref:"Category",
        required:true
    },
    image:{
        type:String,
        default: 'https://image.freepik.com/free-vector/hand-drawn-food-elements_1411-48.jpg'
    },
    description:{
        type:String,
        required:true
    },
    variants:[
        {
            price:Number,
            size:String,
            _id: false
        }
    ]
},{versionKey: false}))

export default MenuItem;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2021-07-30
@GORNOSTAY25

VPS/VDS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question