How aces/data-query-tool works
File structure
• Top-level project files:
• couchapp.json: metadata for Erica/Couchapp tooling
• rewrites.json: URL rewrite rules mapping friendly routes to design document functions
• filters/, views/, functions/: CouchDB design document components
• _attachments/: all static assets (HTML, JS, CSS, images, tests) that form the UI
• filters/: JavaScript functions for filtered replication or changes feeds
• views/: map/reduce functions for each data domain (categories, datadictionary, files, instruments, runlog, savedqueries, search, serverconfig, sessions)
• functions/: list.js, show.js, etc., which process view output or render documents
• _attachments/: contains:
– script/: UI JavaScript modules and unit tests (array_tools, query, user, UI modules)
– style/: CSS themes and layout styles
– index.html & help HTML pages
• No separate “backend” folder—CouchDB itself acts as the server, exposing all endpoints.
README for additional insights
• Confirms CouchDB ≥1.2 is required
• Installation is done via CouchDB replication (from central server) or Erica push
• Data is populated by external Loris import scripts (not part of this repo)
• Access point is the design document’s _rewrite endpoint
a. Main components to represent:
• Client Browser (UI)
• CouchDB Server (with the target database)
• CouchDB Design Document (“DQG-2.0”) containing:
– Static Assets (HTML/CSS/JS under _attachments)
– Views (map/reduce functions)
– Show/List/Update/Filter functions
– URL Rewrite Rules
• External CouchDB Instance (couchdb.loris.ca) for initial replication
• (Optionally) Loris Import Scripts / Admin tooling (Erica, PHP scripts)
b. Relationships & data flows:
• Browser issues HTTP GET/POST to CouchDB _rewrite endpoint → triggers show/list or serves static HTML/JS/CSS
• Browser fetches view results (JSON) from CouchDB via AJAX
• CouchDB serves map/reduce outputs or document attachments
• (Optional) Loris PHP scripts → push data into CouchDB via CouchDB HTTP API
c. Architectural patterns & design principles:
• Serverless Frontend: UI is purely static in CouchDB attachments
• RESTful HTTP API: CouchDB’s API serves as both data and static asset endpoints
• MapReduce Views: pre-aggregated queries via map/reduce functions
• Filtered replication: filters/ directory defines named filters for data sync
• /List functions: server-side rendering or JSON transformation of view rows
• URL Rewrites: friendly URLs mapped to CouchDB endpoints
d. Key technologies & frameworks:
• Apache CouchDB
• CouchDB design docs: views, shows, lists, filters, rewrites
• Erica (for dev push)
• JavaScript (client-side modules, Jasmine tests)
• jQuery UI themes for styling
• PHP import scripts (external Loris tools)
Detail
• Break out each view folder to show domain contexts (categories, search, sessions…)
• That list/show functions wrap view output for UI components
• Call out the rewrites.json mapping of friendly URLs
• Filters as logical nodes used by replication or changes feeds