Step 2. Project structure

Before we start actually writing our microservice, we need to create a directory structure in the project’s folder.

Create a folder for the project and, inside it, a directory structure to match the one below:

/bin
/config
/docker
/src
└───/build
└───/container
└───/data
│   └───/version1
└───/logic
└───/persistence
└───/service
    └───/version1
/test
└───/logic
└───/persistence
└───/service
    └───/version1

/bin
/config
/docker
/src
└───/build
└───/container
└───/data
│   └───/version1
└───/logic
└───/persistence
└───/service
    └───/version1
/test
└───/logic
└───/persistence
└───/service
    └───/version1

/bin
/config
/docker

/build
/container
/data
└───/version1
/logic
/persistence
/service
└───/version1

/test
└───/logic
└───/persistence
└───/service
    └───/version1

/bin
/config
/docker
/lib
└───/build
└───/container
└───/data
│   └───/version1
└───/logic
└───/persistence
└───/service
    └───/version1
/test
└───/logic
└───/persistence
└───/service
    └───/version1

/bin
/config
/docker
/src
└───/build
└───/container
└───/data
│   └───/version1
└───/logic
└───/persistence
└───/service
    └───/version1
/test
└───/logic
└───/persistence
└───/service
    └───/version1

Not available
Add a package.json file with the following lines to the root of the project's folder:

/package.json

{
  "name": "beacons",
  "version": "1.0.0",
  "main": "./obj/src/index.js",
  "typings": "./obj/src/index.d.ts",
  "scripts": {
    "test": "mocha -t 5000 -R spec -u tdd --recursive ./obj/test"
  },
  "dependencies": {
    "pip-services3-commons-node": "^3.0.*",
    "pip-services3-components-node": "^3.0.*",
    "pip-services3-container-node": "3.0.*",
    "pip-services3-data-node": "^3.0.*",
    "pip-services3-rpc-node": "^3.0.*",
    "pip-services3-mongodb-node": "^3.0.*"
  },
  "devDependencies": {
    "@types/async": "^2.0.49",
    "@types/chai": "^4.1.3",
    "@types/lodash": "^4.14.109",
    "@types/mocha": "^5.2.1",
    "@types/node": "^10.3.0",
    "chai": "^4.1.2",
    "mocha": "^5.2.0",
    "restify": "^4.3.0"
  }
}
Now, we must add a csproj files with the following lines to the next project folders:

src/interface/Interface.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RootNamespace>Beacons</RootNamespace>
    <AssemblyName>Beacons</AssemblyName>
    <ApplicationIcon />
    <Win32Resource />
    <Version>1.0.0</Version>
    <Authors>Sergey Seroukhov</Authors>
    <Copyright>Conceptual Vision Consulting LLC 2018</Copyright>
    <Description>Beacons microservice client</Description>
    <Company>Conceptual Vision Consulting LLC</Company>
    <Product>Beacons</Product>
    <PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
    <PackageProjectUrl>https://github.com/pip-services/pip-services</PackageProjectUrl>
    <PackageIconUrl>https://github.com/pip-services/pip-services/design/Logo.png</PackageIconUrl>
    <PackageTags>microservices beacons</PackageTags>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="PipServices3.Commons" Version="3.1.2" />
  </ItemGroup>

</Project>

src/interface/Process.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <AssemblyName>main</AssemblyName>
    <RootNamespace>Beacons</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Service\Service.csproj" />
  </ItemGroup>

</Project>

src/interface/Service.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RootNamespace>Beacons</RootNamespace>
    <AssemblyName>Beacons.Service</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="PipServices3.Commons" Version="3.1.2" />
    <PackageReference Include="PipServices3.Components" Version="3.2.1" />
    <PackageReference Include="PipServices3.Container" Version="3.1.2" />
    <PackageReference Include="PipServices3.Data" Version="3.2.3" />
    <PackageReference Include="PipServices3.MongoDb" Version="3.3.0" />
    <PackageReference Include="PipServices3.Rpc" Version="3.4.1" />
    <PackageReference Include="PipServices3.Expressions" Version="3.1.0" />
    <PackageReference Include="PipServices3.Swagger" Version="3.0.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Interface\Interface.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Compile Remove="src\Interface\Data\Version1\BeaconTypeV1.cs" />
    <Compile Remove="test\Service.Test\Interface\Data\Version1\TestModel.cs" />
    <Compile Remove="Persistence\BeaconsMongoDbSchema.cs" />
  </ItemGroup>
