Django 5 & DRF Apple Find My ESP32 & MicroPython Django-Q2 Workers MapLibre GL Fernet Encryption

Building a Find My Network Simple Manager for ESP32 DIY Tags

A walk through what this project actually does — from BLE radio advertisements on a coin-cell board to a unified Django desk you can sit at, sign into Apple, and watch a real pin appear on an interactive dark vector map.

Félix Pupo Pérez Félix Pupo Pérez
September 10, 2026
22 min read
Embedded & IoT Systems
fpupoperez/apple_find_my_network_simple_manager Open Source

Complete open-source repository for the self-hosted Apple Find My DIY Tag Manager. Includes multi-tenant user accounts, encrypted Apple credentials at rest, NIST P-224 key generation, multi-format firmware exporters (ESP-IDF, Arduino IDE, MicroPython), background 2FA session handling with FindMy.py, headless DRF API, and MapLibre GL tracking.

Python 3.10+ Django 5.0 Django-Q2 Cryptography (Fernet) MapLibre GL JS
View on GitHub

If you have ever wanted an AirTag that you assembled yourself, you already know the gap. Apple’s Find My network is astonishingly generous: hundreds of millions of iPhones, iPads, and MacBooks quietly relay anonymous Bluetooth Low Energy beacons into Apple's cloud. The hard part is everything around the physical beacon — generating curve keypairs, baking them into firmware Apple's network will actually recognize, logging into an Apple ID that can download encrypted reports, handling 2FA challenges, decrypting payloads, and serving a polished interface that does not feel like a tangle of half-broken Python terminal scripts.

This project is that missing workbench. It is a full-featured Django 5 service that owns the entire lifecycle for custom ESP32 Find My locator tags: multi-tenant user accounts, Apple IDs, device keys, multi-format firmware exports, asynchronous background login and location fetching via FindMy.py, an authenticated REST API, and a real-time vector map.

Workshop Operational Notice

Development defaults (ALLOWED_HOSTS = ["*"], console email, and a shared local SECRET_KEY) are meant for a trusted local network only. The SQLite database stores Apple credentials and private device keys. Treat this as a workshop desk tool, not an unshielded public website.

Dark-mode dashboard and MapLibre GL tracking interface of the Apple Find My Simple Manager
Live locator beacon telemetry visualized over OpenFreeMap dark vector tiles with MapLibre GL JS

01. The problem, in human terms

Official Apple AirTags are masterclasses in industrial miniaturization and frictionless UX. Homemade tags, on the other hand, originate from academic and open-source reverse engineering: the seminal OpenHaystack research at TU Darmstadt demonstrated that an inexpensive Bluetooth radio ($3 ESP32 board or nRF51/nRF52 chip) could impersonate an offline accessory simply by broadcasting the appropriate advertisement payload and matching random static MAC address. Later community initiatives — most notably macless-haystack — liberated the report-fetching pipeline from requiring physical macOS hardware by containerizing the Anisette authentication handshake on Linux.

Yet when working on the bench, the manual cognitive overhead remains daunting:

  • NIST P-224 Keypair Synthesis: Generating elliptic curve points, extracting the raw 28-byte public x-coordinate, and calculating SHA-256 advertisement hashes.
  • Firmware Tailoring: Manually splicing raw hex bytes into C/C++ or MicroPython source code, configuring advertising intervals, and tweaking power-saving deep sleep intervals.
  • Key Tracking: Remembering which .keys file belongs to which soldered coin-cell board scattered across your desk.
  • Apple 2FA Challenges: Dealing with SMS or trusted-device push notifications when Apple invalidates your authentication cookies.
  • Coordinate Plotting: Copying raw latitude, longitude, and horizontal accuracy floats from JSON logs into external mapping tools.

This manager acts as the filing cabinet and automated workbench. You register a user, register the Apple account you dedicate to Find My, mint or import device keypairs, export ready-to-flash firmware, complete Apple 2FA directly inside the browser, and asynchronously pull location coordinates straight into a local database for instant map visualization.

02. What the project does

In a single sentence: it manages homemade Find My tags and the Apple accounts used to decrypt their reports.

