[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-107669":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":14,"stars30d":15,"stars90d":13,"forks30d":13,"starsTrendScore":13,"compositeScore":16,"rankGlobal":8,"rankLanguage":8,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":8,"pushedAt":22,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":13,"starSnapshotCount":13,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},107669,"Closet","20cwaters\u002FCloset","20cwaters",null,"TypeScript",67,9,51,0,1,15,42,"MIT License",false,"main",true,[],"2026-10-31 19:29:30","2026-11-17 07:16:18","# Closet\n\nA self-hosted wardrobe app for your household: photograph your clothes, build and save\noutfits, and get a daily outfit suggestion based on the weather and what you've worn\nrecently. It runs in Docker on any always-on machine (a home server, a NAS, a Raspberry Pi\nwith enough memory) and is meant to be reached on your home network.\n\n- **A tablet in the closet:** browse, build outfits, see today's pick. Returns to the\n  profiles screen after 90 idle seconds.\n- **Phones:** take photos and add clothes. Remembers who you are.\n- **Everyone gets a profile:** add as many people as you like; each has their own closet,\n  outfits and daily pick, and pieces can be shared between closets.\n\nThere are no passwords: anyone who can reach the app can use every profile. Keep it on\nyour home network (or behind something like Tailscale), not on the open internet.\n\n## Quick start\n\nYou need Docker with Compose, and about 3 GB of free memory for background removal.\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002F20cwaters\u002FCloset.git closet\ncd closet\ncp .env.example .env        # then set LAT, LON and TZ (see below)\ndocker compose up -d --build\n```\n\nOpen **http:\u002F\u002F\u003Cserver-ip>:8530** (or whatever `PORT` you set). On first visit Closet asks\nfor your name and shows a short tour; replay it any time from your avatar menu\n(**How Closet works**).\n\nThe first photo you add downloads the background-removal model (~170 MB, once, kept in\n`data\u002Fmodels`). rembg also takes about a minute to start after a restart. Uploads made in\nthe meantime wait and retry on their own.\n\n## People\n\n- **Add someone:** on the profiles screen, tap **Add person**. (On a phone, open your avatar\n  menu and tap **Profiles** to get there.)\n- **Rename, change photo, remove:** tap your avatar. **Remove** deletes that person's\n  pieces, outfits, wear history and plans for good, after a confirmation.\n- **Switch person:** tap your avatar, then **Switch to …** or **Profiles**.\n\nEach person's address is their name, e.g. `http:\u002F\u002F\u003Cserver-ip>:8530\u002Fsam\u002Fbuild`, so a phone\ncan bookmark its owner's closet.\n\n## Settings (`.env`)\n\n| Variable | Default | What it does |\n|---|---|---|\n| `PORT` | `8530` | Port the app listens on. |\n| `LAT`, `LON` | New York City | Where to get the weather for (decimal degrees). |\n| `TZ` | container default (UTC) | Timezone for \"today\" (wear log, daily pick), e.g. `Europe\u002FLondon`. |\n| `IDLE_TIMEOUT_SECONDS` | `90` | Large screens return to the profiles screen after this long untouched. `0` turns it off. |\n| `REMBG_URL` | `http:\u002F\u002Frembg:7000` | Background removal service (the `rembg` container). |\n| `REMBG_MODEL` | `isnet-general-use` | rembg model. `u2net` is ~2x faster but leaves softer edges. rembg's own default, `bria-rmbg`, needs much more memory. |\n| `SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`, `SPOTIFY_REDIRECT_URI` | empty | Optional music player; see **Music (Spotify)**. |\n| `OPENROUTER_API_KEY`, `AI_MODEL`, `OPENAI_API_KEY`, `OPENAI_IMAGE_MODEL` | empty | Optional AI product shots; see **Make it perfect**. |\n\nApply changes with `docker compose up -d`.\n\n## Taking photos\n\nLay each piece flat on a plain background, one piece per photo. For white pieces, or\nanything with big white prints or logos, use a colored background. White on white is the\none thing background removal struggles with. You can select dozens of photos at once.\nTag them while they upload; the cutouts arrive in the background (~5–8 s each).\n\nGet close, so the piece fills most of the frame: the cutout is cropped from the photo, so\na piece shot from across the room comes out small and soft. Dark pieces look best in bright,\nwarm light (a window in daytime) on a light grey background rather than bright white, which\nmakes the camera darken them until the fabric texture is lost.\n\nIf a background can't be removed, the piece keeps its original photo. Open it and tap\n**Try again** once rembg is back.\n\n### Make it perfect (optional, AI)\n\nWith an API key set, every new piece (and every retake) automatically gets an AI version\nafter its background is removed, and shows it once ready. The detail view's **Make it\nperfect** does the same by hand: an image model (Seedream 5.0 Flash, through OpenRouter)\nredraws it as a clean, flat, evenly lit product photo, which then has its background removed\nlike any other. It takes about 30 s and costs about 2¢. Your photo is kept: **Your photo \u002F\nPerfect** switches which one the closet shows, and **Redo it** tries again. AI versions can\ninvent small details (a label, a slightly different shade), so check pieces with logos or\nprints. Retaking the photo drops the AI version. Photos are sent to the AI provider, so\nleave this off if you'd rather they stay on your machine.\n\nSeedream's filter refuses some prints, usually well-known characters. With `OPENAI_API_KEY`\nset, those pieces automatically go to OpenAI's image model instead (`OPENAI_IMAGE_MODEL`,\nabout 2¢ each too, though its filter refuses some as well).\n\nTo turn it on, create a key at [openrouter.ai](https:\u002F\u002Fopenrouter.ai) (Settings → API Keys,\nwith a few dollars of credit) and set `OPENROUTER_API_KEY` in `.env`, then\n`docker compose up -d app`. To make AI versions for every piece that hasn't got one\n(one at a time; stops if the credits run out):\n\n```sh\ndocker compose run --rm --no-deps -T app node dist\u002Fenhance.js        # or: … enhance.js 12 40\n```\n\nAfter the cutout code changes, redo every piece's cutout from its original (safe while the\napp is in use; each piece keeps its old cutout until the new one is ready, ~7 s per piece):\n\n```sh\ndocker compose run --rm --no-deps -T app node dist\u002Freprocess.js        # or: … reprocess.js 12 40\n```\n\n## Tags\n\nEvery piece can have any number of each kind of tag:\n\n- **Category:** headwear, outerwear, top, bottom, shoes. An overshirt can be both a top\n  and outerwear; it then shows in both Build rows and both Closet sections.\n- **Weather:** hot, warm, cool, cold, rainy, windy. **All weather** sets the lot. A piece\n  with no weather tags counts as fine in any weather.\n- **Style:** Casual, Work, Dressy, Athletic, Lounge, Outdoor, plus any you add with\n  **Add style** in the picker. The Closet can filter by style.\n\nA piece's detail view edits its tags, and **Retake photo** swaps in a new photo while\nkeeping its tags and outfits. **Share** makes a piece show up in everyone's closet.\n\n## Layers\n\nThe Tops and Outerwear rows in Build have **+ Layer**, for up to 3 of each (a tee under a\nshirt, a vest under a coat). Saved outfits remember which row each piece was in, so they\nreopen layered.\n\n## The daily suggestion\n\nAll the rules live in **`server\u002Fsrc\u002Frules.ts`**:\n\n- **Recency:** a top worn in the last 5 days, or bottoms in the last 3, are skipped.\n  Shoes, outerwear and headwear can repeat.\n- **Today's weather:** the high sets the temperature: cold (\u003C 45 °F), cool (\u003C 65 °F),\n  warm (\u003C 80 °F) or hot. Rain over 50 % adds *rainy*; wind over 20 mph adds *windy*.\n  Pieces tagged with temperatures are only picked on those days. On rainy or windy days,\n  pieces tagged for it are picked first.\n- **Outerwear:** shown when the high is below 60 °F, or it's rainy or windy.\n\nAn outfit planned for today on the calendar wins. Otherwise a saved outfit where every\npiece fits is preferred, favoring the least recently worn; failing that, one is assembled\npiece by piece. The pick is the same all day (seeded by person and date), and **Shuffle**\ngives an alternative that suits today's temperature.\n\nAfter editing `rules.ts`, run `docker compose up -d --build app`.\n\n## Music (Spotify)\n\nA slim \"now playing\" strip on Build, with play, pause and skip. Tap it to pick a speaker\n(any Spotify Connect device: a phone, a smart speaker) and a playlist. Star a playlist to\nmake it your **morning playlist**: when nothing is playing, the strip starts it in one tap.\nEach person connects their own Spotify from their avatar menu, and each needs Premium.\n\n**One-time setup** (Spotify only allows this for the account owner):\n\n1. Go to \u003Chttps:\u002F\u002Fdeveloper.spotify.com\u002Fdashboard> and **Create app**:\n   - Name: Closet. Description: anything.\n   - Redirect URI: `https:\u002F\u002F\u003Cyour-closet-address>\u002Fapi\u002Fspotify\u002Fcallback` (it must be HTTPS;\n     see **HTTPS** below).\n   - API used: **Web API**.\n2. In the app's **User Management**, add the Spotify account of everyone else who'll use\n   it. Development Mode allows up to 5 people; the app owner needs Premium.\n3. In **Settings**, copy the Client ID and Client secret into `.env`\n   (`SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`), set `SPOTIFY_REDIRECT_URI` to the same\n   redirect URI, then run `docker compose up -d`.\n4. Each person: open Closet at its HTTPS address, tap your avatar, then **Connect\n   Spotify**. After that the connection is stored on the server, so any screen, including\n   a shared tablet, shows the player.\n\nSpeakers only appear while Spotify is open (or recently used) on them. If none show,\nopen Spotify on the phone or speaker and tap **Refresh**. Tokens refresh on their own; if\nsomeone revokes access in their Spotify account, Closet shows **Connect Spotify** again.\nDisconnecting from the avatar menu forgets the tokens. Note that backups include the\nstored tokens.\n\n## A local name like `closet.home`\n\nDNS names can't carry a port, so pick one of these:\n\n1. **Your router's or Pi-hole\u002FAdGuard's local DNS.** Add a record `closet.home → \u003Cserver-ip>`,\n   then use `http:\u002F\u002Fcloset.home:8530`. (`home.arpa` is the officially reserved suffix for\n   home networks; `.home` works with most home DNS too.)\n2. **Drop the port with a reverse proxy.** With Caddy, for example:\n\n   ```\n   http:\u002F\u002Fcloset.home {\n       reverse_proxy 127.0.0.1:8530\n   }\n   ```\n\n3. **One device only:** put `\u003Cserver-ip>  closet.home` in that device's hosts file.\n\n## HTTPS (optional: needed to install it as an app, keep the screen on, and for Spotify)\n\nOver plain HTTP everything works, but browsers only allow **Install app** (PWA, fullscreen)\nand the **screen wake lock** on HTTPS. With HTTPS a tablet keeps its screen on by itself\nwhile the app is open.\n\n- **Tailscale (simplest, no certificates to manage).** If your devices are on a tailnet:\n\n  ```sh\n  tailscale serve --bg --https=8443 http:\u002F\u002F127.0.0.1:8530\n  ```\n\n  The app is then at `https:\u002F\u002F\u003Cmachine>.\u003Ctailnet>.ts.net:8443`, tailnet only. Remove it\n  with `tailscale serve --https=8443 off`. **Never** use `tailscale serve` on a port that's\n  already a Funnel (`tailscale funnel status` lists them); it turns Funnel off for\n  everything on that port.\n- **Caddy with its internal CA (LAN only).** Use a `closet.home { tls internal; reverse_proxy 127.0.0.1:8530 }`\n  block, then install Caddy's root certificate on the tablet and phones.\n\nThen on the tablet open the HTTPS address and choose **Install app** \u002F **Add to Home\nscreen**. It opens fullscreen like a kiosk app. A kiosk browser such as Fully Kiosk works\ntoo.\n\n## Backups\n\n`backup.sh` makes a safe online copy of the database with SQLite's `.backup`, checks its\nintegrity, and snapshots the images folder. Images never change once written, so each\nsnapshot hard-links unchanged photos to the last one, and a nightly run costs only that\nday's new photos. It keeps the newest 14 snapshots by default.\n\n```sh\n.\u002Fbackup.sh \u002Fpath\u002Fto\u002Fbackups\u002Fcloset        # keep 14\n.\u002Fbackup.sh \u002Fpath\u002Fto\u002Fbackups\u002Fcloset 30     # keep 30\n```\n\nUse a different disk from the app's. Nightly at 03:15, via `crontab -e`:\n\n```cron\n15 3 * * * \u002Fpath\u002Fto\u002Fcloset\u002Fbackup.sh \u002Fpath\u002Fto\u002Fbackups\u002Fcloset >> \u002Fpath\u002Fto\u002Fbackups\u002Fcloset\u002Fbackup.log 2>&1\n```\n\nThe log path must be somewhere you can write. If cron can't open it, the whole job\nsilently never runs. Create the folder first: `mkdir -p \u002Fpath\u002Fto\u002Fbackups\u002Fcloset`.\n\n### Restore\n\n```sh\ncd \u002Fpath\u002Fto\u002Fcloset\ndocker compose stop app\ncp \u002Fpath\u002Fto\u002Fbackups\u002Fcloset\u002Flatest\u002Fcloset.db data\u002Fcloset.db\nrm -f data\u002Fcloset.db-wal data\u002Fcloset.db-shm\nrsync -a --delete \u002Fpath\u002Fto\u002Fbackups\u002Fcloset\u002Flatest\u002Fimages\u002F data\u002Fimages\u002F\ndocker compose start app\n```\n\nUse a dated folder instead of `latest` to go back further.\n\n## Running it\n\n- **Status:** `docker compose ps`. The app has a Docker healthcheck on `\u002Fapi\u002Fhealth`, which\n  also reports whether rembg is up.\n- **Logs:** `docker compose logs -f app` (or `rembg`).\n- **Memory:** rembg holds ~1.7 GB once it has processed a photo, capped at 2.5 GB.\n  `docker restart closet-rembg` frees it after a big batch.\n- **Data:** `.\u002Fdata` holds `closet.db` and `images\u002F{originals,cutouts,thumbs,outfits,people}`.\n  Filenames are random and never reused, so images are served with year-long cache headers.\n- **File ownership:** both containers run as user `1000:1000` so `.\u002Fdata` stays owned by\n  you. If your user id differs (`id -u`), change `user:` in `docker-compose.yml`.\n\n## Development\n\nWith Node 22:\n\n```sh\ncd server && npm install && npm run build && npm test     # type-check + suggestion rule tests\ncd web && npm install && npx tsc -b                        # type-check the frontend\n```\n\nOr without Node on the host, in containers:\n\n```sh\ndocker run --rm -u 1000:1000 -e HOME=\u002Ftmp -v $PWD\u002Fweb:\u002Fw -w \u002Fw node:22-bookworm npx tsc -b\ndocker run --rm -u 1000:1000 -e HOME=\u002Ftmp -e DATA_DIR=\u002Ftmp\u002Fd -v $PWD\u002Fserver:\u002Fw -w \u002Fw node:22-bookworm \\\n  sh -c 'npx tsc -p . && npm test'\ndocker compose up -d --build app     # rebuild and restart\n```\n\n- **Layout:** `server\u002F` holds Express, SQLite migrations in `server\u002Fmigrations\u002F*.sql`, and\n  the image pipeline. `web\u002F` is React + Vite + Tailwind; the design tokens are in\n  `web\u002Fsrc\u002Fstyles\u002Ftokens.css`.\n- **Schema changes:** add a new numbered `.sql` file to `server\u002Fmigrations\u002F`. Each runs\n  once, in order, with foreign keys off and checked before it commits. Existing data must\n  be carried forward; `002_tags_layers.sql` and `007_people.sql` are examples.\n\n## Contributing\n\nIssues and pull requests are welcome. Please keep changes small and focused, run the\ntype-checks and tests above, and describe how you tried the change in the app.\n\n## License\n\n[MIT](LICENSE)\n","Closet 是一款自托管的家庭衣橱管理应用，帮助用户拍照录入衣物、创建搭配方案，并基于天气和穿着历史提供每日穿搭建议。核心功能包括多用户个人档案（支持衣物共享）、无密码本地访问、自动背景去除（集成 rembg）、设备自适应界面（平板\u002F手机），以及可选的 Spotify 音乐集成和 AI 服饰图生成。项目采用 TypeScript 开发，通过 Docker 容器化部署，适用于家庭私有网络环境下的日常穿搭规划与衣橱数字化管理。",2,"2026-11-24 04:32:35","CREATED_QUERY"]