book-nest-svelte Svelte Themes

Book Nest Svelte

šŸ“š Book Nest

This is small practice project, a personal library management application that allows you to create, organize, and share your book collection. Built with SvelteKit and powered by Supabase, it features an AI-powered book scanning capability using OpenAI's GPT-4 Vision to automatically recognize books from shelf photos.

✨ Features

  • šŸ” User Authentication - Secure sign-up and login with Supabase Auth
  • šŸ“– Personal Library - Create and manage your digital book collection
  • šŸ“ø AI Book Scanner - Take a photo of your bookshelf and automatically add books using GPT-4 Vision
  • ⭐ Book Ratings - Rate and review your books with a star rating system
  • šŸ·ļø Categories - Organize books by categories
  • šŸ‘¤ User Profiles - Manage your account and settings
  • šŸŽØ Beautiful UI - Clean, intuitive interface built with Svelte 5
  • šŸ”’ Protected Routes - Secure private pages with authentication guards

šŸ› ļø Tech Stack

  • Frontend Framework: SvelteKit v2 with Svelte 5
  • Backend & Database: Supabase (PostgreSQL, Authentication, Storage)
  • AI Integration: OpenAI GPT-4 Vision for book recognition
  • Language: TypeScript
  • Styling: Custom CSS
  • Icons: @iconify/svelte
  • File Upload: svelte-file-dropzone
  • Development: Vite, ESLint, Prettier
  • Deployment: Vercel

šŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

šŸš€ Getting Started

1. Clone the repository

git clone https://github.com/KimChanaDev/book-nest-svelte.git
cd book-nest-svelte

2. Install dependencies

npm install
# or
pnpm install
# or
yarn install

3. Set up Supabase

Option A: Use Supabase Cloud

  1. Create a new project at supabase.com
  2. Get your project URL and anon key from Project Settings > API

Option B: Use Supabase Local Development

# Start Supabase locally
npx supabase start

4. Set up environment variables

Create a .env file in the root directory and add your API keys:

# Supabase Configuration
PUBLIC_SUPABASE_URL=your_supabase_project_url
PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
PUBLIC_FRONTEND_URL=your_front_end_url

SUPABASE_SERVICE_ROLE_KEY=your_supabase_role_key

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key

# Set to 'true' for testing without OpenAI API calls, 'false' for production
MOCK_OPENAI=false

Note: Variables with PUBLIC_ prefix are exposed to the browser. Keep sensitive keys private.

5. Run the development server

npm run dev

The application will be available at http://localhost:5173

6. (Optional) Start Supabase Studio

If using local Supabase:

npx supabase start

Access Supabase Studio at http://127.0.0.1:54323

šŸŽØ Components

Main Components

  • HeroSection.svelte - Landing page hero with call-to-action
  • AuthForm.svelte - Reusable authentication form for login/register
  • BookCard.svelte - Display individual book information
  • BookCategory.svelte - Category selector for books
  • StarRating.svelte - Interactive star rating component
  • Button.svelte - Reusable button component
  • Header.svelte - Navigation header
  • SideNavigation.svelte - Sidebar navigation for authenticated users

šŸ“± Pages & Routes

Public Routes

  • / - Landing page
  • /login - User login page
  • /register - User registration page

Protected Routes (Requires Authentication)

  • /private/dashboard - User's book library overview
  • /private/book/[bookId] - Individual book details page
  • /private/scan-shelf - AI-powered book scanner
  • /private/settings - Account settings and profile management

šŸ¤– AI Book Scanner

The book scanner feature uses OpenAI's GPT-4 Vision model to:

  1. Accept a photo of your bookshelf (via drag-and-drop or file upload)
  2. Analyze the image and extract book titles and authors
  3. Return a structured JSON array of recognized books
  4. Allow you to review and add books to your library in bulk

šŸ—ļø Project Structure

book-nest/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ lib/
│   │   ā”œā”€ā”€ components/     # Reusable Svelte components
│   │   ā”œā”€ā”€ state/          # State management
│   │   ā”œā”€ā”€ types/          # TypeScript type definitions
│   │   └── utils/          # Utility functions
│   ā”œā”€ā”€ routes/             # SvelteKit routes
│   │   ā”œā”€ā”€ api/            # API endpoints
│   │   ā”œā”€ā”€ auth/           # Authentication routes
│   │   ā”œā”€ā”€ login/          # Login page
│   │   ā”œā”€ā”€ register/       # Registration page
│   │   └── private/        # Protected routes
│   ā”œā”€ā”€ app.css             # Global styles
│   ā”œā”€ā”€ app.html            # HTML template
│   └── hooks.server.ts     # Server-side hooks & middleware
ā”œā”€ā”€ static/                 # Static assets
ā”œā”€ā”€ supabase/
│   ā”œā”€ā”€ config.toml         # Supabase configuration
│   └── migrations/         # Database migrations
└── package.json

šŸš€ Deploy to Vercel

The easiest way to deploy your Book Nest application is using Vercel:

Alternative: Deploy with Adapter

For other platforms, you can change the adapter in svelte.config.js:

# Install specific adapter
npm install -D @sveltejs/adapter-cloudflare # for Cloudflare Workers and Cloudflare Pages
npm install -D @sveltejs/adapter-node # for Node servers
npm install -D @sveltejs/adapter-static # for static site generation (SSG)
npm install -D @sveltejs/adapter-vercel # for Vercel
npm install -D @sveltejs/adapter-netlify # for Netlify

šŸ”§ Configuration

Path Aliases

The project uses custom path aliases configured in svelte.config.js:

  • $components → src/lib/components
  • $assets → src/lib/assets
  • $state → src/lib/state

Top categories

Loading Svelte Themes