Here is the architectural feature breakdown:

  • Multi-Tenant User Accounts: Independent registration, mandatory email confirmation, password reset, and optional multi-factor authentication (TOTP authenticator app and recovery codes). Two separate users can safely utilize the same Apple ID credentials without data overlap.
  • Credential Vault: Stores Apple IDs (username/password) with cryptographic Fernet encryption at rest derived from Django’s SECRET_KEY.
  • NIST P-224 Key Generation: Generates the 28-byte advertisement key the tag broadcasts and the matching 28-byte private key required to decrypt Apple’s reports. Also imports existing keys from generate_keys.py.
  • Multi-Format Firmware Generators: Emits customized MicroPython (main.py), native ESP-IDF C (main.c), and Arduino IDE C++ (tag.ino) source code on demand.
  • Companion Interoperability: Exports raw .keys format files and config.ini files so you can run the manager alongside an existing macless-haystack Docker container.
  • Non-Blocking Apple 2FA & Fetch: Coordinates with FindMy.py through asynchronous django-q2 worker processes so that long network calls or interactive 2FA challenges never block web HTTP worker threads.
  • Vector Map Visualization: Renders device location history and latest telemetry markers using MapLibre GL JS against OpenFreeMap dark vector tiles without third-party API keys or subscription fees.
Find My Manager Home Dashboard
Figure 1: Manager Dashboard displaying registered Apple accounts, device counts, fetch statuses, and global trigger controls

03. How Find My DIY actually works

Apple’s offline finding network functions as a privacy-preserving gossip mesh. An offline beacon does not have cellular connectivity, GPS receivers, or Wi-Fi. It simply emits a periodic Bluetooth Low Energy (BLE) advertisement packet that masquerades as an Apple accessory.

When a passing iPhone or iPad detects this advertisement, the device records its own current GPS coordinates, encrypts those coordinates against the public key broadcast by the beacon using Elliptic Curve Cryptography (ECC), and uploads the encrypted report blob to Apple’s cloud servers. Apple cannot decrypt this report because Apple never possesses the private key. Later, the owner — who possesses the matching private key — authenticates with Apple, queries for reports matching the hashed advertisement key, downloads the ciphertext blobs, and decrypts their own coordinates locally.

Cryptographic Artifact Size Where It Lives Operational Purpose
Advertisement Key 28 bytes Embedded on the ESP32 Tag NIST P-224 public curve x-coordinate broadcasted over the air.
Private Key 28 bytes Manager Database / Companion The secret key used to decrypt location blobs. Never placed on the tag.
Hashed Advertisement Key 32 bytes Apple Cloud Query Parameter SHA-256 hash of the 28-byte advertisement key, used to index reports on Apple servers.
Random Static MAC 6 bytes BLE Controller Hardware Address The first 6 bytes of the advertisement key, required for Apple's network to stitch the full key.
Find My Telemetry Sequence & Decryption Flow
  ┌───────────┐         ┌──────────────┐         ┌─────────────┐         ┌──────────────┐
  │ ESP32 Tag │         │ Nearby Apple │         │ Apple Cloud │         │  Find My     │
  │ (Beacon)  │         │ Device (iOS) │         │   Servers   │         │ Manager Desk │
  └─────┬─────┘         └──────┬───────┘         └──────┬──────┘         └──────┬───────┘
        │                      │                        │                       │
        │ 1. BLE Adv (28B Key) │                        │                       │
        ├─────────────────────>│                        │                       │
        │                      │ 2. Encrypt GPS with    │                       │
        │                      │    Beacon Public Key   │                       │
        │                      ├───────────────────────┐│                       │
        │                      │<──────────────────────┘│                       │
        │                      │                        │                       │
        │                      │ 3. Upload Ciphertext   │                       │
        │                      ├───────────────────────>│                       │
        │                      │                        │                       │
        │                      │                        │ 4. Authenticate and   │
        │                      │                        │    Fetch by SHA256    │
        │                      │                        │──────────────────────>┤
        │                      │                        │                       │
        │                      │                        │ 5. Return Encrypted   │
        │                      │                        │    Location Payloads  │
        │                      │                        ├<──────────────────────│
        │                      │                        │                       │
        │                      │                        │    6. Decrypt locally │
        │                      │                        │       with P-224      │
        │                      │                        │       Private Key     │
        │                      │                        │    ┌──────────────────┤
        │                      │                        │    │ Lat, Lon, Acc    │
        │                      │                        │    │ SQLite + Map     │
        │                      │                        │    └─────────────────>│

