Welcome to the Intelligent Book Management System, a modern application built with Python and powered by Llama3 AI for book summaries, PostgreSQL for efficient data management, and Machine Learning for personalized recommendations. Deployed on AWS, this system leverages cutting-edge technology to manage books, reviews, and ratings seamlessly. πβ¨
This system allows users to add, retrieve, update, and delete books. Using the power of AI with Llama3, it generates detailed book summaries and review summaries. Our machine learning model further enhances the experience by recommending books based on user preferences, genre, and ratings.
Everything is exposed via a RESTful API, making it easy to integrate with other systems and providing asynchronous operations for enhanced performance.
- AI-Powered Summaries: Llama3 generates insightful summaries for books.
- Machine Learning Recommendations: Personalized recommendations based on genre and ratings.
- RESTful API: Easy-to-use API for interacting with books, reviews, and recommendations.
- PostgreSQL Database: Efficient storage of book and review data.
- AWS Deployment: Cloud infrastructure for scalability and high availability.
- Asynchronous Operations: Optimized for performance with
asyncio
andasyncpg
.
-
Clone the repository:
git clone https://github.com/TravelXML/PYTHON-FASTAPI-AI-LLAM-POSTGRESSQL-AWS-AI.git cd PYTHON-FASTAPI-AI-LLAM-POSTGRESSQL-AWS-AI
-
Set up a virtual environment and install dependencies:
python -m venv env source env/bin/activate pip install -r requirements.txt
-
Set up PostgreSQL and configure your
.env
file with the correct database credentials. -
Run the app locally:
uvicorn app:app --reload
curl --location 'http://localhost:8000/books/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKS1RFU1QiLCJpYXQiOjE3Mjc4NDYwMjEsIm5iZiI6MTcyNzg0NjAyMSwianRpIjoiZTM3ZGI1MTYtY2YyMS00ZWQyLTk0NzMtYmUyZmE4ODZkZDUwIiwiZXhwIjoxNzI3ODQ2OTIxLCJ0eXBlIjoiYWNjZXNzIiwiZnJlc2giOmZhbHNlfQ.-AH9mlxlsaTY9TYiI7L8JtNIMExdxCY4K4jlXYerWs0' \
--data '{"title": "Book Title", "author": "Author Name", "genre": "Fiction", "year_published": 2023, "summary": "Sample summary."}'
-
GET
/books
: Retrieve all books.curl --location 'http://localhost:8000/books/'
-
GET
/books/{id}
: Retrieve a specific book.curl --location 'http://localhost:8000/books/2'
-
PUT
/books/{id}
: Update a book's information.curl --location --request PUT 'http://localhost:8000/books/2' \ --header 'Content-Type: application/json' \ --data '{ "title": "The Catcher in the Rye", "author": "J.D. Salinger", "genre": "Fiction", "year_published": 1951, "summary": "The novel details two days in the life of 16-year-old Holden Caulfield after he has been expelled from prep school." }'
-
DELETE
/books/{id}
: Delete a book.```bash curl --location --request PUT 'http://localhost:8000/books/2' \ --header 'Content-Type: application/json' \ --data '{ "title": "The Catcher in the Rye", "author": "J.D. Salinger", "genre": "Fiction", "year_published": 1951, "summary": "The novel details two days in the life of 16-year-old Holden Caulfield after he has been expelled from prep school." }' ```
-
POST
/books/{id}/reviews
: Add Review.```bash curl --location 'http://localhost:8000/books/2/reviews' \ --header 'Content-Type: application/json' \ --data '{ "user_id": 123, "review_text": "An incredible book with deep insights into politics and humanity.", "rating": 5 }' ```
-
POST
/generate-summary/
: Generate Summarycurl --location 'http://localhost:9000/generate-summary/' \ --header 'Content-Type: application/json' \ --data '{ "content": "This book is a gripping tale of adventure and self-discovery." }'
-
GET
/recommendations
: Get book recommendations based on preferences.curl --location 'http://localhost:8000/recommendations/?book_title=Dune'
@app.post("/books/")
async def create_book(book: BookSchema, db: AsyncSession = Depends(get_db)):
new_book = Book(**book.dict())
db.add(new_book)
await db.commit()
return new_book
This snippet showcases how the app uses FastAPI and asynchronous programming to handle book creation in a PostgreSQL database.
- Set up an AWS account and configure RDS for PostgreSQL.
- Deploy the app on EC2 or use AWS Lambda for serverless architecture.
- Use S3 for model storage (if necessary).
- Set up AWS CloudWatch for monitoring and IAM roles for security.
- Run unit tests for API endpoints:
pytest tests/
Welcome for contributions! Please open an issue or submit a pull request for any improvements or new features. Be sure to follow the coding standards and add relevant tests.