The .NET solution consists of 7 projects:
- The
Modelsproject defines all the model classes required by RideShare - The
Sharedproject contains all the services which are used by the functions to provide different functionality - The
Seederproject contains some integration tests to pump trips through the solution - The
DriversFunction App project contains theDriversAPIs - The
TripsFunction App project contains theTripsAPIs - The
PassengersFunction App project contains thePassengersAPIs - The
OrchestratorsFunction App project contains theOrchestrators
The following are some notes about the source code:
- The
Factorypattern is used to create static singleton instances via theServiceFactory:
private static ISettingService _settingService = null;
public static ISettingService GetSettingService()
{
if (_settingService == null)
_settingService = new SettingService();
return _settingService;
}- The
ISettingServiceservice implementation is used to read settings from environment variables:
var seconds = _settingService.GetTripMonitorIntervalInSeconds();
var maxIterations = _settingService..GetTripMonitorMaxIterations();- The
ILoggerServiceservice implementation sends traces, exceptions, custom events and metrics to theApplication Insightsresource associated with the Function App:
// Send a trace
_loggerService.Log($"{LOG_TAG} - TripCreated - Error: {error}");
// Send an event telemetry
_loggerService.Log("Trip created", new Dictionary<string, string>
{
{"Code", trip.Code },
{"Passenger", $"{trip.Passenger.FirstName} {trip.Passenger.LastName}" },
{"Destination", $"{trip.Destination.Latitude} - {trip.Destination.Longitude}" },
{"Mode", $"{trip.Type}" }
});
// Send a metric telemetry
_loggerService.Log("Active trips", activeTrips);IPersistenceServicehas two implementations:CosmosPersistenceServiceandSqlPersistenceService. The Azure Cosmos DB implementation is complete and used in the APIs while the SQL implementation is partially implemented and only used in theTripExternalizations2PowerBIhandler to persist trip summaries to SQL.- The
CosmosPersistenceServiceassigns Cosmos DB IDs manually, which is a combination of thecollection typeand some identifier. Cosmos DB'sReadDocumentAsyncretrieves really fast if anidis provided. - The
IsPersistDirectlysetting is used mainly by the orchestrators to determine whether to communicate with the storage directly (via the persistence layer) or whether to use the exposed APIs to retrieve and update. In the reference implementation, theIsPersistDirectlysetting is set to true.
The nodejs folder contains the Archiver Function App with the following folder structure:
- The serverless-microservices-functionapp-triparchiver folder contains the Archiver Function App.
- The EVGH_TripExternalizations2CosmosDB folder contains the function to send data to the Archiver Collection in Azure Cosmos DB:
- function.json: Defines the function's in (eventGridTrigger) and out (documentDB) bindings.
- index.js: The function code that defines the data to be sent.
- .gitignore: Local Git ignore file.
- host.json: This file can include global configuration settings that affect all functions for this function app.
- local.settings.json: This file can include configuration settings needed when running the functions locally.
The web folder contains the Vue.js-based SPA website with the following folder structure:
- The public folder contains the
index.htmlpage, as well asjsfolder that contains important settings for the SPA. Thesettings.sample.jsfile is included and shows the expected settings for reference. Thesettings.jsfile is excluded to prevent sensitive data from leaking. This file is added via the Web App's debug console (Kudu) after deploying the website. - The src folder contains the bulk of the files:
- api: these files use the http helper (
utils/http.js) to execute REST calls against the API Management endpoints. - assets: site images.
- components: Vue.js components, including a SignalR component that contains the client-side functions called by the SignalR Service.
- store: Vuex store, which represents the state management components for the SPA site.
- utils: utilities for authentication (wraps the Microsoft Authentication Library (MSAL)) and HTTP (wraps the Axios library)
- views: Vue.js files for each of the SPA "pages".
- api: these files use the http helper (


