A comprehensive CRUD application for tracking books and organizing them into collections, built with Next.js 15, TypeScript, TailwindCSS, HeadlessUI, HeroIcons, and MongoDB.
- ✅ Add, view, edit, and delete books
- ✅ Track book details: Title, Author, Review, Rating (0-5), Status, Collection
- ✅ Book statuses: TBR (To Be Read), Reading, Read, DNF (Did Not Finish), On Hold
- ✅ Individual book view page with detailed information
- ✅ Quick status and collection changes from the books list
- ✅ Comprehensive loading states with visual feedback for all operations
- ✅ Create, edit, and delete collections from the dashboard
- ✅ Move books between collections
- ✅ Default "My Books" collection for new databases
- ✅ Automatic book reassignment when deleting collections
- ✅ Integrated collection management in dashboard view
- ✅ Loading states for collection operations
- ✅ Unique link-based access (no login required)
- ✅ Each database has a unique ID accessible via localhost:3000/{database-id}
- ✅ MongoDB Atlas cloud storage for reliable data persistence
- ✅ Automatic database creation for new users
- ✅ Smart database ID display with dynamic formatting for different ID lengths
- ✅ Copy-to-clipboard functionality for database IDs
- ✅ Overview statistics: total books, collections count, reading status breakdown
- ✅ Collections management with add/edit/delete functionality
- ✅ Reading status distribution
- ✅ Integrated collection cards with book counts
- ✅ Real-time data updates with loading indicators
- ✅ Responsive design with TailwindCSS
- ✅ Dark mode support with theme toggle
- ✅ Professional loading components replacing content during operations
- ✅ Sortable table headers (Title, Author, Rating, Status, Collection)
- ✅ Filtering by status and collection
- ✅ Modal forms for adding/editing books and collections
- ✅ Streamlined navigation: Dashboard and Books pages
- ✅ Integrated collection management in dashboard
- ✅ Optimized loading states preventing UI blocking
- Frontend: Next.js 15 with App Router
- Language: TypeScript
- Database: MongoDB Atlas (cloud-hosted)
- Styling: TailwindCSS
- UI Components: HeadlessUI
- Icons: HeroIcons
- HTTP Client: Axios for API requests
- Routing: Dynamic routes for database IDs
- Development: Turbopack for fast development builds
- Node.js 18+
- npm or yarn
- MongoDB Atlas account (free tier available)
- Clone the repository:
git clone <repository-url>
cd reading-tracker-app-simple- Install dependencies:
npm install-
Set up environment variables:
- Copy
.env.local.exampleto.env.local(if available) - Or create
.env.localwith your MongoDB connection string:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/reading-tracker?retryWrites=true&w=majority - Copy
-
Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
- Visit
localhost:3000 - The app will automatically create a new database and redirect you to
localhost:3000/{unique-id} - Bookmark this URL as your personal reading tracker
- Use the copy button next to the database ID in the header to save your unique link
- Navigate to the Books page
- Click "Add Book"
- Fill in the required fields:
- Title (Required)
- Author (Required)
- Rating 0-5 (Required)
- Status (Required, defaults to TBR)
- Collection (Required, defaults to "My Books")
- Review (Optional)
- The app will show a loading indicator while saving
- Navigate to the Dashboard
- Scroll to the Collections section
- Click "Add Collection" to create new collections
- Use the edit (pencil) icon to modify existing collections
- Use the delete (trash) icon to remove collections (books will be moved to another collection)
- Each collection shows its title, description, book count, and creation date
- All operations show loading states for better user feedback
- Click on any book title to view full details
- Use the Books list to quickly change status or collection
- Filter and sort books using the controls at the top of the Books page
- Edit or delete books using the action buttons
- Loading indicators show progress for all operations
- All data is stored securely in MongoDB Atlas cloud database
- Each database ID maintains separate data collections
- Data persists across devices and browser sessions
- Automatic backup and reliability through MongoDB Atlas
- No user accounts required - access via unique database ID
src/
├── app/ # Next.js App Router pages
│ ├── [dbId]/ # Dynamic database routes
│ │ ├── page.tsx # Dashboard with collections management
│ │ └── books/ # Books pages
│ │ ├── page.tsx # Books list with loading states
│ │ └── [bookId]/ # Individual book view
│ ├── api/ # Next.js API routes
│ │ ├── books/ # Books CRUD operations
│ │ ├── collections/ # Collections CRUD operations
│ │ └── test/ # Database connection testing
│ └── page.tsx # Home page (redirects to new DB)
├── components/ # Reusable React components
│ ├── Layout.tsx # Main layout with navigation and theme toggle
│ ├── BookForm.tsx # Book add/edit modal
│ ├── CollectionForm.tsx # Collection add/edit modal
│ ├── CollectionsManagementModal.tsx # Collections management interface
│ ├── Loading.tsx # Professional loading component
│ ├── StyledDropdown.tsx # Custom dropdown component
│ └── ThemeToggle.tsx # Dark/light mode toggle
├── contexts/ # React contexts
│ └── ThemeContext.tsx # Theme management context
├── lib/ # Utility libraries
│ ├── constants.ts # App constants and configurations
│ └── mongodb.ts # MongoDB connection and client setup
├── services/ # Business logic and data services
│ ├── dataService.ts # Legacy localStorage service
│ └── mongoDataService.ts # MongoDB data operations
└── types/ # TypeScript type definitions
├── index.ts # App-wide interfaces
└── css.d.ts # CSS module declarations
- Loading.tsx: Professional loading component with customizable sizes (sm/md/lg)
- Content replacement strategy instead of button spinners
- Consistent loading states across all operations
- Dark mode support with spinning icons
- mongoDataService.ts: MongoDB operations with proper error handling
- dataService.ts: Legacy localStorage fallback
- mongodb.ts: Database connection management with connection pooling
- ThemeContext.tsx: Global theme state management
- ThemeToggle.tsx: User-friendly theme switching
- Persistent theme preferences
- Full dark mode support across all components
interface Book {
_id?: string; // MongoDB ObjectId
id: string; // Application ID
title: string;
author: string;
review?: string;
rating: number; // 0-5
status: 'TBR' | 'Reading' | 'Read' | 'DNF' | 'On Hold';
collectionId: string;
createdAt: Date;
updatedAt: Date;
}interface Collection {
_id?: string; // MongoDB ObjectId
id: string; // Application ID
title: string;
description: string;
createdAt: Date;
updatedAt: Date;
}Each database ID corresponds to separate MongoDB collections:
books_{dbId}: Stores all books for the databasecollections_{dbId}: Stores all collections for the database
Required environment variables in .env.local:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/reading-tracker?retryWrites=true&w=majority# Development server with Turbopack
npm run dev
# Production build with Turbopack
npm run build
# Start production server
npm start
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code with Prettier
npm run format
# Check code formatting
npm run format:check- ✅ Migrated from localStorage to MongoDB Atlas cloud storage
- ✅ Reliable data persistence across devices and sessions
- ✅ Proper ObjectId handling and validation in API routes
- ✅ Connection pooling and optimized database performance
- ✅ Automatic database and collection creation
- ✅ Professional Loading component with spinning animations
- ✅ Content replacement loading strategy (better than button spinners)
- ✅ Granular loading states for every operation (add, edit, delete)
- ✅ Consistent loading experience across all pages
- ✅ Loading indicators for initial data fetching
- ✅ Dark mode support with persistent theme preferences
- ✅ Smart database ID formatting (prevents character overlap)
- ✅ Copy-to-clipboard functionality for database IDs
- ✅ Responsive design improvements
- ✅ Better error handling and user feedback
- ✅ Turbopack integration for faster development builds
- ✅ Optimized API routes with proper error handling
- ✅ Efficient MongoDB queries and operations
- ✅ Reduced redundant API calls with proper loading states
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use the established loading state patterns
- Ensure dark mode compatibility for new components
- Test with both short and long database IDs
- Add proper error handling for MongoDB operations
This project is licensed under the MIT License - see the LICENSE file for details.