A modern, full-stack library management system built with React + TypeScript (Vite) frontend and Spring Boot (Java) backend, using MongoDB for data persistence. This application provides comprehensive book management, user authentication, and loan tracking capabilities for libraries.
- User Authentication: Secure registration and login system with JWT tokens
- Book Search & Browse: Search books by title, author, or category
- Book Borrowing: Borrow available books with automatic due date tracking
- Loan Management: View current loans, due dates, and return history
- User Dashboard: Personal dashboard with borrowing statistics
- Admin Dashboard: Comprehensive admin panel for library management
- Book Management: Add, edit, and remove books from the catalog
- Member Management: Manage library members and their accounts
- Loan Tracking: Monitor all active loans and overdue items
- Library Statistics: Overview of library usage and inventory
- Responsive Design: Works seamlessly on desktop and mobile devices
- Real-time Updates: Live data synchronization across the application
- Role-based Access: Secure role-based permissions (User/Admin)
- Modern UI: Clean, intuitive interface built with Radix UI and Tailwind CSS
- React 18 - Modern React with hooks and context
- TypeScript - Type-safe development
- React Router 6 - SPA routing
- TailwindCSS 3 - Utility-first CSS framework
- Radix UI - Accessible UI components
- Tanstack Query - Server state management
- Vite - Fast build tool and dev server
- Java 17 - LTS runtime
- Spring Boot 3 - REST API framework
- Spring Security + JWT - Authentication & authorization
- MongoDB - NoSQL database
- BCrypt - Password hashing
- pnpm - Fast, disk space efficient package manager
- Vitest - Unit testing framework
- Prettier - Code formatting
- ESLint - Code linting
Before you begin, ensure you have met the following requirements:
- Java 17+ - For Spring Boot backend
- Node.js (v18 or higher) - For React frontend development
- pnpm (v8 or higher) -
npm install -g pnpm - MongoDB Atlas account OR local MongoDB installation
- Maven 3.6+ - For building Spring Boot application
git clone https://github.com/pushkarkumarsaini2006/Java-Project.git
cd Java-Projectpnpm installYour Spring Boot backend is pre-configured to use MongoDB Atlas:
- The connection string is already set in
server/src/main/resources/application.properties - Database:
leafstack-library - If you want to use a different MongoDB instance, update the URI in
application.properties
For local MongoDB (optional):
spring.data.mongodb.uri=mongodb://localhost:27017/leafstack-library# Start both servers together
pnpm dev:fullOR start them separately:
# Terminal 1: Start Spring Boot backend
pnpm dev:backend
# Terminal 2: Start React frontend
pnpm devThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080/api
On first run, the backend seeds a default admin account:
- Email:
admin@leafstack.local - Password:
admin12345
The system automatically seeds sample books and borrowing data for testing.
βββ client/ # React frontend application
β βββ components/ # Reusable UI components
β β βββ ui/ # Radix UI component library
β βββ contexts/ # React context providers
β βββ hooks/ # Custom React hooks
β βββ pages/ # Route components
β βββ App.tsx # Main app component with routing
βββ server/ # Spring Boot backend (Java)
β βββ src/main/java/com/leafstack/library
β β βββ controller/ # REST controllers
β β βββ service/ # Business logic
β β βββ repository/ # Mongo repositories
β β βββ security/ # JWT & security config
β β βββ config/ # App config & seeders
β βββ src/main/resources/application.properties
βββ shared/ # Shared types and utilities
βββ public/ # Static assets
# Development
pnpm dev # Start development server (client + server)
pnpm build # Build for production
pnpm start # Start production server
# Testing & Quality
pnpm test # Run tests
pnpm typecheck # TypeScript type checking
pnpm format.fix # Format code with PrettierThe backend provides REST endpoints under /api/library/*:
POST /api/library/auth/register- Register new userPOST /api/library/auth/login- User loginPOST /api/library/auth/refresh- Refresh JWT token
GET /api/library/books- Get all booksPOST /api/library/books- Add new book (Admin only)PUT /api/library/books/{id}- Update book (Admin only)DELETE /api/library/books/{id}- Delete book (Admin only)
GET /api/library/users- Get all users (Admin only)GET /api/library/users/profile- Get current user profilePUT /api/library/users/profile- Update user profile
GET /api/library/borrows- Get all borrowsPOST /api/library/borrows- Borrow a bookPUT /api/library/borrows/{id}/return- Return a book
-
Build the frontend:
pnpm build
-
Package the backend:
cd server mvn clean package -
Deploy:
- Backend: Deploy
target/library-backend-1.0.0.jarto your cloud provider - Frontend: Deploy the
dist/folder to Netlify, Vercel, or any static hosting service
- Backend: Deploy
The application uses JWT (JSON Web Tokens) for authentication:
- User Registration: Users can register with email and password
- Secure Login: Passwords are hashed using bcrypt
- Role-based Access: Two roles supported (User/Admin)
- Protected Routes: Certain endpoints require authentication
- Admin Features: Some features are restricted to admin users
{
name: string
email: string (unique)
password: string (hashed)
role: 'user' | 'admin'
createdAt: Date
}{
title: string
author: string
isbn: string (unique)
category: string
totalCopies: number
availableCopies: number
createdAt: Date
}{
user: ObjectId (ref: User)
book: ObjectId (ref: Book)
borrowDate: Date
dueDate: Date
returnDate: Date (optional)
status: 'active' | 'returned' | 'overdue'
}The application uses a comprehensive UI component library built on:
- Radix UI - Accessible, unstyled components
- TailwindCSS - Utility-first CSS framework
- Lucide React - Beautiful, customizable icons
- Framer Motion - Smooth animations
Available components include:
- Forms (Input, Select, Checkbox, etc.)
- Navigation (Tabs, Menubar, Breadcrumb)
- Feedback (Toast, Alert, Dialog)
- Data Display (Table, Card, Badge)
- Layout (Separator, Sidebar, Resizable panels)
pnpm build
pnpm startFrontend (Vite):
VITE_API_BASE_URL=https://your-backend.example.comBackend (Spring Boot):
spring.data.mongodb.uri=your-production-mongodb-uri
jwt.secret=your-production-jwt-secret
cors.allowed-origins=https://your-frontend.example.comThis application can be deployed as:
- Netlify/Vercel (Frontend SPA) + Render/Heroku/AWS/VM (Spring Boot API)
- Single VM/Kubernetes hosting both services
For Netlify, set VITE_API_BASE_URL to your Spring Boot API origin. The existing [[redirects]] for /api/* targets a serverless function template and is not used when VITE_API_BASE_URL is configured.
Run the test suite:
pnpm testRun type checking:
pnpm typecheck- Fork the repository
- Create your 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
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with the Fusion Starter template
- UI components from Radix UI
- Icons from Lucide
- Styling with TailwindCSS
If you have any questions or need help getting started:
- Check the Issues page
- Create a new issue if your question isn't already answered
- For urgent matters, contact the maintainer
Happy coding! πβ¨