当前位置:网站首页>Brief analysis of application source code of neo4j intelligent supply chain
Brief analysis of application source code of neo4j intelligent supply chain
2022-06-22 02:31:00 【Neo4j developer】

stay 4 month 13 It was held on the 7th Neo4j The the Belt and Road of related data Theme activities ,Neo4j Asia Pacific presales and service director Joshua Yu Shared Use knowledge map 、 The case and demonstration of the intelligent supply chain digital infrastructure built by the Internet of things and the digital twin , The intuitive and cool front-end interaction and visual interface have attracted many viewers . Based on this case, this paper gives you an in-depth analysis of the source code , Let you also have a set of intelligent supply chain basic programs that can be customized and run immediately .
We can take a look at a demonstration of this system .

Next, we will analyze this case from the following parts .
Business needs
In response to demand fluctuations , Organizations are relying on predictive and normative analysis 、 machine learning 、 Artificial intelligence and enhancement technology , Provide clear solutions for unexpected problems and potential problems in the future . This includes shortening production time 、 Determine the best way to buffer supply and inventory , And automated processes to cope with supply shortages .
Graph technology for optimizing logistics 、 It is very important to find loopholes and improve the overall supply chain flexibility . In any business , Especially in retail and warehouse distribution , On stock 、 The need for accurate information about product inventory and how it is delivered is critical . The more steps in the supply chain , The greater the risk of instability . The graph database is well suited for this task , Because they are good at expressing complex relationships . therefore , The graph based supply chain management approach provides the flexibility and scalability needed to meet these challenges . By representing the data as a series of interconnected nodes ,Neo4j You can easily model complex relationships , And identify patterns and insights hidden in traditional tabular datasets .
In this demonstration , Here's what we're focusing on Warehouse 、 Delivery and Fleet Management problem .
In the business analysis phase , Then we can model graph data , Don't forget to work with business experts to draw the relationship between business and . The data model for this demonstration is as follows :

Can you see the specific business from the graph data model ?
System architecture
In order to intuitively show the situation of the supply chain , We need a very visual and interactive way , This demo uses a series of front-end visualization frameworks , And the use of Angular As a load-bearing frame .
At the same time, we need a set of server to interact with the database and the front end , And implement business logic and API. Here we use .NET Core To achieve , By default Web API The architecture and use of Repository As the data layer interface .
On the database side, we used Neo4j AuraDB, It can be used quickly without any operation and maintenance .
In addition, we also designed a complete deployment architecture , You can refer to this design to deploy the whole system in the cloud .

Source code parsing
Sounds like you're ready to try, right , Next, we start from the underlying database and interpret the source code step by step , I hope you can run your own version directly after completion .
The source code of this case is in GitHub, You can clone it locally for development . I'm going to use it here Visual Studio Code To develop and debug .

Neo4j AuraDB initialization
Let's first create AuraDB Example . You can choose the data center you want to deploy , You can also refer to the data center that the entire system needs to deploy to flexibly select .

After the instance is created , This demo prepares some test data ,Cypher The script is located in the path supply-chain-demo/DBScripts/populateDB.txt. Use Neo4j Browser Run the script to import the data .
Next, you need to record the connection string information of the database , Used to connect to the database from the server .

Server side Neo4j Back Source code
With the database instance and connection string , Let's take a look at the server code . First look at the directory structure .

The main project of the server is SpikeNeo4j, There are also test items SpikeNeo4j.Tests, This article only introduces the main project .
How to follow Neo4j Database interaction
To follow Neo4j AuraDB Database interaction , The project uses the contribution of the community .NET drive Neo4jClient. meanwhile , The connection string and other information are passed through appsettings.json File to manage .
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Neo4j": {
"Host": "neo4j+s://64e5d198.databases.neo4j.io",
"User": "xxxxx",
"Pass": "xxxxx"
},
"AppSettings": {
"Token": "xxxxx"
},
"Login": {
"Username": "xxx",
"Password": "xxx"
},
"ApikeyGoogleMaps": {
"ApiKey": "xxxxxxxxxxx"
}
}
Besides , And maps and Swagger Related libraries . You can explore further by browsing the project file .
Repository Is a data layer access encapsulation pattern , Interface file IClienteSpikeNeo4jRepository.cs Define the method of data acquisition .
In the file Startup.cs Well configured Neo4j Driver Single instance implementation of , The code is as follows :
private IGraphClient GetGraphClient(IServiceProvider provider)
{
//Create our IGraphClient instance.
var client = new BoltGraphClient(Configuration["Neo4j:Host"], Configuration["Neo4j:User"], Configuration["Neo4j:Pass"]);
//We have to connect - as this is fully async, we need to 'Wait()'
client.ConnectAsync().Wait();
return client;
}
Use MVC Pattern realization API
API Layers pass through MVC Pattern realization , In the file Neo4jClientController.cs You can see API Realization .
And then through Swagger To expose API Interfaces and documentation .
Running server
If you want to see the effect , You can run the server , It needs to be installed .NET, Access address get.dot.net You can download the appropriate version of your system .
Then switch to the directory in the terminal Neo4j Back/SpikeNeo4j, Run the command dotnet run, If you see the following information, you have successfully compiled and run .
SpikeNeo4j[main*] % dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /Users/shinyzhu/Documents/GitHub/supply-chain-demo/Neo4J Back/SpikeNeo4j
here , Open browser access https://localhost:5001/swagger You can open Swagger Page .
front end Neo4j Front Source code
Server side API When ready , Let's take a look at front-end applications . The directory structure is as follows :