A critical realization: keys are not cryptographically linked to your Apple ID. You can broadcast advertisements using one keypair, and query Apple using any valid Apple account. Apple stores the encrypted payload indexed by the SHA-256 hash of the public key. This decoupling is why the manager maintains both entities independently: Apple credentials to query the cloud, and tag private keys to decrypt the results.

04. System architecture & request routing

The manager is engineered as a lean, unified Django 5 web service designed for zero-headache local deployment. It eliminates external broker dependencies like Redis by leveraging SQLite alongside Django-Q2’s native database broker.

Application Subsystems & Data Pipeline
  Browser UI (/login, /accounts, /devices, /map, /profile)
       │
       │  Django Session Cookie

  ┌─────────────────────────────────────────────────────────────────┐
  │  config/       Django Project (Settings, URLs, Middleware)      │
  │  manager/      HTML UI, ORM Models, Firmware Exporters          │
  │  api/          DRF ViewSets under /api/v1/ (Bearer Token)       │
  │  allauth       Browser /account/* + Headless /api/app/v1/       │
  │  django-q2     Background Task Queue (Apple Auth and Fetch)     │
  └───────────────┬─────────────────────────────┬───────────────────┘
                  │                             │
                  +                             +
           SQLite (db.sqlite3)          .findmy/ Session JSON
           Users, Accounts, Devices,    Anisette Libs + Cached
           Locations, Task Results      Apple Login Cookies
                  │
                  +
           FindMy.py  ────────── Apple Find My Network

Global request routing is governed by custom middleware ManagerLoginRequiredMiddleware. To prevent unauthorized inspection, every URL path requires an authenticated session by default, cleanly carving out exemptions for public authentication routes, the headless JSON API, administrative interfaces, and static assets.

URL Prefix Subsystem Audience Authentication Mechanism Purpose
/ Manager Web UI Django Session Cookie Dashboard, accounts, devices, firmware export, and MapLibre tracking.
/account/ Allauth Browser Pages Public / Session User registration, mandatory email verification, password reset, and MFA setup.
/api/app/v1/ Allauth Headless API Flow Session Token Native mobile/headless authentication and credentials exchange.
/api/v1/ DRF REST API Session or Bearer <token> Programmatic CRUD on accounts, devices, firmware downloads, and location history.
/api/auth/ DRF Browsable API Django Session Interactive API exploration and testing through standard web browser.
/admin/ Django Admin Django Superuser Session Low-level database administration and Django-Q2 scheduled task inspection.

05. A day in the workshop: From soldering to map pin

To see how the components align, imagine assembling a coin-cell powered ESP32-C3 or ESP32-S3 locator tag on your bench:

  1. Register the Manager User: Navigate to /account/signup/. Enter your username, email, and password. In local development, the activation email is printed to your active terminal console. Click the verification link to immediately establish a session.
  2. Configure Your Apple ID: Head to Apple Accounts → Add Account. Enter your dedicated Apple ID email and password. The password is immediately encrypted using Fernet before being written to SQLite.
  3. Perform Apple Cloud Sign-In: Click Sign in to Apple on the account page. This enqueues a background task in django-q2. If Apple triggers two-factor authentication, the UI smoothly transitions to a dedicated 2FA challenge page where you submit your trusted-device or SMS code. The generated session is securely cached in .findmy/account_<uuid>.json.
  4. Generate a Device Keypair: Go to Devices → Add Device. The manager generates a cryptographic NIST P-224 keypair. Set your desired radio transmission timing (e.g., advertise for 10 seconds, rest for 5 minutes).
  5. Export Tailored Firmware: Download the pre-configured source code:
    • ESP-IDF: Native C source (main.c) setting the required random static MAC address via Bluedroid.
    • Arduino IDE: Standard C++ sketch (tag.ino) compatible with the ESP32 Arduino Core.
    • MicroPython: Concise Python loop (main.py) for rapid bench testing.
  6. Flash and Deploy: Flash your ESP32 board over USB, power it with a 3V CR2032 battery or LiPo cell, and place it in your backpack or vehicle.
  7. Fetch & Map Coordinates: From the dashboard, trigger Fetch Locations. The worker uses FindMy.py to request report blobs from Apple, decrypts them with the device's private key, stores the location records, and plots markers on the dark MapLibre interface.
Registered Apple Accounts List
Figure 2: Apple accounts management table
Add Apple Account Modal
Figure 3: Encrypted Apple ID credential entry

06. Data modeling & encryption at rest

Domain entities are modeled with strict multi-tenancy. Every core model belongs to a Django User, and tables employ 128-bit UUID primary keys to eliminate enumeration attacks across the API.

Relational Entity Relationship Model
  ┌──────────────┐       1      * ┌────────────────────┐
  │  auth_user   │────────────────│    AppleAccount    │
  │ (Django User)│                │ (Encrypted Passwd) │
  └──────────────┘                └─────────┬──────────┘
         │                                  │ 1
         │ 1                                │
         │                                  │ *
         │ *                      ┌─────────┴──────────┐
         └────────────────────────│       Device       │
                                  │ (Encrypted Keys)   │
                                  └─────────┬──────────┘
                                            │ 1
                                            │
                                            │ *
                                  ┌─────────┴──────────┐
                                  │   DeviceLocation   │
                                  │ (Lat, Lon, Acc)    │
                                  └────────────────────┘

The models implement custom querysets with a mandatory .for_user(user) scope. Views, API serializers, and background tasks strictly execute queries through this method, preventing accidental data leaks.

Cryptographic Field Level Encryption

In manager/encryption.py, we implement a custom Django field: EncryptedCharField. The encryption pipeline derives a 32-byte key from Django’s SECRET_KEY via SHA-256 and base64url-encoding, feeding it into Fernet authenticated symmetric encryption (AES-128-CBC + HMAC-SHA256).

manager/encryption.py — Fernet Symmetric Field Encryption
import base64
import hashlib
from cryptography.fernet import Fernet
from django.conf import settings
from django.db import models

def get_fernet() -> Fernet:
    """Derive a deterministic Fernet key from Django SECRET_KEY."""
    digest = hashlib.sha256(settings.SECRET_KEY.encode()).digest()
    key = base64.urlsafe_b64encode(digest)
    return Fernet(key)

class EncryptedCharField(models.CharField):
    """Transparently encrypts string on write, decrypts on read."""
    description = "Fernet-encrypted CharField"

    def from_db_value(self, value, expression, connection):
        if value is None or not value.startswith("crypt:"):
            return value
        token = value[6:].encode()
        return get_fernet().decrypt(token).decode()

    def get_prep_value(self, value):
        if value is None or value == "":
            return value
        if value.startswith("crypt:"):
            return value
        token = get_fernet().encrypt(value.encode()).decode()
        return f"crypt:{token}"

Stored SQLite data contains only opaque ciphertext prefixed with crypt:gAAAAA.... Even if the raw database file is inspected, Apple passwords and private device keys cannot be retrieved without the server's unique SECRET_KEY.

07. User access control & headless authentication

Authentication is anchored by django-allauth, providing a dual-mode surface: standard session-backed browser views under /account/ and headless JSON endpoints under /api/app/v1/.

  • Mandatory Email Confirmation: ACCOUNT_EMAIL_VERIFICATION = "mandatory" ensures that accounts cannot operate or fetch location data until their email address is validated.
  • Multi-Factor Authentication (MFA): Includes optional RFC 6238 TOTP authenticator app support and emergency recovery codes, managed through /profile/.
  • Headless Bearer Token Strategy: For mobile apps or automated CLI scripts, logging in via /api/app/v1/auth/login returns a standard Django REST Framework token wrapped in a Bearer token response.
User Login Screen
Figure 4: Dark-mode authentication login page
User Profile and MFA Settings
Figure 5: User profile, email manager & MFA configuration

08. Firmware: Three ways to flash a tag

The manager does not run a C compiler in the cloud. Instead, it acts as a code generator, dynamically embedding your 28-byte advertisement key, custom device name, and duty-cycle timing directly into ready-to-compile source files.

Firmware Export Runtime / Stack Sets Random Static MAC? Apple Network Recognition Recommended Use Case
ESP-IDF (main.c) Native C / Bluedroid API Yes (Hardware Level) 100% Reliable Production trackers, vehicle tags, coin-cell battery optimization.
Arduino (tag.ino) Arduino Core for ESP32 Yes (via IDF Call) 100% Reliable Rapid iteration inside the Arduino IDE or PlatformIO.
MicroPython (main.py) MicroPython 1.20+ No (Stack Limitation) Weak / Unstitched Benchtop RF validation, laboratory testing, educational tinkering.
Create New Device Form
Figure 6: Device creation modal with automated NIST P-224 key generation
Arduino IDE Sample Code Export
Figure 7: Live Arduino IDE C++ firmware exporter with embedded key bytes

Why the Random Static MAC Address is Mandatory

In our companion article on Building an Apple Find My Network Detector, we detailed the 31-byte GAP advertisement payload constraint. Apple encodes the full 28-byte P-224 public key by splitting it across two layers:

  • The First 6 Bytes: Set as the BLE radio's Random Static Device Address (MAC address).
  • The Remaining 22 Bytes: Placed inside the Manufacturer Data payload (Type 0x12, Apple ID 0x004C).

Passing Apple devices capture both the MAC address and the payload, reassembling the complete 28-byte key before encrypting GPS coordinates. Because MicroPython’s standard Bluetooth GAP API does not expose custom random static MAC address configuration on ESP32, native C (ESP-IDF or Arduino) is mandatory for genuine, dependable location reporting.

Arduino ESP32 (tag.ino) — Setting Random Static MAC & Apple Payload
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <esp_bt_main.h>
#include <esp_gap_ble_api.h>

// The 28-byte public x-coordinate generated by the Django Manager
static const uint8_t public_key[28] = {
  0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f, /* bytes 0-5: assigned to MAC address */
  0x70, 0x81, 0x92, 0xa3, 0xb4, 0xc5, 0xd6, 0xe7,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00  /* bytes 6-27: embedded in payload, (hypothetical values here) */
};

