You are tasked with creating an intelligent book management system using Python, a locally running Llama3 generative AI model, and AWS cloud infrastructure. The system should allow users to add, retrieve, update, and delete books from a PostgreSQL database, generate summaries for books using the Llama3 model, and provide book recommendations based on user preferences. Additionally, the system should manage user reviews and generate rating and review summaries for books. The system should be accessible via a RESTful API and deployed on AWS.
- Database Setup: Use PostgreSQL to store book and review information. The `books` table should contain `id, title, author, genre, year_published, summary`. The `reviews` table should contain `id, book_id, user_id, review_text, rating`.
- Llama3 Model Integration: Set up a locally running Llama3 model to generate summaries for new book entries and to summarize user reviews for a given book.
- Machine Learning Model: Develop a recommendation model based on book genre and average rating.
- RESTful API: Develop a complete RESTful API using a framework like FastAPI or Flask with full CRUD functionality for books and reviews, plus endpoints for recommendations and summaries.
- Asynchronous Programming: Implement asynchronous operations for database interactions (using `sqlalchemy[asyncio]` and `asyncpg`) and AI model predictions to ensure a non-blocking, high-performance API.
- AWS Deployment: Deploy the application on AWS infrastructure, using RDS for the database and services like EC2, Lambda, or ECS for the application. Use S3 for model storage if needed. A CI/CD pipeline should be set up for automated deployments.
- Authentication and Security: Implement basic API authentication and ensure secure communication throughout the stack.
| Method | Endpoint | Description |
|---|---|---|
| POST | /books |
Add a new book to the database. |
| GET | /books |
Retrieve a list of all books. |
| GET | /books/{id} |
Retrieve a specific book by its ID. |
| PUT | /books/{id} |
Update a book's information. |
| DELETE | /books/{id} |
Delete a book from the database. |
| POST | /books/{id}/reviews |
Add a review for a specific book. |
| GET | /books/{id}/reviews |
Retrieve all reviews for a specific book. |
| GET | /books/{id}/summary |
Get an AI-generated summary and aggregated rating. |
| GET | /recommendations |
Get personalized book recommendations. |
| POST | /generate-summary |
Generate a summary for a given text content. |
- Implement caching for book recommendations using AWS ElastiCache to improve response times.
- Add unit and integration tests for the API endpoints and AI model interactions.
- Utilize AWS SageMaker for deploying and managing the machine learning recommendation model.
Instructions
- Database Schema: Define and provide the SQL schema for the `books` and `reviews` tables.
- Llama3 Integration: Set up a local Llama3 instance and implement the logic for generating summaries.
- Model Training: Train the recommendation model and save the artifact for inference.
- API Development: Develop the asynchronous RESTful API.
- AWS Deployment: Deploy the full application stack on AWS.
- Testing & Documentation: Write unit tests and provide clear API documentation (e.g., via Swagger UI from FastAPI).
Deliverables
The final submission should include the complete source code, deployment instructions, and a link to the live, deployed application.
The solution will be evaluated based on correctness, efficiency, proper use of asynchronous programming, effective implementation of both the generative AI and recommendation models, quality and security of the RESTful API, successful cloud deployment, and the overall quality of testing and documentation.