This repository consists of:
- a CollectorService that fetches the latest event data from the Open Api of the Swedish Police every 10 minutes and stores it in a MongoDB database. When hosted in Azure, the service is an Azure function with a timer trigger
- a .NET 8 REST API that dispatches queries to the to the MongoDB database
- a mobile-friendly Angular front-end app that uses the REST API for searching and displaying nearby events (based on geolocation). The Angular application has a map view with overlays for Swedish counties and municipalities
- a Blazor web-assembly application for searching among old police events. This app is hosted by the api-service
The incoming requests to the Api triggers Queries that are dispatched to handlers in the Core assembly. The business logic in Core operates against the repository interfaces for fetching data. The CollectorService (and the Azure function) dispatches Commands to the Core assembly that in turn makes updates to the database via the repository interfaces.
- Install a MongoDB instance and create a database called 'Police' with a collection called 'police_events'
- Create a 2dsphere index on the Geo field for the collection
- Modify the appsettings.json files in the CollectorService- and API-projects with connection strings for the database
cd police-events/CollectorService
dotnet run
You can also use the Azure functions-project if you want to trigger the data collection from an Azure function instead.
cd police-events/Api
dotnet run
https://localhost:5001/swagger
https is required for using geolocation from browser
A self-signed certificate is provided in the repo but you can replace it with your own
cd police-events/App
yarn install
yarn startSSL
https://localhost:4300/