void setup() {
  BLEDevice::init("");

  // Step 1: Set Random Static Address to public_key[0:6] with top bits set
  esp_bd_addr_t rnd_addr;
  memcpy(rnd_addr, public_key, 6);
  rnd_addr[0] |= 0b11000000; // Static random address standard prefix
  esp_ble_gap_set_rand_addr(rnd_addr);

  // Step 2: Construct 31-byte OpenHaystack Apple payload
  uint8_t payload[31];
  payload[0] = 0x1E;                 // Length (30 bytes to follow)
  payload[1] = 0xFF;                 // Manufacturer Specific Data
  payload[2] = 0x4C; payload[3] = 0x00; // Apple Inc. Company ID (0x004C)
  payload[4] = 0x12;                 // Find My Offline Finding Subtype
  payload[5] = 0x19;                 // Subtype length (25 bytes)
  payload[6] = 0x00;                 // Battery status / key counter byte
  memcpy(&payload[7], &public_key[6], 22); // 22 bytes remaining public key
  payload[29] = public_key[0] >> 6;  // First 2 bits of key byte 0
  payload[30] = 0x00;                // Reserved hint byte

  esp_ble_gap_config_adv_data_raw(payload, sizeof(payload));

  // Step 3: Broadcast BLE advertisement
  esp_ble_adv_params_t adv_params = {
    .adv_int_min = 0x0640, // ~1000ms advertisement interval
    .adv_int_max = 0x0640,
    .adv_type = ADV_TYPE_NONCONN_IND,
    .own_addr_type = BLE_ADDR_TYPE_RANDOM,
    .channel_map = ADV_CHNL_ALL,
    .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
  };
  esp_ble_gap_start_advertising(&adv_params);
}

