A Next.js application that generates motivational quotes about Saint Elizabeth Feodorovna using OpenAI's GPT API.
This app generates short motivational quotes (120-150 characters) about Saint Elizabeth Feodorovna, a Russian Orthodox saint and great martyr. The app uses:
- Frontend: Next.js 15 with React 19, TypeScript, and CSS modules
- Backend: Next.js API routes that call OpenAI's GPT-3.5-turbo API
- Styling: Custom CSS with beautiful background images and modern UI
The main functionality is in the /api/quote endpoint, which sends a prompt to OpenAI requesting a quote about Saint Elizabeth Feodorovna and returns it to the frontend.
- Node.js 18+
- npm, yarn, pnpm, or bun
- OpenAI API key (get one at https://platform.openai.com/api-keys)
-
Install Node.js and npm:
# Update package list sudo apt update # Install Node.js and npm sudo apt install nodejs npm # Verify installation node --version npm --version
-
Install project dependencies:
# Clone the repository (if not already done) git clone <your-repo-url> cd next-motivation # Install dependencies npm install
- Install Node.js from https://nodejs.org
- Install dependencies:
npm install
-
Copy the environment template:
cp env.example .env
-
Edit the
.envfile and add your OpenAI API key:# Replace with your actual OpenAI API key OPENAI_API_KEY=sk-your-actual-api-key-here -
Get your OpenAI API key:
- Go to https://platform.openai.com/api-keys
- Create a new API key
- Copy it to your
.envfile
npm run devThis will:
- Start the development server with Turbopack for faster builds
- Enable hot reloading (changes appear instantly in the browser)
- Run on http://localhost:3000
- Hot Reloading: Changes to files automatically refresh the browser
- Turbopack: Faster build times and development experience
- TypeScript: Full type checking and IntelliSense support
- ESLint: Code linting for better code quality
Press Ctrl + C in the terminal where the dev server is running.
npm run buildThis creates an optimized production build in the .next folder.
npm startThis starts the production server on http://localhost:3000.
Press Ctrl + C in the terminal where the production server is running.
npm run dev- Start development server with Turbopacknpm run build- Build the app for productionnpm start- Start the production servernpm run lint- Run ESLint to check code quality
next-motivation/
├── src/
│ └── app/
│ ├── api/quote/route.ts # OpenAI API integration
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ ├── page.module.css # Page-specific styles
│ └── page.tsx # Main page component
├── public/
│ └── backgrounds/ # Background images
├── env.example # Environment variables template
├── package.json # Dependencies and scripts
└── README.md # This file
-
"Missing OpenAI API key" error:
- Make sure you've created a
.envfile fromenv.example - Verify your OpenAI API key is correct
- Restart the development server after adding the API key
- Make sure you've created a
-
Port 3000 already in use:
- Kill the process using port 3000:
lsof -ti:3000 | xargs kill -9 - Or use a different port:
npm run dev -- -p 3001
- Kill the process using port 3000:
-
Build errors:
- Clear the
.nextfolder:rm -rf .next - Reinstall dependencies:
rm -rf node_modules && npm install
- Clear the
This project is open source and available under the MIT License.