[{"data":1,"prerenderedAt":703},["ShallowReactive",2],{"docs-navigation":3,"docs:\u002Fdocs\u002Fconcepts\u002Fhow-it-works":235,"docs-surround:\u002Fdocs\u002Fconcepts\u002Fhow-it-works":698},[4],{"title":5,"path":6,"stem":7,"children":8},"Docs","\u002Fdocs","docs",[9,13,37,55,70,128,146,191,217],{"title":10,"path":6,"stem":11,"icon":12},"Hubstruct documentation","docs\u002Findex","book-open",{"title":14,"icon":15,"path":16,"stem":17,"children":18,"page":36},"Getting started","rocket","\u002Fdocs\u002Fgetting-started","docs\u002F1.getting-started",[19,24,28,32],{"title":20,"path":21,"stem":22,"icon":23},"Introduction","\u002Fdocs\u002Fgetting-started\u002Fintroduction","docs\u002F1.getting-started\u002F1.introduction",null,{"title":25,"path":26,"stem":27,"icon":23},"Requirements","\u002Fdocs\u002Fgetting-started\u002Frequirements","docs\u002F1.getting-started\u002F2.requirements",{"title":29,"path":30,"stem":31,"icon":23},"Quick start","\u002Fdocs\u002Fgetting-started\u002Fquick-start","docs\u002F1.getting-started\u002F3.quick-start",{"title":33,"path":34,"stem":35,"icon":23},"First steps","\u002Fdocs\u002Fgetting-started\u002Ffirst-steps","docs\u002F1.getting-started\u002F4.first-steps",false,{"title":38,"icon":39,"path":40,"stem":41,"children":42,"page":36},"Concepts","lightbulb","\u002Fdocs\u002Fconcepts","docs\u002F2.concepts",[43,47,51],{"title":44,"path":45,"stem":46,"icon":23},"How it works","\u002Fdocs\u002Fconcepts\u002Fhow-it-works","docs\u002F2.concepts\u002F1.how-it-works",{"title":48,"path":49,"stem":50,"icon":23},"Processing steps","\u002Fdocs\u002Fconcepts\u002Fprocessing","docs\u002F2.concepts\u002F2.processing",{"title":52,"path":53,"stem":54,"icon":23},"Media","\u002Fdocs\u002Fconcepts\u002Fmedia","docs\u002F2.concepts\u002F3.media",{"title":56,"path":57,"stem":58,"children":59,"icon":69},"Libraries","\u002Fdocs\u002Flibraries","docs\u002F3.libraries\u002F1.index",[60,61,65],{"title":56,"path":57,"stem":58,"icon":23},{"title":62,"path":63,"stem":64,"icon":23},"Storage","\u002Fdocs\u002Flibraries\u002Fs3","docs\u002F3.libraries\u002F3.s3",{"title":66,"path":67,"stem":68,"icon":23},"Uploading","\u002Fdocs\u002Flibraries\u002Fuploading","docs\u002F3.libraries\u002F4.uploading","layer-group",{"title":71,"icon":72,"path":73,"stem":74,"children":75,"page":36},"Features","wand-magic-sparkles","\u002Fdocs\u002Ffeatures","docs\u002F4.features",[76,80,84,88,92,96,100,104,108,112,116,120,124],{"title":77,"path":78,"stem":79,"icon":23},"Browsing","\u002Fdocs\u002Ffeatures\u002Fbrowsing","docs\u002F4.features\u002F01.browsing",{"title":81,"path":82,"stem":83,"icon":23},"Search","\u002Fdocs\u002Ffeatures\u002Fsearch","docs\u002F4.features\u002F02.search",{"title":85,"path":86,"stem":87,"icon":23},"Tags","\u002Fdocs\u002Ffeatures\u002Ftags","docs\u002F4.features\u002F03.tags",{"title":89,"path":90,"stem":91,"icon":23},"Albums","\u002Fdocs\u002Ffeatures\u002Falbums","docs\u002F4.features\u002F04.albums",{"title":93,"path":94,"stem":95,"icon":23},"People and faces","\u002Fdocs\u002Ffeatures\u002Fpeople","docs\u002F4.features\u002F05.people",{"title":97,"path":98,"stem":99,"icon":23},"Groups","\u002Fdocs\u002Ffeatures\u002Fgroups","docs\u002F4.features\u002F06.groups",{"title":101,"path":102,"stem":103,"icon":23},"Duplicates and stacks","\u002Fdocs\u002Ffeatures\u002Fduplicates-and-stacks","docs\u002F4.features\u002F07.duplicates-and-stacks",{"title":105,"path":106,"stem":107,"icon":23},"NSFW","\u002Fdocs\u002Ffeatures\u002Fnsfw","docs\u002F4.features\u002F08.nsfw",{"title":109,"path":110,"stem":111,"icon":23},"Trash","\u002Fdocs\u002Ffeatures\u002Ftrash","docs\u002F4.features\u002F09.trash",{"title":113,"path":114,"stem":115,"icon":23},"Home and the dashboard","\u002Fdocs\u002Ffeatures\u002Fhome-and-dashboard","docs\u002F4.features\u002F10.home-and-dashboard",{"title":117,"path":118,"stem":119,"icon":23},"Live updates and offline","\u002Fdocs\u002Ffeatures\u002Flive-updates","docs\u002F4.features\u002F11.live-updates",{"title":121,"path":122,"stem":123,"icon":23},"Appearance and the app","\u002Fdocs\u002Ffeatures\u002Fappearance","docs\u002F4.features\u002F12.appearance",{"title":125,"path":126,"stem":127,"icon":23},"Places","\u002Fdocs\u002Ffeatures\u002Fplaces","docs\u002F4.features\u002F13.places",{"title":129,"icon":130,"path":131,"stem":132,"children":133,"page":36},"Administration","sliders","\u002Fdocs\u002Fadministration","docs\u002F5.administration",[134,138,142],{"title":135,"path":136,"stem":137,"icon":23},"Users and sign-in","\u002Fdocs\u002Fadministration\u002Fusers-and-sign-in","docs\u002F5.administration\u002F1.users-and-sign-in",{"title":139,"path":140,"stem":141,"icon":23},"API keys","\u002Fdocs\u002Fadministration\u002Fapi-keys","docs\u002F5.administration\u002F2.api-keys",{"title":143,"path":144,"stem":145,"icon":23},"Processing settings","\u002Fdocs\u002Fadministration\u002Fprocessing-settings","docs\u002F5.administration\u002F3.processing-settings",{"title":147,"icon":148,"path":149,"stem":150,"children":151,"page":36},"Self-hosting","server","\u002Fdocs\u002Fself-hosting","docs\u002F6.self-hosting",[152,156,160,164,167,171,175,179,183,187],{"title":153,"path":154,"stem":155,"icon":23},"Architecture","\u002Fdocs\u002Fself-hosting\u002Farchitecture","docs\u002F6.self-hosting\u002F1.architecture",{"title":157,"path":158,"stem":159,"icon":23},"Telemetry","\u002Fdocs\u002Fself-hosting\u002Ftelemetry","docs\u002F6.self-hosting\u002F10.telemetry",{"title":161,"path":162,"stem":163,"icon":23},"Sharing one GPU","\u002Fdocs\u002Fself-hosting\u002Fgpu","docs\u002F6.self-hosting\u002F2.gpu",{"title":62,"path":165,"stem":166,"icon":23},"\u002Fdocs\u002Fself-hosting\u002Fstorage","docs\u002F6.self-hosting\u002F3.storage",{"title":168,"path":169,"stem":170,"icon":23},"Backups","\u002Fdocs\u002Fself-hosting\u002Fbackups","docs\u002F6.self-hosting\u002F4.backups",{"title":172,"path":173,"stem":174,"icon":23},"Updating","\u002Fdocs\u002Fself-hosting\u002Fupdating","docs\u002F6.self-hosting\u002F5.updating",{"title":176,"path":177,"stem":178,"icon":23},"Scaling","\u002Fdocs\u002Fself-hosting\u002Fscaling","docs\u002F6.self-hosting\u002F6.scaling",{"title":180,"path":181,"stem":182,"icon":23},"HTTPS and a domain","\u002Fdocs\u002Fself-hosting\u002Freverse-proxy","docs\u002F6.self-hosting\u002F7.reverse-proxy",{"title":184,"path":185,"stem":186,"icon":23},"Troubleshooting","\u002Fdocs\u002Fself-hosting\u002Ftroubleshooting","docs\u002F6.self-hosting\u002F8.troubleshooting",{"title":188,"path":189,"stem":190,"icon":23},"The config file","\u002Fdocs\u002Fself-hosting\u002Fconfig-file","docs\u002F6.self-hosting\u002F9.config-file",{"title":192,"icon":193,"path":194,"stem":195,"children":196,"page":36},"Reference","book","\u002Fdocs\u002Freference","docs\u002F7.reference",[197,201,205,209,213],{"title":198,"path":199,"stem":200,"icon":23},"Environment variables","\u002Fdocs\u002Freference\u002Fenvironment","docs\u002F7.reference\u002F1.environment",{"title":202,"path":203,"stem":204,"icon":23},"Worker roles","\u002Fdocs\u002Freference\u002Fworker-roles","docs\u002F7.reference\u002F2.worker-roles",{"title":206,"path":207,"stem":208,"icon":23},"API","\u002Fdocs\u002Freference\u002Fapi","docs\u002F7.reference\u002F3.api",{"title":210,"path":211,"stem":212,"icon":23},"Keyboard shortcuts","\u002Fdocs\u002Freference\u002Fkeyboard-shortcuts","docs\u002F7.reference\u002F4.keyboard-shortcuts",{"title":214,"path":215,"stem":216,"icon":23},"Models","\u002Fdocs\u002Freference\u002Fmodels","docs\u002F7.reference\u002F5.models",{"title":218,"icon":219,"path":220,"stem":221,"children":222,"page":36},"Hubstruct Cloud","cloud","\u002Fdocs\u002Fcloud","docs\u002F8.cloud",[223,227,231],{"title":224,"path":225,"stem":226,"icon":23},"Getting started with the cloud","\u002Fdocs\u002Fcloud\u002Fgetting-started","docs\u002F8.cloud\u002F1.getting-started",{"title":228,"path":229,"stem":230,"icon":23},"Plans and billing","\u002Fdocs\u002Fcloud\u002Fplans-and-billing","docs\u002F8.cloud\u002F2.plans-and-billing",{"title":232,"path":233,"stem":234,"icon":23},"Moving between cloud and self-hosted","\u002Fdocs\u002Fcloud\u002Fmoving","docs\u002F8.cloud\u002F3.moving",{"id":236,"title":44,"body":237,"description":692,"extension":693,"eyebrow":38,"icon":23,"meta":694,"navigation":695,"path":45,"seo":696,"stem":46,"__hash__":697},"docs\u002Fdocs\u002F2.concepts\u002F1.how-it-works.md",{"type":238,"value":239,"toc":681},"minimark",[240,244,249,406,412,416,426,429,433,445,461,464,467,499,503,506,605,611,615,666,670],[241,242,243],"p",{},"Hubstruct is built from a few services with one job each, all started together by Docker Compose. This page explains what they are, how they talk to each other, and what happens between adding a photo and finding it by searching for what's in it.",[245,246,248],"h2",{"id":247},"the-services","The services",[250,251,252,268],"table",{},[253,254,255],"thead",{},[256,257,258,262,265],"tr",{},[259,260,261],"th",{},"Service",[259,263,264],{},"What it does",[259,266,267],{},"Needs",[269,270,271,288,309,326,340,356,370,394],"tbody",{},[256,272,273,280,283],{},[274,275,276],"td",{},[277,278,279],"code",{},"console",[274,281,282],{},"The app you open in the browser. It draws pages on the server where that helps (your theme and colors, page headers), and passes the browser's calls on to the API.",[274,284,285],{},[277,286,287],{},"api",[256,289,290,294,297],{},[274,291,292],{},[277,293,287],{},[274,295,296],{},"Everything the app can do, as an HTTP API with an OpenAPI reference. Sign-in, permissions, lists, search, edits, uploads, and the live stream of changes.",[274,298,299,302,303,302,306],{},[277,300,301],{},"postgres",", ",[277,304,305],{},"storage",[277,307,308],{},"models",[256,310,311,316,319],{},[274,312,313],{},[277,314,315],{},"worker",[274,317,318],{},"All background work: the processing steps, keeping album rules current, suggesting people and putting media in places.",[274,320,321,302,323,325],{},[277,322,301],{},[277,324,305],{},", the models",[256,327,328,333,336],{},[274,329,330],{},[277,331,332],{},"migrator",[274,334,335],{},"Runs once at every start: applies any database changes the new version brings, then exits. Everything else waits for it.",[274,337,338],{},[277,339,301],{},[256,341,342,346,354],{},[274,343,344],{},[277,345,301],{},[274,347,348,349,353],{},"PostgreSQL 18 with ",[350,351,352],"strong",{},"pgvector",": the media, tags, albums, people, the embeddings and the indexes that search them.",[274,355],{},[256,357,358,362,368],{},[274,359,360],{},[277,361,305],{},[274,363,364,367],{},[350,365,366],{},"Garage",", an S3-compatible object store: libraries' originals and renditions, and the pictures Hubstruct makes itself, such as album mosaics.",[274,369],{},[256,371,372,376,391],{},[274,373,374],{},[277,375,308],{},[274,377,378,379,382,383,386,387,390],{},"llama.cpp, one server per model, started as needed: ",[350,380,381],{},"Gemma"," (descriptions, titles, reading text), ",[350,384,385],{},"EmbeddingGemma"," (the embeddings for search and similarity) and ",[350,388,389],{},"d1",", the classifier behind smart tags and NSFW scores.",[274,392,393],{},"GPU",[256,395,396,401,404],{},[274,397,398],{},[277,399,400],{},"vision",[274,402,403],{},"Image models over HTTP: the face detectors and embedders (real and drawn faces), and the text detector.",[274,405,393],{},[241,407,408,411],{},[409,410,153],"a",{"href":154}," goes into ports, volumes and health checks.",[245,413,415],{"id":414},"the-app-never-touches-the-database","The app never touches the database",[241,417,418,419,421,422,425],{},"The browser talks only to ",[277,420,279],{},", on one address. Calls to ",[277,423,424],{},"\u002Fapi\u002F…"," are passed on to the API by the app's own server, so the browser never needs to reach the API directly and the session cookie stays on one origin. When the app draws a page on the server, it calls the API over Compose's private network.",[241,427,428],{},"The API is the only thing that reads and writes on behalf of people. The worker writes too, but only the results of its own work.",[245,430,432],{"id":431},"no-queue-work-is-worked-out-from-the-data","No queue: work is worked out from the data",[241,434,435,436,439,440,444],{},"Most systems like this put jobs on a queue. Hubstruct doesn't. Instead, each processing step has a ",[350,437,438],{},"processor"," in the worker that asks the database a question: ",[441,442,443],"em",{},"which media need this step right now?"," The answer comes from a view that compares what each media has with what the step needs:",[446,447,448,452,455,458],"ul",{},[449,450,451],"li",{},"Has the step never run on it? It's due.",[449,453,454],{},"Did the step fail, and has its back-off time passed? It's due again.",[449,456,457],{},"Has something it depends on changed since it last ran, such as the text an embedding was made from? It's due again.",[449,459,460],{},"Are the steps it depends on done? If not, it waits.",[241,462,463],{},"Each run is recorded on the media: when it started, how long it took, which model ran, and what went wrong if anything did. That record is what the dashboard shows.",[241,465,466],{},"Because the database is the only source of truth:",[446,468,469,475,484,490],{},[449,470,471,474],{},[350,472,473],{},"Nothing is lost on a restart."," The worker asks the same question again and carries on.",[449,476,477,480,481,483],{},[350,478,479],{},"Turning a model off pauses its steps."," A processor only takes work while the model server it needs answers its health check. Stop ",[277,482,308],{},", and the steps that need it simply wait.",[449,485,486,489],{},[350,487,488],{},"Changes re-trigger the right work."," Edit a title and the embedding is redone; add a smart tag and every media is scored for it; nothing has to be queued by hand.",[449,491,492,495,496,498],{},[350,493,494],{},"Several workers can share the work."," Taking a media is a conditional write that only succeeds once, so two workers never do the same thing. See ",[409,497,176],{"href":177},".",[245,500,502],{"id":501},"from-a-photo-to-a-search-result","From a photo to a search result",[241,504,505],{},"Here is what happens when you upload a photo to a library:",[507,508,509,515,521,527,578,584,594],"ol",{},[449,510,511,514],{},[350,512,513],{},"The upload"," streams the file straight into storage, never holding it in memory, and creates its row. The page shows it at once.",[449,516,517,520],{},[350,518,519],{},"metadata"," reads what the file is: its size, how long it is if it's a video, when it was taken (from EXIF) and its ThumbHash, a tiny blurry placeholder.",[449,522,523,526],{},[350,524,525],{},"renditions"," makes a thumbnail and a preview (for a video, from a frame a moment in).",[449,528,529,530],{},"In parallel, the rest begin:\n",[446,531,532,538,544,550,556,562,568],{},[449,533,534,537],{},[350,535,536],{},"analysis"," measures colors, sharpness and exposure, and a perceptual hash;",[449,539,540,543],{},[350,541,542],{},"visual"," makes an embedding of the pixels alone;",[449,545,546,549],{},[350,547,548],{},"tagging"," asks the classifier about each smart tag;",[449,551,552,555],{},[350,553,554],{},"nsfw"," asks it one more question;",[449,557,558,561],{},[350,559,560],{},"text"," finds any text and reads it;",[449,563,564,567],{},[350,565,566],{},"faces"," finds the faces and embeds each one;",[449,569,570,573,574,577],{},[350,571,572],{},"description",", then ",[350,575,576],{},"title",", have Gemma describe it.",[449,579,580,583],{},[350,581,582],{},"duplicates"," compares its hash and image embedding with the rest of the library.",[449,585,586,589,590,593],{},[350,587,588],{},"embedding"," combines everything written about it (titles, descriptions, the text in it, its tags) with its picture into one vector. This is what search, ",[441,591,592],{},"similar media"," and album rules compare.",[449,595,596,597,600,601,604],{},"Meanwhile, the worker's ",[350,598,599],{},"people"," pass places its faces with people, and the ",[350,602,603],{},"albums"," pass adds it to any album whose rules it now matches.",[241,606,607,608,498],{},"Each finished step announces itself, and open pages update within about a second. See ",[409,609,610],{"href":118},"Live updates",[245,612,614],{"id":613},"where-things-are-kept","Where things are kept",[250,616,617,627],{},[253,618,619],{},[256,620,621,624],{},[259,622,623],{},"What",[259,625,626],{},"Where",[269,628,629,637,648,656],{},[256,630,631,634],{},[274,632,633],{},"Media rows, tags, albums, people, faces, embeddings, settings, accounts",[274,635,636],{},"PostgreSQL",[256,638,639,642],{},[274,640,641],{},"Libraries' originals, thumbnails and previews",[274,643,644,645],{},"Storage, under ",[277,646,647],{},"libraries\u002F\u003Cid>\u002F",[256,649,650,653],{},[274,651,652],{},"Album, tag and person mosaics (the cover pictures)",[274,654,655],{},"Storage, made on demand and cached",[256,657,658,660],{},[274,659,214],{},[274,661,662,663,665],{},"The ",[277,664,308],{}," volume",[245,667,669],{"id":668},"secrets","Secrets",[241,671,672,673,676,677,680],{},"Secrets Hubstruct keeps in the database are encrypted with the app secret (",[277,674,675],{},"APP_SECRET",", or one derived from ",[277,678,679],{},"POSTGRES_PASSWORD"," if it's unset). Passwords are hashed with scrypt; sessions and API keys are stored only as SHA-256 hashes, so the database's contents can't be used to sign in.",{"title":682,"searchDepth":683,"depth":683,"links":684},"",3,[685,687,688,689,690,691],{"id":247,"depth":686,"text":248},2,{"id":414,"depth":686,"text":415},{"id":431,"depth":686,"text":432},{"id":501,"depth":686,"text":502},{"id":613,"depth":686,"text":614},{"id":668,"depth":686,"text":669},"The services that make up Hubstruct, what each one does, and how a photo travels through them.","md",{},true,{"title":44,"description":692},"dGikYs2ol7km_6Z0WDlsCIv_38L6upSNF8fvhCetzXo",[699,701],{"title":33,"path":34,"stem":35,"description":700,"children":-1},"Your first hour with Hubstruct, from the empty library to smart tags, albums and people.",{"title":48,"path":49,"stem":50,"description":702,"children":-1},"Every step Hubstruct runs on a photo or video, in order, with what it needs, what it makes, and when it runs again.",1795744073075]