void loop() {
  delay(10000); // Broadcast for duration, then deep sleep
}

09. Talking to Apple without blocking the UI

Interacting with Apple ́s Find My infrastructure involves multiple cryptographic handshakes: computing Anisette hardware-bound headers, executing SRP (Secure Remote Password) protocol handshakes, waiting for multi-factor push notifications, and querying high-latency cloud endpoints. Executing these operations inside an HTTP request/response cycle would inevitably lead to gateway timeouts and frozen user interfaces.

Asynchronous Task Dispatch with Django-Q2
  Web Browser UI          Django Web Thread             Django-Q2 Worker
        │                         │                             │
        │ Click "Sign in"         │                             │
        ├────────────────────────>│                             │
        │                         │ async_task("login_findmy")  │
        │                         ├────────────────────────────>│
        │ 202 Accepted            │                             │ (Executes in
        │<────────────────────────┤                             │  background)
        │                         │                             │
        │ Polls Status            │                             │ Talks to Apple
        ├────────────────────────>│ Read Task Status            │ via FindMy.py
        │                         ├────────────────────────────>│
        │ {status: "needs_2fa"}   │                             │
        │<────────────────────────┤                             │ Needs 2FA code
        │                         │                             ├──────────────┐
        │ Renders 2FA Code Input  │                             │ Wait for UI  │
        │ (Submits SMS/Push code) │                             │ code input   │
        ├────────────────────────>│ Save 2FA State              │              │
        │                         ├────────────────────────────>│<─────────────┘
        │                         │                             │ Writes session
        │                         │                             │ account_uuid.json

