A modern web interface for AI-powered music generation using KIE AI's API
Create beautiful, AI-generated music with an intuitive project-based interface. Organize your generations, track progress in real-time, and manage multiple music projectsโall powered by cutting-edge AI technology.
- ๐จ Project-Based Organization - Group your music generations into projects
- โก Real-Time Updates - Server-Sent Events (SSE) for live generation status
- ๐ต Dual Track Generation - Each generation produces two unique variants
- ๐๏ธ Stem Separation - Vocal removal / stem splitting with live status updates
- ๏ฟฝ Import Existing Songs - Import previously generated songs by Task ID
- ๏ฟฝ๐ Smart Polling - Automatic status updates with the KIE AI API
- ๐พ Local SQLite Storage - Fast, reliable data persistence with WAL mode
- ๐ฏ Form Pre-filling - Quickly iterate on previous generations
- ๐ญ Modern UI - Built with Svelte 5 and Tailwind CSS v4
- ๐ฑ Responsive Design - Works seamlessly across devices
Before you begin, ensure you have:
- Bun v1.0 or higher installed
- A KIE AI API key (obtain from KIE AI)
- Node.js 20+ (for compatibility checks)
-
Clone the repository
git clone https://github.com/MichaelBailly/kie-frontend.git cd kie-frontend -
Install dependencies
bun install
-
Configure environment variables
Create a
.envfile in the project root:KIE_API_KEY=your_kie_api_key_here
โ ๏ธ Important: Never commit your API key to version control! -
Start the development server
bun run dev
The app will be available at
http://localhost:5173
| Command | Description |
|---|---|
bun run dev |
Start development server with hot reload |
bun run build |
Build for production |
bun run preview |
Preview production build locally |
bun run check |
Run TypeScript type checking |
bun run check:watch |
Type check in watch mode |
bun run format |
Format code with Prettier |
bun run lint |
Lint code with ESLint and Prettier |
bun run test |
Run all tests (CI mode) |
bun run test:unit |
Run tests in watch mode |
- Make your changes in the
src/directory - Run type checking:
bun run check - Format your code:
bun run format - Lint your code:
bun run lint - Run tests:
bun run test - Commit following conventional commit patterns
kie-frontend/
โโโ src/
โ โโโ lib/
โ โ โโโ components/ # Svelte components
โ โ โโโ assets/ # Static assets
โ โ โโโ db.server.ts # SQLite database operations
โ โ โโโ kie-api.server.ts # KIE AI API integration
โ โ โโโ sse.server.ts # Server-Sent Events management
โ โ โโโ types.ts # Shared TypeScript types
โ โ โโโ constants.server.ts # Server-only constants
โ โโโ routes/
โ โ โโโ +layout.svelte # Root layout
โ โ โโโ +page.server.ts # Home page (redirects to first project)
โ โ โโโ projects/
โ โ โ โโโ [projectId]/ # Project detail pages
โ โ โโโ api/
โ โ โโโ generations/ # Generation endpoints (+ extend)
โ โ โโโ import/ # Import existing songs endpoint
โ โ โโโ projects/ # Project CRUD endpoints
โ โ โโโ stem-separation/ # Stem separation endpoint
โ โ โโโ sse/ # SSE endpoint
โ โ โโโ layout.css # Tailwind CSS imports
โ โโโ app.html # HTML template
โโโ static/ # Public static files
โโโ package.json
โโโ svelte.config.js # SvelteKit configuration
โโโ vite.config.ts # Vite & Vitest configuration
โโโ tsconfig.json # TypeScript configuration
- SvelteKit - Full-stack framework with file-based routing
- Svelte 5 - Reactive UI with modern runes API
- TypeScript - Type-safe development
- Tailwind CSS v4 - Utility-first CSS framework
- @tailwindcss/forms - Beautiful form styles
- @tailwindcss/typography - Prose styling
- Bun SQLite - Fast, embedded database with WAL mode
- Server-Sent Events (SSE) - Real-time updates from server to client
- Bun - Fast all-in-one JavaScript runtime
- Vite - Lightning-fast build tool
- Vitest - Unit testing with Playwright browser support
- ESLint - Code linting with flat config
- Prettier - Code formatting
- @sveltejs/adapter-node - Node.js production server
The app uses Server-Sent Events for live updates:
- Client connects to
/api/sseon page load - Server broadcasts generation status changes to all clients
- UI updates automatically without polling
// Client-side SSE subscription (automatic in layouts)
const eventSource = new EventSource('/api/sse');
eventSource.onmessage = (event) => {
// The server sends default "message" events containing JSON with a `type` field
const message = JSON.parse(event.data);
if (message.type === 'generation_update' || message.type === 'generation_complete') {
console.log('Generation update:', message.generationId, message.data);
}
};Generation workflow:
- Request - User submits title, style, and lyrics
- Task Creation - Server calls KIE AI to create generation task
- Polling - Server polls KIE API every 5 seconds (max 10 minutes)
- Status Updates - Progress flows:
PENDINGโTEXT_SUCCESSโFIRST_SUCCESSโSUCCESS - Notification - SSE broadcasts updates to all connected clients
- Storage - Final URLs and metadata saved to SQLite
- SQLite with WAL mode for concurrent reads during writes
- Development: Database stored at
./kie-music.db - Production: Database stored at
/data/kie-music.db - Schema: Projects with one-to-many Generations relationship
The project uses Vitest with two test suites:
- Client tests (
*.svelte.{test,spec}.ts) - Browser tests with Playwright - Server tests (
*.{test,spec}.ts) - Node.js unit tests
Run tests:
# All tests (CI mode)
bun run test
# Watch mode
bun run test:unit
# Type checking
bun run check๐ก Note: Browser tests require Playwright. If tests fail locally, run:
npx playwright install npx playwright install-deps # Linux only
bun run buildThis creates an optimized build in the build/ directory.
# Set environment variables
export KIE_API_KEY=your_production_api_key
# Start the server (preview mode)
bun run preview
# Or run the built Node.js server directly
node build/index.js- Ensure
/datadirectory exists and is writable for SQLite database - Set
KIE_API_KEYenvironment variable - The app uses
@sveltejs/adapter-nodefor production deployment - Database will be created at
/data/kie-music.dbin production mode
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following the project conventions
- Run linting and tests:
bun run format bun run lint bun run test - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code patterns
- Use Svelte 5 runes (
$props(),$state(),$derived()) - Server-only code must use
.server.tssuffix - Run
bun run formatbefore committing
This project is open source and available under the MIT License.
- KIE AI - For providing the music generation API
- Svelte - For the amazing framework
- Bun - For the blazing-fast runtime
Having issues or questions?
- ๐ Report a bug
- ๐ก Request a feature
- ๐ฌ Start a discussion