A Next.js application for AI-generated predictions from celebrity personas.
This project uses OpenAI's API for generating predictions. To set up your environment:
-
Copy
.env.exampleto.env.local:cp .env.example .env.local
-
Edit
.env.localand replace the placeholder with your OpenAI API key:OPENAI_API_KEY=your-actual-api-key-here
Note: The .env.local file is automatically excluded from Git to protect your API key. Each developer needs to create their own local copy.
This project is containerized with Docker for consistent development and deployment:
-
Make sure you have Docker and Docker Compose installed
-
Build and start the containers:
docker-compose up -d
-
The application will be available at http://localhost:3000
-
To pass your OpenAI API key to the container, either:
- Add it to your
.env.localfile which is mounted to the container - Or set it directly in the
docker-compose.ymlfile:environment: - OPENAI_API_KEY=your-api-key-here
- Add it to your
-
To stop the containers:
docker-compose down
If you prefer to run without Docker:
npm run dev
# or
yarn devOpen http://localhost:3000 with your browser to see the result.
- Choose from multiple celebrity personas for predictions
- Real-time prediction generation using OpenAI API
- Responsive design for mobile and desktop
- Next.js 14 with App Router
- React and TypeScript
- Redux for state management
- Tailwind CSS for styling
- Prisma ORM with SQLite database
- UUID for user identification
- Docker for containerization
- Jest and React Testing Library for testing
The application exposes the following API endpoints:
- POST /api/predictions
- Generates a prediction based on user input and selected celebrity
- Requires
question,starId, anduserIdin the request body - Stores the prediction history in the database
- GET /api/history?userId={userId}
- Returns all prediction history for a specific user
- Example:
http://localhost:3000/api/history?userId=123e4567-e89b-12d3-a456-426614174000
- DELETE /api/clear-history?userId={userId}
- Deletes all prediction history for a specific user
- Useful for maintaining privacy or starting fresh conversations
This project uses Jest and React Testing Library for unit tests.
To run all tests:
npm testTo run in watch mode:
npm run test:watchTo generate a coverage report:
npm run test:coverage