A static site for organizing and browsing Midjourney style references (srefs). Built with Astro, featuring filesystem-based storage for easy Git management and instant client-side search.
π€ Now with Discord Bot Integration! Add Midjourney images directly from Discord via context menu commands.
- π Filesystem-based - All data stored as YAML and images, no database needed
- π Instant Search - Client-side fuzzy search with Fuse.js
- π·οΈ Tag Filtering - Filter by multiple tags
- πΌοΈ Automatic Image Processing - Dimensions extracted at build time
- π± Responsive Design - Works on all devices
- π Static Site - Deploy anywhere that serves HTML
- π€ Discord Bot - Add srefs directly from Midjourney messages
- π Tag Analytics - Built-in utility to analyze tag usage and cleanup
- π GitHub Integration - Edit on GitHub link for easy contribution
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build- Set up the Discord bot (see Discord Bot Setup)
- In Discord, right-click any Midjourney Bot message
- Select "Apps" β "Add to Sref Database"
- Fill out the modal with title and tags
- Bot automatically downloads image and creates sref structure
- Rebuild site:
npm run build
- Create a new directory in
src/data/srefs/namedsref-[id] - Add a
meta.yamlfile:
id: "12345678"
title: "Your Style Name"
description: "Description of the style"
tags:
- tag1
- tag2
cover_image: "cover.jpg"
images:
- filename: "example1.jpg"
prompt: "example prompt --sref 12345678"- Add images to
src/data/srefs/sref-[id]/images/ - Build the site:
npm run build(includes S3 sync and image processing)
This project uses AWS S3 for scalable image storage and CloudFront for fast global delivery, replacing Git LFS.
# 1. Deploy AWS infrastructure
cd terraform && AWS_PROFILE=srefs terraform apply
# 2. Update GitHub repository variables with Terraform outputs- Build Pipeline:
npm run buildsyncs from S3 β processes images β uploads to S3 - Image Processing: Creates optimized AVIF/WebP thumbnails and gallery images
- CDN Delivery: CloudFront serves processed images with global caching
- No Git LFS: All images stored in S3, dramatically reducing repository size
Use the built-in tag analysis utility to understand and manage your collection's tags:
npx tsx scripts/analyze-tags.tsThis shows:
- Complete tag usage statistics
- Tags with low usage (candidates for cleanup)
- Which srefs use each tag
- Usage distribution across your collection
Perfect for identifying inconsistent tags or finding underutilized categories.
-
Create Discord Application:
- Go to Discord Developer Portal
- Create a new application and bot
- Copy bot token and application ID
-
Configure Environment:
cp .env.example .env # Edit .env with your DISCORD_TOKEN and DISCORD_CLIENT_ID -
Invite Bot to Server:
- In Discord Developer Portal β OAuth2 β URL Generator
- Select scopes:
botandapplications.commands - Select permissions:
Read MessagesandUse Application Commands - Use generated URL to invite bot to your server
-
Start Bot:
npm run bot:dev # Development mode with file watching npm run bot:start # Production mode
/
βββ public/
β βββ data/
β βββ srefs/ # Style reference data
β βββ sref-[id]/
β βββ meta.yaml # Metadata
β βββ images/ # Image files
βββ src/
β βββ bot/ # Discord bot integration
β β βββ commands/ # Context menu commands
β β βββ handlers/ # Message processing
β β βββ utils/ # Bot utilities
β βββ pages/ # Astro pages
β βββ components/ # React and Astro components
β βββ layouts/ # Page layouts
β βββ lib/ # Utilities and data loading
βββ scripts/ # Utility scripts (tag analysis, etc.)
βββ tests/ # Test files and fixtures
βββ dist/ # Built static site
| Command | Description |
|---|---|
npm run dev |
Start development server at localhost:4321 |
npm run build |
Build static site to ./dist/ |
npm run preview |
Preview production build |
npm test |
Run tests |
npm run test:coverage |
Run tests with coverage report |
| Command | Description |
|---|---|
npm run bot:dev |
Start bot in development mode (with file watching) |
npm run bot:start |
Start bot in production mode |
| Command | Description |
|---|---|
npx tsx scripts/analyze-tags.ts |
Analyze tag usage statistics and find low-usage tags |
The project includes comprehensive tests for data loading, search functionality, build process, and Discord bot integration:
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:ui # Interactive UI
npm run test:coverage # Coverage report
npm test src/bot # Run only bot testsTest Coverage:
- Site functionality: 100% coverage on SearchClient component
- Bot functionality: 98.41% coverage on utilities and handlers
- Integration tests for complete workflows
The repository includes automated CI/CD via GitHub Actions:
- Automatic Testing: Every push/PR runs full test suite
- Automatic Building: Successful tests trigger Astro build
- Automatic Deployment: Built site deploys to GitHub Pages
Setup GitHub Pages:
- Go to repository Settings β Pages
- Set Source to "GitHub Actions"
- Push to
mainbranch to trigger deployment
Live Site: https://jtatum.github.io/srefs
The built site in dist/ can also be manually deployed to:
- Netlify (drag & drop the dist folder)
- Vercel
- Any static hosting service
Site:
- Astro - Static site generator
- React - Search component
- Tailwind CSS - Styling
- Fuse.js - Fuzzy search
- Sharp - Image processing
Discord Bot:
- Discord.js - Discord API integration
- tsx - TypeScript execution for development
Development:
- Vitest - Testing framework
- TypeScript - Type safety
MIT