Fable is a full-stack e-book digital marketplace that connects readers, writers, and administrators. The platform enables writers to publish and monetize original e-books, allows readers to discover and purchase content, and provides administrators with comprehensive management and analytics tools. Built with modern web technologies, it emphasizes user experience, security, and scalability.
Live URL: https://fable-amber.vercel.app
- Framework: Next.js 16 (React 19) with App Router
- Styling: Tailwind CSS 4 + PostCSS
- UI Components: shadcn/ui (Base UI + Radix UI primitives)
- Authentication: BetterAuth (Email/Password + Google OAuth)
- Forms: React Hook Form
- Animations: Framer Motion
- Charts: Recharts
- Payments: Stripe (Client SDK)
- Icons: Lucide React + React Icons
- Notifications: Sonner (Toast library)
- Carousel: Swiper
- Theme: next-themes (Dark mode support)
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB
- Authentication: BetterAuth with MongoDB adapter
- Payments: Stripe (Server SDK)
- CORS: Enabled for cross-origin requests
- Environment: Dotenv for configuration
- Client: Vercel
- Server: Node.js server (custom deployment)
- Database: MongoDB Atlas
- User profiles (readers and writers)
- Managed by BetterAuth
- Fields: email, name, role (reader/writer), avatar, metadata
- E-book metadata and content
- Fields: title, description, author (writer), cover image, price, genre, status, content, upload date, view count
- Purchase transactions and sales history
- Fields: book id, buyer id, seller id, price, purchase date, transaction status
- User bookmarks/wishlist entries
- Fields: user id, book id, created date
fable/
โโโ client/ # Next.js Frontend Application
โ โโโ app/
โ โ โโโ page.js # Home page
โ โ โโโ layout.js # Root layout
โ โ โโโ globals.css # Global styles
โ โ โโโ api/ # API routes (Auth, Checkout)
โ โ โโโ all-books/ # Public ebook catalog
โ โ โโโ authors/ # Author profile pages
โ โ โโโ login/ # Login & authentication
โ โ โโโ signup/ # User registration
โ โ โโโ dashboard/ # Role-based dashboards
โ โ โ โโโ admin/ # Admin overview & controls
โ โ โ โโโ reader/ # Reader dashboard
โ โ โ โโโ writer/ # Writer dashboard
โ โ โโโ unauthorized/ # Access denied page
โ โ
โ โโโ components/
โ โ โโโ pageContent/ # Full-page components
โ โ โโโ tools/ # Utility components
โ โ โโโ ui/ # Reusable UI components (15+)
โ โ
โ โโโ lib/
โ โ โโโ auth.js # BetterAuth configuration
โ โ โโโ stripe.js # Stripe integration
โ โ โโโ actions/ # Server actions
โ โ โโโ api/ # API integration layer
โ โ โโโ core/ # Core utilities
โ โ โโโ utils/ # Helper utilities
โ โ
โ โโโ public/ # Static assets
โ โโโ package.json
โ โโโ next.config.mjs
โ โโโ tailwind.config.js
โ โโโ README.md
โ
โโโ server/ # Express.js Backend
โโโ index.js # Main server file
โโโ package.json
โโโ vercel.json # Deployment config
โโโ .env # Environment variables
User Registration/Login
โ BetterAuth (Email/Google)
โ JWT Session Token (7-day expiration)
โ Role Selection (Reader/Writer)
โ Dashboard Access
Browse Catalog
โ View E-book Details
โ Click "Buy Now"
โ Stripe Checkout Session
โ Secure Payment Processing
โ Add to "Purchased" Collection
โ Content Unlock & Access
Writer Dashboard
โ Click "Add New E-book"
โ Fill Complete Metadata (Title, Price, Genre, Cover, Description)
โ Upload Content
โ Publish/Draft Toggle
โ Appears in Catalog (if published)
GET /api/usersโ Fetch all users (admin)DELETE /api/users/:idโ Remove a user account (admin)
GET /api/ebooksโ Fetch all published e-booksGET /api/ebooks/:idโ Get single e-book detailsPOST /api/ebooksโ Create new e-book (authenticated writer)PUT /api/ebooks/:idโ Update e-book metadata (writer/admin)DELETE /api/ebooks/:idโ Delete e-book (writer/admin)
GET /api/soldbooksโ Fetch all sales (admin)GET /api/soldbooks/writer/:idโ Get writer's sales historyPOST /api/soldbooksโ Record new purchase
GET /api/bookmarks/:userIdโ Get user's bookmarksPOST /api/bookmarksโ Add bookmarkDELETE /api/bookmarks/:idโ Remove bookmark
POST /api/auth/[...all]โ BetterAuth endpoints (login, signup, logout)POST /api/checkout_sessionsโ Create Stripe checkout session
- Authentication: BetterAuth manages secure JWT session tokens with 7-day expiration
- Protected Routes: Role-based access control (Reader, Writer, Admin) with middleware guards
- CORS Configuration: Strict CORS policy on backend for safe cross-origin requests
- Payment Security: Stripe handles PCI compliance and secure payment processing
- Database Security: MongoDB connections secured with environment variables and authentication
- Session Persistence: No data loss on page reload; sessions stored securely
- Environment Management: All sensitive keys stored in
.envand.env.localfiles (never committed to git)
| Feature | Reader | Writer | Admin |
|---|---|---|---|
| Browse E-books | โ | โ | โ |
| Purchase E-books | โ | โ | โ |
| Create Bookmarks | โ | โ | โ |
| Publish E-books | โ | โ | โ |
| Manage Own E-books | โ | โ | โ |
| Manage All E-books | โ | โ | โ |
| Manage All Users | โ | โ | โ |
| View Own Analytics | โ | โ | โ |
| View Platform Analytics | โ | โ | โ |
- Pagination: Efficient server-side pagination for handling large datasets
- Skeleton Loaders: Improves perceived performance during content loading
- Image Optimization: Next.js Image component for responsive, optimized images
- Code Splitting: Modular component architecture enabling automatic route-based code splitting
- Caching Strategy: Leverages Next.js built-in caching and HTTP caching headers
- Database Indexing: MongoDB collections indexed on frequently queried fields
- CDN Delivery: Vercel's edge network for ultra-fast static asset delivery globally
- User Reviews & Ratings: Enable readers to review and rate purchased e-books
- Search Optimization: Full-text search with Elasticsearch for advanced filtering
- Social Features: Author follow system, community comments, and discussions
- Content Features: Series/Collections, table of contents, highlights, annotations, reading progress tracking
- Payment Features: Multiple payment gateways (PayPal, Apple Pay), subscription plans, promotional codes
- Internationalization: Multi-language support and currency conversion
- Content Management: WYSIWYG editor for e-book creation, DRM protection, version control
- Mobile App: Native iOS/Android apps for better reading experience