The front-end of the project uses Angular To build ,Angular Is a very popular front-end modular framework , It also includes a map library Leaflet, Chart Library ECharts and ChartJS, wait .
Configure the backend API Information
The front end needs to be consistent with the server end API Interaction , You can modify the file Neo4J Front/src/environments/environment.ts To specify your server API Address .
export const environment = {
production: false,
urlApi:
'https://localhost:5001/api',
};
Run front end
Front end applications are based on NodeJS Of , So you need to install it in advance , Access address nodejs.org You can find download .Angular We go through NodeJS Just install it , Relevant libraries have been configured in this project , So it can be run directly from the project .
If you have installed NodeJS, But there is no global installation Angular. You can run commands npx ng serve You can start the front-end application .
Neo4J Front[main*] % npx ng serve
⠦ Generating browser application bundles (phase: building)...WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.
Recommendation: math.div($size, 16)
More info and automated migrator: https://sass-lang.com/d/slash-div
╷
21 │ $unit: $size / 16;
│ ^^^^^^^^^^
╵
src/app/maps/map2d/map2d.component.scss 21:8 root stylesheet
Browser application bundle generation complete.
Initial Chunk Files | Names | Size
vendor.js | vendor | 2.76 MB
scripts.js | scripts | 997.21 kB
polyfills.js | polyfills | 123.38 kB
main.js | main | 49.92 kB
styles.css | styles | 23.75 kB
runtime.js | runtime | 12.53 kB
| Initial Total | 3.94 MB
Lazy Chunk Files | Names | Size
src_app_maps_maps_module_ts.js | - | 5.88 MB
Build at: 2022-05-10T04:02:44.230Z - Hash: 0461de2fe12622853272 - Time: 9284ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Compiled successfully.
Then we open the browser , visit http://localhost:4200 You can see cool front-end applications .
Cloud deployment
The advantage of cloud computing services is that they provide out of the box services ,Neo4j Not only DBaaS Fully managed services for AuraDB, You can also find different VM templates in the market of cloud vendors , It can also be used for rapid deployment Neo4j database .
The server uses cross platform .NET Core, So it can be easily integrated into existing CI/CD etc. DevOps In the process .
You can learn about the services provided by the cloud vendors you are using or familiar with , So as to further improve the architecture of the whole system .
summary
Come here , You should have run the demonstrated complete supply chain project . No matter what part you are interested in , I hope they can bring you a complete set of plans , Inspire you .
Resource link
Neo4j Supply chain case code base :https://github.com/neo4j-examples/supply-chain-demo
Deployed online cases :http://dev.neo4j.com/supply-chain-demo
Free use Neo4j AuraDB:https://neo4j.com/aura
Joshua Yu Sharing and playback of :https://www.bilibili.com/video/BV1N5411m7fv?t=0h6m30s
Neo4j Supply chain management use cases :https://neo4j.com/use-cases/supply-chain-management/
边栏推荐
- EMC rectification tips
- PMP pre exam guide on June 25, you need to do these well
- OpenJudge NOI 1.13 46:八进制到十进制
- 智翔金泰冲刺科创板:年营收3919万亏损超3亿 拟募资40亿
- EMC radiation emission rectification - principle case analysis
- Development of power plant compliance test system with LabVIEW
- cmake常用命令分类备忘
- Idea ---- copy and paste
- New employees enter the company and learn about work information
- Matlab learning notes (4) matlab array
猜你喜欢

基于xposed框架hook使用
![Leetcode 513 find the value in the lower left corner of the tree [bfs binary tree] the leetcode path of heroding](/img/15/b406e7bf1b83cbdd685c8cde427786.png)
Leetcode 513 find the value in the lower left corner of the tree [bfs binary tree] the leetcode path of heroding
![[Chapter 14 image compression and reconstruction based on principal component analysis -- matlab deep learning practical case]](/img/fa/a3ff1c0213d953f7ef8a01ea7672b9.png)
[Chapter 14 image compression and reconstruction based on principal component analysis -- matlab deep learning practical case]

微信小程序影視評論交流平臺系統畢業設計畢設(4)開題報告

目标检测之——labelImg标注工具使用方法

微信小程序影视评论交流平台系统毕业设计毕设(6)开题答辩PPT

本周一问 | -leaf 这个属性的含义?

带你区分几种并行

Using hook based on xposed framework

MySQL 递归查找树形结构,这个方法太实用了!
随机推荐
[proteus simulation] INT0 and INT1 interrupt count
Minecraft 1.18.2 biochemical 8 module version 1.3 3D objects + more complex villages
基于xposed框架hook使用
Cmake common command category notes
Extending kubernetes API with CRD
剑指offer 26:树的子结构
In 2022, the number of mobile banking users in Q1 will reach 650million, and ESG personal financial product innovation will be strengthened
Official release of ideal L9: retail price of 459800 yuan will be delivered before the end of August
Programming of pytorch interface
idea----bookmark
C # judge whether the application is started and displayed
EMC rectification tips
使用 OKR 进行 HR 数字化转型
What does informer have
Return to Chengdu to start my software testing career
Courses learned
Zap grammar sugar
最新发布:Neo4j 图数据科学 GDS 2.0 和 AuraDS GA
fatal error: png++/png.hpp: 没有那个文件或目录
使用 OKR 進行 HR 數字化轉型