https://github.com/larsbergqvist/police-events
A .NET 8 + Angular solution for working with police event data from the Open API of the Swedish Police
https://github.com/larsbergqvist/police-events
angular azure azure-functions blazor-webassembly geojson mongodb net8 openapi opendata openlayers openstreetmap police-reports
Last synced: 7 months ago
JSON representation
A .NET 8 + Angular solution for working with police event data from the Open API of the Swedish Police
- Host: GitHub
- URL: https://github.com/larsbergqvist/police-events
- Owner: LarsBergqvist
- License: mit
- Created: 2022-05-28T19:48:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-22T13:04:19.000Z (over 1 year ago)
- Last Synced: 2024-06-22T21:24:39.142Z (over 1 year ago)
- Topics: angular, azure, azure-functions, blazor-webassembly, geojson, mongodb, net8, openapi, opendata, openlayers, openstreetmap, police-reports
- Language: C#
- Homepage:
- Size: 5.82 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# police-events
[](https://larsbq.visualstudio.com/PoliceEvents/_build/latest?definitionId=16&branchName=main)
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# Architecture

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.
# Pre-reqs
* 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# Setup and start the CollectorService
```
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.# Setup and start the backend .NET Core API and the Blazor App
```
cd police-events/Api
dotnet run```
## Access the swagger endpoint for the Api
https://localhost:5001/swagger
## Access the Blazor application
https://localhost:5001# Setup and start the Angular application
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 startSSLhttps://localhost:4300/
```
# Screenshots


