BookWise is a comprehensive library management system app built with Next.js for tracking book states.
- Add Books: Add new books with details like title, author, and ISBN.
- Update Status: Easily update a book's borrowing status between 'Available', 'Checked Out', and 'Archived'.
- Assign Borrowers: Assign books to borrowers when they are checked out.
- Search & Filter: A powerful search for finding books by title and filtering by their current status.
- AI-Powered Suggestions: Get recommendations for related books based on a book's title, powered by GenAI.
This project is a demonstration of a modern, full-stack web application using Next.js, TypeScript, and Tailwind CSS, featuring server components, server actions, and AI integration.
Here's an overview of the key directories and files in this project:
- /src/app: Contains the core Next.js application, including pages and API routes.
- /src/components: Reusable React components used throughout the application.
- /src/ai: Houses the Genkit AI flows and configuration.
- /src/services: Modules for interacting with external services like Firebase.
- /src/lib: Utility functions and type definitions.
- /firebase.json: Configuration for Firebase services.
- /genkit.ts: Configuration for the Genkit AI framework.
This project uses Firebase to handle backend services, including:
- Firestore: A NoSQL document database for storing book information, user data, and application state.
- Firebase Authentication: Manages user sign-up and login, providing a secure way to handle user accounts.
- Cloud Storage for Firebase: Used to store book cover images generated by the AI.
- Cloud Functions for Firebase: The
onBookWriteCreateEmbeddingfunction is a key part of the AI-powered features, generating embeddings from book notes.
Genkit is an open-source framework that helps you build, deploy, and monitor production-ready AI-powered features. It provides tools for defining AI flows, managing prompts, and integrating with models like Google's Gemini.
The application leverages Genkit to create AI-powered flows that enhance the user experience. These flows are defined in the /src/ai/flows directory.
- Purpose: Generates a unique book cover image based on the book's title and author.
- Genkit Features:
ai.defineFlow: Defines the flow, making it available for invocation.ai.generate: Calls the image generation model with a specific prompt.
- Trigger: Manually triggered by the user from the book details page.
- Input:
title,author,bookId. - Output: The public URL of the generated book cover image in Firebase Storage.
- Purpose: Automatically populates book data (author and ISBN) based on the book's title.
- Genkit Features:
ai.definePrompt: Creates a reusable prompt template for extracting structured data.ai.defineFlow: Wraps the prompt in a flow.
- Trigger: When a user adds a new book.
- Input:
title. - Output: An object containing the
title,author, andisbn.
- Purpose: Suggests a list of related books based on the current book's title.
- Genkit Features:
ai.definePrompt: Creates a prompt for generating a list of suggestions.ai.defineFlow: Exposes the prompt as a flow.
- Trigger: Manually triggered by the user.
- Input:
title. - Output: A list of related book titles.
- Purpose: Enables a conversational experience, allowing users to chat about a book.
- Genkit Features:
ai.defineFlow: Manages the chat history and context.ai.generate: Generates a conversational response.
- Trigger: User initiates a chat from the book details page.
- Input: Chat
historyandbookobject. - Output: A conversational response from the AI.
The project includes a key Cloud Function for Firebase that integrates with the AI capabilities.
- Purpose: This function automatically generates a vector embedding for a book's notes whenever the notes are added or updated in Firestore.
- Trigger: The function is triggered by
onWriteevents on documents in the/users/{userId}/books/{bookId}collection. For example, a real document path could be/users/123/books/456. - Details: When a book's
notesfield is modified, the function uses a Genkit embedder to create a 768-dimensional vector embedding of the notes. This embedding is then stored in theembeddingfield of the same document, enabling vector-based similarity searches.
You can access the deployed application here: https://studio--bookwise-7k4b9.us-central1.hosted.app