Download replit.md from surekim/tars: direct link, hf CLI and curl.
- Browser
- Download file 8.49 kB
-
https://huggingface.co/spaces/surekim/tars/resolve/main/replit.md
- Command line
-
hf download hf://spaces/surekim/tars/replit.md
-
curl -L -o replit.md https://huggingface.co/spaces/surekim/tars/resolve/main/replit.md
Ai&R System v1.1
Overview
This is an AI-powered music A&R (Artists & Repertoire) analysis tool called "The Ai&R System." It uses a Dual-Model Orchestration pipeline with a Two-Stage Workflow:
Stage 1 ("The Breach"): Gemini Flash extracts Sonic DNA (quantitative audio features, X-Factor keywords, primary reference artist, technical profiles) β Groq generates Suno v4 style tags and 3 suggested song titles. No lyrics generated at this stage.
Stage 2 ("The Synthesis"): User selects a title β Groq generates full anti-cringe lyrics (24+ lines) with reference artist vocal branding and X-Factor metatag injection. If Groq fails, Gemini handles everything as a fallback.
The app is a full-stack TypeScript monorepo with a React frontend and Express backend, backed by PostgreSQL for storing analysis history. Apple-style minimalist black UI with action-first layout (Copy Suno Prompt, Copy Lyrics, Go to Suno buttons at top).
User Preferences
Preferred communication style: Simple, everyday language.
System Architecture
Monorepo Structure
client/β React SPA (Vite + TypeScript)server/β Express API server (TypeScript, runs via tsx)shared/β Shared types, schemas, and route definitions used by both client and servermigrations/β Drizzle-generated database migrationsattached_assets/β Reference documents (prompt engineering specs, UI mockups)
Frontend Architecture
- Framework: React 18 with TypeScript, bundled by Vite
- Routing: Wouter (lightweight client-side router)
- State/Data Fetching: TanStack React Query for server state management
- UI Components: shadcn/ui (new-york style) built on Radix UI primitives with Tailwind CSS
- Animations: Framer Motion for reveal effects and log animations
- Icons: Lucide React
- Styling: Tailwind CSS with CSS variables for theming. Dark-only monochromatic theme (pure black background, white text, green accents). Uses three font families: Inter (sans), Newsreader (serif), Geist Mono (monospace).
- Key Pages: Home page (
/) is the main analysis interface; Pricing page (/pricing); Help page (/help); 404 page for unknown routes - Path Aliases:
@/maps toclient/src/,@shared/maps toshared/
Backend Architecture
- Framework: Express.js on Node.js with TypeScript
- API Pattern: Routes defined in
shared/routes.tsas a typed contract (method, path, input/output schemas via Zod). Both client and server reference the same route definitions. - AI Integration: Dual-Model Orchestration with efficient fallback
- Gemini Flash (Analyst): Extracts raw Music Observation via
@google/genai, accessed through Replit AI Integrations (AI_INTEGRATIONS_GEMINI_API_KEYandAI_INTEGRATIONS_GEMINI_BASE_URL) - Groq Llama-3.3-70b (Architect & Poet): Stage 1 generates Suno tags and 3 suggested titles. Stage 2 generates full lyrics for a selected title. Uses
groq-sdk(GROQ_API_KEYenv var) - Fallback: If Groq fails, Gemini Architect Fallback reuses existing Gemini observation data (no re-call). If no Groq API key, Gemini Unified mode handles everything.
- Spotify Integration (
server/spotify.ts): Searches Spotify for artist/track, retrieves audio features (if API allows), artist genres, popularity, album art. Real audio features override Gemini estimates for Deep Scan. Connected via Replit Connector. - Helpers:
safeParseJson()centralized JSON parsing,generateWithGroq()/generateWithGemini()shared AI wrappers,validateArchitectOutput()post-parse validation,trimForResponse()strips non-UI fields from API response (full data stored in DB),enrichWithSpotify()merges Spotify data into sonicDna
- Gemini Flash (Analyst): Extracts raw Music Observation via
- Dev Server: Vite dev server is used as middleware in development (HMR via
server/vite.ts); static files served in production fromdist/public - Build: Custom build script (
script/build.ts) β Vite builds the client, esbuild bundles the server intodist/index.cjs
API Endpoints
POST /api/analyzeβ Stage 1 endpoint. AcceptstargetArtist(required). Runs dual-model pipeline: Gemini extracts Sonic DNA β Groq generates Suno tags and 3 suggested titles. Returns structured JSON with sonicDna (tags, suggestedTitles, audioFeatures, highImpactKeywords, primaryReferenceArtist) and pipeline indicator. Response includespipelinefield: "dual", "gemini-fallback", or "gemini-only". Note: Suno tags do NOT include artist names.POST /api/generate-lyricsβ Stage 2 endpoint. AcceptsselectedTitle(string) andsonicDna(full sonic DNA from Stage 1). Generates full anti-cringe lyrics (24+ lines) with reference artist vocal branding. Returns{ sunoScript: string }.GET /api/historyβ Returns all past analysis results ordered by creation date (newest first)
Replit AI Integrations (Pre-built Modules)
Located in server/replit_integrations/:
- chat/ β Generic chat conversation routes with Gemini (conversations + messages CRUD)
- image/ β Image generation endpoint using
gemini-2.5-flash-image - batch/ β Batch processing utilities with rate limiting, retries, and concurrency control
These are supplementary modules. The main analysis feature uses Gemini directly in server/routes.ts.
Database
- Database: PostgreSQL (required, via
DATABASE_URLenvironment variable) - ORM: Drizzle ORM with
drizzle-zodfor schema-to-validation integration - Schema (
shared/schema.ts):analysis_resultstable:id(serial PK),target_artist(text),reference_artist(text),sonic_dna(jsonb β stores tags, BPM, key, instruments, etc.),narrative(text),created_at(timestamp)
- Additional schemas (
shared/models/chat.ts):conversationstable:id,title,created_atmessagestable:id,conversation_id(FK to conversations),role,content,created_at
- Migrations: Use
npm run db:push(drizzle-kit push) to sync schema to database - Storage Layer:
server/storage.tsβDatabaseStorageclass implementsIStorageinterface withcreateAnalysis()andgetHistory()methods
Key Design Decisions
- Shared route contracts β Route definitions with Zod schemas in
shared/routes.tsensure type safety across client-server boundary - JSONB for Sonic DNA β The analysis output from Gemini is complex nested JSON; storing as JSONB allows flexible querying without rigid column structure
- Gemini JSON cleaning β The backend strips markdown code blocks (
```json) from both Gemini and Groq responses before parsing - Dual-Model Orchestration β Gemini as Analyst (data extraction) + Groq as Architect (creative generation) with automatic fallback
- Interscope Deep Scan β 5 circular audio feature gauges (Energy, Valence, Acousticness, Danceability, Instrumentalness) scored 0.0-1.0. Uses Spotify real data when available (with green "Live" badge), falls back to Gemini estimation
- Replit Auth β Google login via Replit OpenID Connect (passport-based). Users table has credits, freeUsesRemaining, totalAnalyses columns. Freemium model: 3 free analyses, then 10 credits per analysis. Auth middleware on
/api/analyze. Credits endpoint atGET /api/credits.
External Dependencies
Required Services
- PostgreSQL Database β Connection string via
DATABASE_URLenvironment variable. Required for all data persistence. - Google Gemini AI (via Replit AI Integrations) β Two environment variables required:
AI_INTEGRATIONS_GEMINI_API_KEYβ API key for GeminiAI_INTEGRATIONS_GEMINI_BASE_URLβ Base URL for the Gemini-compatible endpoint- Model used:
gemini-2.5-flash(Analyst role)
- Groq AI β Environment variable required:
GROQ_API_KEYβ API key for Groq- Model used:
llama-3.3-70b-versatile(Architect & Poet role)
Key NPM Dependencies
@google/genaiβ Google Gemini AI clientgroq-sdkβ Groq AI client (Llama 3.3 70B)drizzle-orm+drizzle-kit+drizzle-zodβ Database ORM and migration toolingexpress+connect-pg-simpleβ HTTP server and session store@tanstack/react-queryβ Client-side data fetchingframer-motionβ UI animationswouterβ Client-side routingzodβ Schema validation (shared between client and server)shadcn/uiecosystem β Radix UI primitives, Tailwind CSS, class-variance-authority, clsx, tailwind-merge