A serverless backend service for generating AI-powered study notes and research summaries. This project uses AWS Lambda functions to create an asynchronous processing pipeline that generates comprehensive study materials from topic inputs.
- Asynchronous Processing: Submit study topics and receive AI-generated notes when ready
- RESTful API: Clean HTTP endpoints for task management
- Queue-based Architecture: Uses AWS SQS for reliable message processing
- Real-time Notifications: SNS integration for completion alerts
- Scalable Storage: DynamoDB for persistent data storage
- CORS Support: Ready for frontend integration
The system consists of two main Lambda functions:
Handles HTTP requests and provides the following endpoints:
POST /tasks- Create a new study note taskGET /tasks- List all tasks with paginationGET /tasks/{id}- Get specific task details including generated contentDELETE /tasks/{id}- Delete a task
Processes tasks from the SQS queue:
- Consumes messages from SQS
- Calls OpenAI API to generate study notes
- Updates task status in DynamoDB
- Sends completion notifications via SNS
POST /tasks
Content-Type: application/json
{
"topic": "Machine Learning Fundamentals"
}Response:
{
"id": "uuid",
"topic": "Machine Learning Fundamentals",
"status": "QUEUED",
"createdAt": "2024-01-01T00:00:00.000Z"
}GET /tasks?limit=25&cursor=base64_encoded_cursorResponse:
{
"items": [
{
"id": "uuid",
"topic": "Machine Learning Fundamentals",
"status": "DONE",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:01:00.000Z"
}
],
"cursor": "base64_encoded_cursor"
}GET /tasks/{id}Response:
{
"id": "uuid",
"topic": "Machine Learning Fundamentals",
"status": "DONE",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:01:00.000Z",
"researchMd": "# Machine Learning Fundamentals\n\n## Overview\n..."
}DELETE /tasks/{id}Response: 204 No Content
TABLE_NAME- DynamoDB table name for storing tasksQUEUE_URL- SQS queue URL for task processing
TABLE_NAME- DynamoDB table name for storing tasksSNS_TOPIC_ARN- SNS topic ARN for completion notificationsOPENAI_API_KEY- OpenAI API key for generating contentOPENAI_PROMPT_ID- OpenAI prompt template ID
- QUEUED - Task created and added to processing queue
- PROCESSING - Worker function is generating the study notes
- DONE - Study notes generated successfully
- ERROR - Processing failed (check error field for details)
- AWS Lambda - Serverless compute for API and worker functions
- Amazon DynamoDB - NoSQL database for task storage
- Amazon SQS - Message queue for asynchronous processing
- Amazon SNS - Notification service for task completion alerts
- OpenAI API - AI service for generating study notes
ai-studynotes-backend/
├── api-function/
│ └── index.js # API Lambda function
├── worker-function/
│ └── index.js # Worker Lambda function
├── LICENSE # GNU GPL v3 License
└── README.md # This file
This project is designed to be deployed on AWS using serverless frameworks like:
- AWS SAM (Serverless Application Model)
- Serverless Framework
- AWS CDK (Cloud Development Kit)
- AWS CLI configured
- Node.js runtime
- AWS Lambda deployment tools
- DynamoDB table with GSI
byCreatedAt - SQS queue for task processing
- SNS topic for notifications
- IAM roles with appropriate permissions
- CORS headers configured for cross-origin requests
- Input validation on all endpoints
- Error handling with appropriate HTTP status codes
- Secure environment variable management
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For questions or issues, please open an issue in the repository or contact the maintainers.
Note: This backend service requires proper AWS infrastructure setup and OpenAI API credentials to function correctly.