$ show photonixapp/photonix
Photonix is a self-hosted, full-stack photo management application with AI-powered classification and search. The backend is a Django monolith exposing a GraphQL API, with background workers for importing, thumbnail generation, raw processing, and ML classification (color, objects, faces, location, style, events). The frontend is a React 19 single-page app built with TanStack Router, Apollo Client, Zustand state management, and a dark-themed shadcn/ui component library. The system supports multi-user libraries, invitations, map view, albums, and fine-grained search with facets. The architecture relies on a PostgreSQL database, Redis for task coordination and locks, and supervisor to manage numerous background processes. While the project shows solid engineering and a modern tech stack, it carries some technical debt from vendored ML models, TensorFlow 1.x compatibility, and hardcoded download URLs, and is explicitly not yet feature-complete.
The LLM identified 5 files worth highlighting for reuse:
Central model lifecycle manager that lazy-loads ML models on demand, enforces memory thresholds (via psutil), uses Redis distributed locks to prevent concurrent downloads/loading across containers, and implements an idle watchdog thread that unloads models after a cooldown period. Demonstrates robust production patterns for managing heavy ML resources in a multi-process environment.
Implements a database-backed task queue with atomic claim/complete/failed/memory_wait methods using conditional UPDATE and select_for_update. Supports task prioritization, parent-child chaining (auto-complete parent when children finish), and retry with backoff. The pattern is cleanly separated from any classifier logic and could be extracted into a reusable task management utility.
Abstract base class for all ML classifiers providing automatic model download with hash verification, lazy TensorFlow graph loading, Redis-backed download locks, and a per-process graph cache. Subclasses only need to implement load() and predict(). This pattern decouples model lifecycle from inference logic and is reusable for any TF-based model.
Provides UUIDModel (UUID primary key with auto-generated created_at) and VersionedModel (adds version field with bump on save) abstract base classes. These are lightweight, self-contained Django model mixins that reduce boilerplate and enforce consistent ID and versioning patterns across all entities.
Complete face classification pipeline: MTCNN detection, FaceNet embedding extraction, per-library Annoy approximate nearest neighbor index, and automated tag creation/association. Includes fallback brute-force matching and index retraining. While coupled to Django models, the core detection->embedding->matching pipeline is well-structured and could be extracted as a reusable face processing module.