Microservices Architecture from Scratch and Demo

Sample Microservices Architecture
Technologies used in Demo
npm install express body-parser nodemon mongoose
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());const mongoose = require("mongoose");
mongoose.connect('mongodb://localhost:27017/library-book', {useNewUrlParser: true}, () => {
console.log("mongoose connected")
})
app.listen(3000, () =>{
console.log("Book Server start");
})
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());const mongoose = require("mongoose");
mongoose.connect('mongodb://localhost:27017/library-customer', {useNewUrlParser: true}, () => {
console.log("mongoose connected")
})
app.listen(4000, () =>{
console.log("Customer Server start");
})
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());const mongoose = require("mongoose");
mongoose.connect('mongodb://localhost:27017/library-order', {useNewUrlParser: true}, () => {
console.log("mongoose connected")
})
app.listen(4000, () =>{
console.log("Order Server start");
})
const mongoose = require("mongoose");
mongoose.model('Book',{
title:{
type:String,
require:true
},
author:{
type:String,
require:true
},
numberofPages:{
type:Number,
require:true
},
publisher:{
type:String,
require:true
}
})
const mongoose = require("mongoose");
mongoose.model('Cutomer',{
name:{
type:String,
require:true
},
age:{
type:String,
require:true
},
address:{
type:String,
require:true
}
})
const mongoose = require("mongoose");
mongoose.model('Order',{
customerID:{
type:mongoose.SchemaTypes.ObjectId,
require:true
},
BookID:{
type:mongoose.SchemaTypes.ObjectId,
require:true
},
initialDate:{
type:Date,
require:true
},
deliveryDate:{
type:Date,
require:true
}
})

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Krishnadeva Sathursan

Krishnadeva Sathursan

Computer Engineering Student (University Of Peradeniya)