Skip to content

Bulk downloads

eecavanna edited this page Aug 29, 2025 · 4 revisions

The following Mermaid diagram represents a team member's understanding of how bulk downloads work on the Data Portal.

sequenceDiagram
    actor user AS User
    participant wb AS Browser
    participant fe   AS Frontend<br>(a.k.a. web)
    participant be   AS Backend
    participant pg   AS Postgres
    participant zs   AS ZipStreamer
    participant net  AS Internet

    %% 1. Select file type(s).
    user->>wb: 1. Select file type(s)
    wb->fe   : POST /api/bulk_download/summary<br>(payload is: selected file types)
    fe->>be  :
    be->>pg  : SELECT<br>the quantity and total size<br>of matching DataObjects
    pg-->>be :
    be-->fe  : 
    fe-->>wb : {"count": 123, "size": 456}
    wb-->>user: Display quantity and size

    %% 2. Initiate download.
    user->>wb : 2. Click "Download ZIP"
    wb-->>user: Display modal
    user->>wb : 3. Click "Accept and continue..."
    wb->>fe   : POST /api/bulk_download<br>(payload is: selected file types, again)
    fe->>be   : 
    be->>pg   : INSERT<br>1 BulkDownload (in total) and<br>1 BulkDownloadDataObject<br>(per matching DataObject)
    pg-->>be  :
    be-->fe   : 
    fe-->>wb  : {"id": "06da0492-...", ...}<br>(BulkDownload ID and misc. info)
    
    %% 3. Automatically visit BulkDownload URL.
    wb->>fe   : GET /api/bulk_download/{id}
    fe->>be   : 
    be->>pg   : SELECT<br>the BulkDownload
    pg-->>be  : 
    be->>be   : Build ZIP file descriptor<br>(a list of URLs and file paths)
    be->>pg   : UPDATE<br>the BulkDownload<br>(set its "expired" flag)
    be->>zs   : POST /download<br>(payload is: ZIP file descriptor)
    zs->>net  : GET {url}
    zs->>net  : 
    zs->>net  : 
    net-->zs  : 
    net-->zs  : 
    net-->zs  : 
    Note left of net: I don't know whether<br>ZipStreamer builds the<br>entire ZIP file before<br>beginning to stream<br>the first chunk of it
    zs-->>be  :
    be-->>fe  :
    fe-->>wb  : 
    wb-->>user: Display generic<br>"Save as..." prompt
    Note left of wb: I assume the web browser<br>displays this when an initial<br>HTTP response header arrives
    user->>wb: 4. Enter destination file path
    zs-->>be  : (Chunk of ZIP file)
    zs-->>be  : 
    zs-->>be  : 
    be-->>fe  :
    be-->>fe  :
    be-->>fe  :
    fe-->>wb  : 
    fe-->>wb  :
    fe-->>wb  :
    wb->>wb   : Build ZIP file from chunks
    wb-->>user: Display generic<br>"Download finished" message

Loading
Clone this wiki locally