</Project>

Add a go.mod file with the following lines to the root of the project's folder:

/go.mod

module github.com/pip-services-samples/service-beacons-gox

go 1.18

require (
	github.com/pip-services3-gox/pip-services3-commons-gox v1.0.6
	github.com/pip-services3-gox/pip-services3-components-gox v1.0.6
	github.com/pip-services3-gox/pip-services3-container-gox v1.0.6
	github.com/pip-services3-gox/pip-services3-data-gox v1.0.6
	github.com/pip-services3-gox/pip-services3-mongodb-gox v0.0.0-20221006150923-97f131215710
	github.com/pip-services3-gox/pip-services3-postgres-gox v1.0.3
	github.com/pip-services3-gox/pip-services3-rpc-gox v1.0.2
	github.com/stretchr/testify v1.8.0
	go.mongodb.org/mongo-driver v1.10.3
)

require (
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/felixge/httpsnoop v1.0.1 // indirect
	github.com/golang/snappy v0.0.1 // indirect
	github.com/google/uuid v1.3.0 // indirect
	github.com/gorilla/handlers v1.5.1 // indirect
	github.com/gorilla/mux v1.8.0 // indirect
	github.com/jackc/chunkreader/v2 v2.0.1 // indirect
	github.com/jackc/pgconn v1.12.1 // indirect
	github.com/jackc/pgio v1.0.0 // indirect
	github.com/jackc/pgpassfile v1.0.0 // indirect
	github.com/jackc/pgproto3/v2 v2.3.0 // indirect
	github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
	github.com/jackc/pgtype v1.11.0 // indirect
	github.com/jackc/pgx/v4 v4.16.1 // indirect
	github.com/jackc/puddle v1.2.1 // indirect
	github.com/jinzhu/copier v0.3.5 // indirect
	github.com/klauspost/compress v1.13.6 // indirect
	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
	github.com/pip-services3-gox/pip-services3-expressions-gox v1.0.1 // indirect
	github.com/pkg/errors v0.9.1 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
	github.com/xdg-go/scram v1.1.1 // indirect
	github.com/xdg-go/stringprep v1.0.3 // indirect
	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
	golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
	golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
	golang.org/x/text v0.3.7 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)
Add a package.json file with the following lines to the root of the project's folder:

/package.yaml

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  pip_services3_commons: ">=1.0.5 <2.0.0"
  pip_services3_components: ">=1.0.2 <2.0.0"
  pip_services3_data: ">=1.0.0 <2.0.0"
  pip_services3_mongodb: ">=1.0.2 <2.0.0"
  pip_services3_rpc: ">=1.0.2 <2.0.0"
  pip_services3_container: ">=1.0.3 <2.0.0"
  http: "^0.12.0"
  angel_framework: ^2.1.1
  fixnum: ^0.10.11

dev_dependencies:
  test: '>=1.14.2 <2.0.0'

Add a requirements.txt file with the following lines to the root of the project’s folder:

/requirements.txt

iso8601
PyYAML
pystache
pytest
pytz
bottle
pybars3
requests
netifaces==0.10.9
 
pip_services3_commons
pip_services3_expressions
pip_services3_components
pip_services3_container
pip_services3_data
pip_services3_mongodb
pip_services3_rpc
pip_services3_swagger
Not available

To install all necessary dependencies, run the following command from a terminal at the root of the project’s directory:

npm install
dotnet restore
go mod download
pub get
pip install -r requirements.txt
Not available

Now that we’ve got the project all set up, we can move on to Step 3. Data model development.

Step 3. Data model development.