How smithsonian/dpo-packrat works
Project Type and Purpose
• This is a monorepo for a full-stack application called dpo-packrat, which manages 3D data captures, models, and scenes.
• It comprises:
• A React-based SPA in client/
• A Node.js-TypeScript GraphQL API + HTTP server in server/
• A shared TypeScript library in common/
• Docker and Nginx configuration in conf/
• End-to-end and unit tests in e2e/ and server/tests/
• Documentation site in docs/
High-Level File-Structure Analysis
• Top-level packages managed by Lerna:
• client/ – React app, components, pages, GraphQL client, Redux store
• common/ – Shared types/constants/utilities
• server/ – GraphQL schemas, Prisma models, many service modules (auth, cache, event, storage, job, workflow, navigation, metadata, audit, collections), HTTP routes, utilities
• Configuration for Docker Compose (conf/docker/*), Nginx (conf/nginx/*), and deployment scripts (conf/scripts/*)
• Test directories separate concerns: e2e tests target the client/server, server side unit tests cover each domain module and GraphQL layer
Key README Insights
• The system runs in Docker containers: client, server, DB, Solr, Nginx proxy.
• Uses Prisma for DB access (PostgreSQL or similar), Solr for enterprise search, Passport for LDAP/Local auth.
• GraphQL code generation required when schema changes.
• Two modes: Docker-based (dev/prod) and local dev without Docker (manually start client, server, common).
Main Components & Interactions
a. Frontend (React SPA)
• Hosted in Docker or on port 3000
• Uses Apollo Client (or GraphQL fetch) to call server’s GraphQL endpoint
• Auth flow integrates via HTTP cookie / token from server
b. Backend (Node.js / TypeScript)
• HTTP Layer: Express (or built-in HTTP) with routes for GraphQL, WebDAV, downloads, sitemap, health checks
• GraphQL Engine: Apollo Server or equivalent, with schema defined under server/graphql/schema and resolvers under server/graphql/api
• Auth Module: Passport strategies (LDAP, Local) under server/auth
• Database Layer: Prisma client generated from server/db/prisma/schema.prisma; custom ORM wrappers in server/db/api
• Event Bus: In-process event engine for pub/sub across modules
• Cache: In-memory or Redis-like abstraction for licenses, users, vocabulary, system objects
• Storage: OCFL-compliant local file storage with adapters under server/storage
• Metadata Extraction: Image/video metadata via ExifTool/Exifr under server/metadata
• Job & Workflow Engines: Long-running tasks (Cook, NS, Packrat) under server/job and server/workflow
• Navigation / Search: Indexing and querying Solr cores under server/navigation and server/config/solr
• Audit & Reporting: Audit events, generators, reporting under server/audit and server/report
c. External Services
• Database: PostgreSQL (or MySQL) container via Docker Compose
• Solr: Standalone Solr containers with multiple cores (packrat, packratMeta)
• Nginx Proxy: SSL termination, routing to client and server containers
• LDAP server (optional) for authentication
Architectural Patterns & Principles
• Modularization: Each domain (auth, cache, storage, event, job, workflow, metadata, navigation) follows an interface/impl/factory structure
• Factory Pattern for creating adapters (AuthFactory, StorageFactory, EventFactory, CollectionFactory, ReportFactory, etc.)
• In-Process Event Bus to decouple subsystems
• GraphQL Schema-First approach + codegen + Prisma ORM
• Containerization via Docker Compose for full-stack isolation and reproducible environments