Somni is a beautiful web application that creates personalized children's stories using AI and reads them aloud in a cloned voice of a loved one. Perfect for when parents travel or simply want to create magical bedtime moments.
- AI Story Generation - Create unique, age-appropriate bedtime stories using GPT-4
- Voice Cloning - Clone a parent's voice using ElevenLabs for personalized narration
- Beautiful UI - Dreamy, child-friendly design with night mode for bedtime reading
- Story Library - Save and organize all your stories in one place
- Personalization - Include your child's name to make them the hero of every story
- Age Groups - Stories tailored for toddlers (1-3), preschoolers (3-5), early readers (5-7), and chapter book readers (7-10)
- Node.js 18+
- PostgreSQL database
- OpenAI API key
- ElevenLabs API key
-
Clone the repository
git clone https://github.com/yourusername/somni.git cd somni -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Then edit
.envwith your credentials:DATABASE_URL- Your PostgreSQL connection stringAUTH_SECRET- Generate withopenssl rand -base64 32OPENAI_API_KEY- Get from OpenAI PlatformELEVENLABS_API_KEY- Get from ElevenLabs
-
Set up the database
npx prisma migrate dev --name init npx prisma generate
-
Start the development server
npm run dev
-
Open your browser
Visit http://localhost:3000
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth.js v5
- Styling: Tailwind CSS
- AI: OpenAI GPT-4
- Voice: ElevenLabs
- Animations: Framer Motion
somni/
├── src/
│ ├── app/
│ │ ├── (auth)/ # Auth pages (login, register)
│ │ ├── (dashboard)/ # Protected pages (dashboard, create, stories, voices)
│ │ ├── api/ # API routes
│ │ │ ├── auth/ # Authentication endpoints
│ │ │ ├── stories/ # Story CRUD & audio generation
│ │ │ └── voices/ # Voice cloning management
│ │ ├── globals.css # Global styles & design system
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Landing page
│ ├── components/ # Reusable components
│ ├── lib/ # Utilities & integrations
│ │ ├── auth.ts # NextAuth configuration
│ │ ├── prisma.ts # Prisma client
│ │ ├── openai.ts # Story generation
│ │ └── elevenlabs.ts # Voice cloning & TTS
│ └── types/ # TypeScript type definitions
├── prisma/
│ └── schema.prisma # Database schema
└── public/ # Static assets
Somni uses a dreamy, calming color palette perfect for bedtime:
- Night:
#1a1b2e- Deep background - Twilight:
#2d2f4e- Secondary background - Lavender:
#9b8dc7- Primary accent - Golden:
#ffd166- Call-to-action - Coral:
#ff8fa3- Warm accents - Mint:
#7dd3c0- Success states
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/stories |
Get all user stories |
| POST | /api/stories |
Create a new story |
| GET | /api/stories/[id] |
Get a specific story |
| DELETE | /api/stories/[id] |
Delete a story |
| POST | /api/stories/[id]/audio |
Generate audio for story |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/voices |
Get all user voices |
| POST | /api/voices |
Clone a new voice |
| DELETE | /api/voices/[id] |
Delete a cloned voice |
- Passwords are hashed using bcrypt
- JWT-based session management
- API routes are protected with authentication middleware
- User data is isolated per account
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the magic of bedtime storytelling
- Built with love for families everywhere
- Thanks to OpenAI and ElevenLabs for their amazing APIs
Made with 💜 for bedtime dreamers everywhere