DeFlock Documentation

repository·master·Indexed 19 days ago

https://github.com/foggedlens/deflock

A crowdsourced tool for locating and reporting Automated License Plate Readers (ALPRs). The project includes a Fastify-based API (deflock-api v1.0.0) for geocoding and sponsor data, a Vue-based web application, serverless microservices for ALPR counts and map clustering, and a Directus CMS integration with Cloudflare cache purging and S3 backup scripts.

Tokens
7.7K
Snippets
36
Records
49
Agent score
72%

What's inside DeFlock

  1. Overview of the Purge Cloudflare Cache Directus Extension

    master
    The purge-cf-cache extension is a Directus extension designed to automate cache invalidation. It monitors content updates within Directus and automatically triggers a request to the Cloudflare API to purge the cache for the URLs affected by those updates. This ensures that users see the most recent content immediately after it is modified in the CMS.
  2. Overview of DeFlock Serverless microservices

    master

    DeFlock includes a set of serverless microservices designed to collect and process auxiliary data. These services are responsible for calculating aggregate metrics used throughout the platform, specifically:

    • Total ALPR counts: Aggregating Automatic License Plate Recognition data.
    • Map clusters: Processing data required for spatial clustering on maps.
  3. What is ALPR Counts?

    master

    ALPR Counts is a serverless process that calculates the total number of Automatic License Plate Recognition (ALPR) reports in the OpenStreetMap (OSM) database on an hourly basis.

    It works by:

    1. Querying the OSM Overpass API to retrieve counts for all ALPRs globally and specifically for those within the United States.
    2. Storing the resulting counts in a JSON file within an S3 bucket.
  4. How ALPR Clusters are generated

    master

    ALPR Clusters are the visual blobs shown on the map when the view is zoomed out. The system generates these clusters daily by:

    1. Querying all ALPR locations using the OSM Overpass API.
    2. Applying a clustering algorithm to the retrieved data.
    3. Storing the resulting clustered data in a JSON file within an S3 bucket.
  5. Schedule Directus backups with cron

    master

    To automate your backups, add the script to your system's crontab. To run the backup every day at 2:00 AM and log the output to a file, use the following cron expression:

    0 2 * * * /path/to/directus-backup.sh >> /var/log/directus-backup.log 2>&1

    0 2 * * * /path/to/directus-backup.sh >> /var/log/directus-backup.log 2>&1
  6. Build the deflock application for production

    master

    To perform type-checking, compilation, and minification for a production deployment, use the build script. This command uses vue-tsc for type checking to ensure .vue file types are correctly validated before bundling.

    npm run build
  7. Set up the development environment for deflock

    master

    To start developing the deflock web application, install the project dependencies using npm. For the best development experience, use VSCode with the Volar extension and ensure that the Vetur extension is disabled. This setup ensures that the TypeScript language service correctly handles type information for .vue files via vue-tsc.

    npm install