A serverless API that generates daily horoscopes using OpenAI's 4o-mini model. Built with AWS Lambda and DynamoDB, supporting both English and Polish languages.
- Daily horoscope generation for all zodiac signs
- Support for English and Polish languages
- Serverless architecture using AWS Lambda
- DynamoDB for data storage
- OpenAI integration
- CORS enabled
- TypeScript for type safety
- Node.js (v18 or higher)
- AWS Account
- AWS CLI configured
- OpenAI API key
- Serverless Framework CLI
- Clone the repository:
git clone <repository-url>
cd zodiakara- Install dependencies:
npm install- Configure AWS credentials:
aws configure- Set up environment variables:
export OPENAI_API_KEY="your-api-key-here"To build the project:
npm run buildTo deploy to AWS Lambda:
- Deploy to development stage:
npm run deploy- Deploy to production stage:
npm run deploy:prodThe deployment will create:
- DynamoDB table
- Two Lambda functions
- API Gateway endpoints
- Required IAM roles and permissions
GET /horoscopes/all?lang=en|pl
Returns all horoscopes for the current day in the specified language (defaults to English if not specified).
GET /horoscopes/{sign}?lang=en|pl
Returns the horoscope for a specific zodiac sign in the specified language (defaults to English if not specified).
Available signs:
- aries
- taurus
- gemini
- cancer
- leo
- virgo
- libra
- scorpio
- sagittarius
- capricorn
- aquarius
- pisces
The API supports two languages:
- English (en) - default
- Polish (pl)
To get horoscopes in Polish, add ?lang=pl to the URL. For English, either omit the parameter or use ?lang=en.
This setup can be completely free within AWS Free Tier limits:
-
Lambda:
- 1 million free requests/month
- 400,000 GB-seconds of compute time/month
- More than enough for this use case
-
DynamoDB:
- 25 GB storage
- 25 Write Capacity Units (WCUs)
- 25 Read Capacity Units (RCUs)
- Sufficient for storing daily horoscopes
-
API Gateway:
- 1 million free requests/month
- More than enough for this use case
The only cost you'll incur is from OpenAI API usage.
You can monitor your Lambda functions and DynamoDB usage through the AWS Console:
- Lambda: CloudWatch Logs and Metrics
- DynamoDB: CloudWatch Metrics
- API Gateway: CloudWatch Logs
ISC