The manager delegates all Apple communication to a separate process: python manage.py qcluster. Using FindMy.py, workers handle Anisette generation (either locally via embedded binaries or remotely via FINDMY_ANISETTE_URL), cache session state to .findmy/account_<uuid>.json, and gracefully handle rate-limiting (treating HTTP 503 responses as temporary throttling backoffs).

Apple Account Details and 2FA Verification
Figure 8: Apple Account view displaying live authentication status, session validity, and action buttons

10. Device telemetry, historical logs & live mapping

Once Apple returns encrypted location reports, the worker uses the tag’s private key to decrypt the telemetry fields:

  • Timestamp: UTC time when the nearby iOS device reported the beacon.
  • Latitude & Longitude: High-precision coordinates of the reporting device.
  • Horizontal Accuracy: Reported in meters (typically 5m to 35m in urban environments).
  • Status / Confidence: Battery indicator flag and reception signal quality.
Devices Overview Table
Figure 9: Registered devices table with advertisement keys and status badges
Device Details View
Figure 10: Device management panel with key inspection and export triggers

Every location report is saved into the DeviceLocation table, protected by a unique database constraint on (device, timestamp) to prevent duplicate records.

Device Location History Table
Figure 11: Granular location history log with confidence and accuracy telemetry

The frontend map interface utilizes MapLibre GL JS paired with OpenFreeMap dark vector tiles (https://tiles.openfreemap.org/styles/dark). This gives full WebGL vector map rendering, interactive zoom/pan controls, and customizable popup markers without transmitting user telemetry to commercial map providers.

Live Map View with Device Pin
Figure 12: MapLibre GL dark vector map rendering active beacon coordinates
Interactive Map Waypoint Detail Popup
Figure 13: Selected waypoint telemetry popup with accuracy radius and timestamp

11. REST API reference & Django admin

In addition to the Bootstrap web UI, the manager exposes a complete REST API under /api/v1/ built with Django REST Framework (DRF). Endpoints support pagination, sorting, and declarative filtering via django-filter.

Method Path Auth Description
GET / POST /api/v1/accounts/ Bearer / Session List or register Apple accounts for current user.
GET /api/v1/accounts/{id}/config.ini/ Bearer / Session Export companion config.ini for macless-haystack.
POST /api/v1/accounts/{id}/fetch/ Bearer / Session Queue background location fetch for specific account.
GET / POST /api/v1/devices/ Bearer / Session List or create new Find My tag devices.
GET /api/v1/devices/{id}/keys/ Bearer / Session Retrieve public advertisement and private keys in hex.
GET /api/v1/devices/{id}/export/firmware/ Bearer / Session Download tailored native ESP-IDF C source file (main.c).
GET /api/v1/devices/{id}/export/arduino/ Bearer / Session Download tailored Arduino IDE sketch (tag.ino).
GET /api/v1/devices/{id}/export/micropython/ Bearer / Session Download tailored MicroPython loop (main.py).
GET /api/v1/locations/ Bearer / Session Query stored location reports with timestamp and accuracy filters.
GET /api/v1/map/ Bearer / Session Retrieve latest GeoJSON marker points for all active tags.
Django REST Framework Browsable API
Figure 14: DRF browsable API root interface
Django Admin Dashboard
Figure 15: Django Admin panel managing tasks and models

12. Complete technology stack breakdown

Every library and tool in this architecture serves an explicit, non-redundant engineering role:

  • Django 5.0: Backbone framework providing ORM models, migration management, administrative tooling, and session authentication.
  • Django REST Framework: Serializers, viewsets, and bearer token authentication for external headless automation.
  • django-allauth: Account registration, mandatory email verification, password recovery, and optional TOTP MFA.
  • django-q2: Asynchronous multiprocessing worker cluster using SQLite ORM broker (no Redis or RabbitMQ required).
  • cryptography (Fernet): High-level authenticated symmetric encryption (AES-128-CBC + HMAC) protecting credentials at rest.
  • FindMy.py: Upstream Python client speaking Anisette protocol, executing Apple 2FA handshakes, and decrypting location reports.
  • MapLibre GL JS: GPU-accelerated client-side vector map renderer, freeing the service from commercial map tokens.
  • Bootstrap 5 & Icons: Vendored styling library delivering a responsive, low-latency dark theme across desktop and mobile browsers.

13. Security considerations & operational guardrails

Understanding the security posture of this project is essential before operating it on anything beyond an isolated workbench network:

  • Safe Unlocked on the Bench: The device detail pages display private keys in plaintext so you can copy/paste them into terminal debuggers and IDEs. This is an intentional feature on a private workbench, but hazardous if exposed publicly.
  • Session Files in Plaintext: Files created in .findmy/account_<uuid>.json store reusable Apple authentication cookies. Ensure directory permissions (chmod 700 .findmy) prevent local unauthorized reading.
  • Fernet Key Rotation: If you rotate Django’s SECRET_KEY, all previously encrypted Apple passwords and private keys become unrecoverable. Only rotate keys when prepared to re-input credentials.
  • LAN vs. Internet Deployment: To run this service outside a private LAN, you must place it behind an HTTPS reverse proxy (Caddy or Nginx), bind ALLOWED_HOSTS to a real domain, configure a production SMTP mailer, and disable DEBUG mode.

14. Running the project & CLI utilities

Getting the stack running requires setting up the virtual environment, copying the settings template, and launching the web server alongside the Django-Q2 cluster worker:

Terminal 1 — Web Server Setup
# Clone repository and enter directory
git clone https://github.com/fpupoperez/apple_find_my_network_simple_manager.git
cd apple_find_my_network_simple_manager

# Create virtual environment and install dependencies
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# Copy settings template and edit configuration
cp config/settings.dist.py config/settings.py

# Apply database migrations and start server
python manage.py migrate
python manage.py runserver
Terminal 2 — Background Task Worker
# Activate virtualenv and launch worker process
source .venv/bin/activate
python manage.py qcluster

The manager includes several high-utility command-line management commands for automated workflows:

Useful CLI Management Commands
# Batch generate 4 new devices under account "Home"
python manage.py generate_devices 4 --account "Home" --prefix tag

# Export firmware directly to disk
python manage.py export_firmware car -o main.c --broadcast 10 --sleep 5
python manage.py export_arduino car -o tag.ino --broadcast 10 --sleep 5
python manage.py export_micropython car -o main.py --broadcast 10 --sleep 5

# Interactive Apple login via terminal
python manage.py login_findmy "Home"

# Trigger immediate location fetch for all devices
python manage.py fetch_locations --all --days 7

# Schedule automated periodic fetch every 15 minutes
python manage.py schedule_fetch --every 15 --unit minutes

# Run comprehensive test suite
python manage.py test manager api

15. Repository layout & codebase structure

apple_find_my_network_simple_manager Repository Tree
apple_find_my_network_simple_manager/
├── config/                     # Core Django project configuration
│   ├── settings.dist.py        # Version-controlled settings template
│   ├── settings.py             # Active runtime settings (git-ignored)
│   ├── urls.py                 # Root URL routing (/admin, /api, /account, /)
│   └── middleware.py           # Custom authentication enforcement middleware
├── manager/                    # Core domain application
│   ├── models.py               # AppleAccount, Device, DeviceLocation ORM models
│   ├── views.py                # Dashboard, CRUD views, firmware export handlers
│   ├── encryption.py           # Fernet field-level encryption helper
│   ├── findmy_auth.py          # Shared Apple login & 2FA Anisette handler
│   ├── tasks.py                # Django-Q2 background worker routines
│   ├── keygen.py               # NIST P-224 elliptic curve keypair generator
│   └── templates/manager/      # Dark-mode Bootstrap 5 templates & MapLibre views
├── api/                        # Headless Django REST Framework API
│   ├── serializers.py          # DRF model serializers
│   ├── views.py                # Scoped viewsets (/api/v1/accounts, /devices)
│   └── auth.py                 # Allauth DrfTokenStrategy integration
├── templates/                  # Allauth custom account overrides
└── requirements.txt            # Declared Python production dependencies

16. Technical references & companion repository