Skip to content

adarshrkumar/H4H-26-Project-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

166 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Huephonics

Huephonics - Audio visualization powered by mood color (Astro, TypeScript, Drizzle, SCSS, Vercel AI SDK).

πŸš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0
  • Neon PostgreSQL account (database)
  • API keys for OpenAI, ElevenLabs, and UploadThing

Installation

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Configure your .env file with your credentials

Environment Variables

Create a .env file with the following variables:

# Neon PostgreSQL (database)
DATABASE_URL="postgresql://user:password@host/database"

# OpenAI (for Vercel AI SDK)
OPENAI_API_KEY="sk-..."

# ElevenLabs (music generation)
ELEVENLABS_API_KEY="sk_..."

# UploadThing (file storage)
UPLOADTHING_TOKEN="..."

# Optional
VITE_APP_URL="http://localhost:5173"

Development

# Start dev server
npm run dev

Visit http://localhost:4321

πŸ“ Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run astro - Run Astro CLI commands
  • npm run test - Run E2E tests

πŸ“ Project Structure

src/
β”œβ”€β”€ components/         # Reusable Astro components
β”œβ”€β”€ db/                 # Database client and types
β”‚   β”œβ”€β”€ initialize.ts   # Drizzle client with Neon HTTP
β”‚   β”œβ”€β”€ schema.ts       # Drizzle table definitions
β”‚   β”œβ”€β”€ helpers.ts      # Database query helpers
β”‚   └── validations.ts  # Zod schemas
β”œβ”€β”€ layouts/            # Page layouts
β”‚   └── Layout.astro
β”œβ”€β”€ lib/                # Utility libraries
β”‚   β”œβ”€β”€ config.ts       # App configuration
β”‚   β”œβ”€β”€ content-converter.ts # Markdown/HTML conversion
β”‚   └── dom-utils.ts    # DOM manipulation
β”œβ”€β”€ pages/              # Routes and pages
β”‚   β”œβ”€β”€ api/            # API endpoints
β”‚   └── index.astro     # Home page
└── styles/             # SCSS stylesheets
    β”œβ”€β”€ variables/      # SCSS variables and mixins
    β”œβ”€β”€ components/     # Component styles
    β”œβ”€β”€ pages/          # Page styles
    β”œβ”€β”€ reset.scss      # CSS reset
    └── global.scss     # Global styles

🎨 SCSS Architecture

This app uses a strict SCSS architecture:

  • No inline <style> tags in .astro files
  • All styles in external SCSS files for better maintainability
  • Data attributes for modifiers (preferred over BEM)
  • Semantic class names (no utility classes)

Example:

---
import '@/styles/components/button.scss';
---
<button class="btn" data-variant="primary" data-size="lg">
    Click Me
</button>

πŸ—„οΈ Database

Database is handled by Drizzle ORM with Neon PostgreSQL. Define your schema in src/db/schema.ts:

import { pgTable, text, integer, timestamp } from 'drizzle-orm/pg-core';

export const music = pgTable('music', {
    id: text('id').primaryKey(),
    title: text('title'),
    duration: integer('duration'),
    createdAt: timestamp('created_at').defaultNow(),
});

Query and mutate data using helpers in src/db/helpers.ts.

πŸ€– AI Features

Vercel AI SDK

Chat and text generation powered by Vercel AI SDK.

Music Generation

ElevenLabs API for music generation.

File Storage

UploadThing for reliable file uploads and storage.

πŸš€ Deployment

Vercel (Recommended)

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

Make sure to set these environment variables in your Vercel project settings:

  • DATABASE_URL
  • OPENAI_API_KEY
  • ELEVENLABS_API_KEY
  • UPLOADTHING_TOKEN

πŸ“š Documentation

πŸ› οΈ Utilities

Content Conversion

import { htmlToMarkdown, markdownToHtml } from '@/lib/content-converter';

const markdown = htmlToMarkdown('<h1>Hello</h1>');
const html = markdownToHtml('# Hello');

Database Queries

import { createRecording, getRecording, updateRecording } from '@/db/helpers';

const music = await createRecording(data);
const existing = await getRecording(id);
await updateRecording(id, updates);

πŸ“„ License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors