Digital library management web application for Hellenic Mediterranean University (HMU)
E-Lib is a PHP-based web application designed for managing and accessing a digital library collection. The application provides a comprehensive platform for storing, organizing, and reading PDF documents with features like user authentication, book searching, online reading, and administrative tools.
The application features a modular architecture with separate routes for web pages and API endpoints, allowing for a clean separation of concerns and easy extensibility.
Before you begin, ensure you have the following installed on your system:
- PHP 8.0 or higher with the following extensions:
- OpenSSL
- MongoDB
- JSON
- Fileinfo
- Ctype
- PDO (if using SQL database in the future)
- Composer (PHP package manager)
- MongoDB Server (version 4.4 or later)
- Web Server (Apache/Nginx with mod_rewrite enabled)
- Node.js (for frontend assets compilation)
git clone https://github.com/yourusername/e-lib.git
cd e-lib-
Install PHP dependencies:
composer install
-
Install frontend dependencies (if applicable):
npm install npm run build
-
Copy the example environment file:
cp .env.example .env
-
Generate application key:
php -r "file_put_contents('.env', str_replace('your_jwt_secret_key_here', bin2hex(random_bytes(32)), file_get_contents('.env')));" -
Edit the
.envfile with your configuration:# Database Configuration DB_CONNECTION=mongo DB_HOST=localhost DB_PORT=27017 DB_DATABASE=e_lib # JWT Configuration JWT_SECRET=your_secure_jwt_secret # Application URL APP_URL=http://localhost:8000 # Email Configuration (for notifications and support) MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=your_username MAIL_PASSWORD=your_password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=hello@example.com MAIL_FROM_NAME="${APP_NAME}"
- Ensure MongoDB is running
- Import sample data (if available):
Or create the database manually.
mongorestore --db e_lib database/dumps/e_lib
php -S localhost:8000 -t public- Configure your web server (Apache/Nginx) to point to the
publicdirectory - Set up proper SSL certificates
- Configure your web server's document root to
/path/to/e-lib/public
Open your browser and visit:
- Frontend:
http://localhost:8000 - Admin Panel:
http://localhost:8000/admin(if applicable)
Default admin credentials (if applicable):
- Email: admin@example.com
- Password: password
-
MongoDB Connection Issues:
- Ensure MongoDB service is running
- Check connection string in
.env - Verify database credentials and permissions
-
File Permissions:
- Ensure storage and bootstrap/cache directories are writable
- Run
composer dump-autoloadif class not found errors occur
-
Environment Variables:
- Clear configuration cache:
php artisan config:clear - Ensure
.envfile exists and is properly formatted
- Clear configuration cache:
To update to the latest version:
git pull origin main
composer install
php artisan migrate
npm install
npm run build- Book Management: Add, edit, search, and remove books from the library
- Online PDF Reader: Read documents directly in the browser
- Multi-format Support: Support for PDF, EPUB, Word, PowerPoint, MOBI, AZW, and DJVU formats
- Document Thumbnails: Automatic thumbnail generation for document listings
- Book Collections: Save books to personal reading lists
- User Reviews: Rate and review books
- Admin Dashboard: Comprehensive administrative tools
- Responsive Design: Works on desktop and mobile devices
- MongoDB Integration: Primary storage with JSON fallback
- Security Features: JWT authentication, secure file handling, and more
- Email System: PHPMailer integration for email notifications and support
- Support System: Built-in help center with image upload support
The project is organized into several directories and files:
-
App/: Contains the core application logic.
- Controllers/: Application controllers that handle user requests
BookController.php: Manages book-related operationsUserController.php: Handles user authentication and profile managementPageController.php: Renders web pagesDbController.php: Database operations controller
- Models/: Data models
Books.php: Book data modelUsers.php: User data model
- Router/: Houses routing classes
ApiRouter.php: Manages API routingPageRouter.php: Handles web page routingBaseRouter.php: Base class for routing functionality
- Services/: Business logic services
BookService.php: Book-related functionalityUserService.php: User-related functionalityCasService.php: CAS authentication serviceEmailService.php: Email functionality for notifications and support
- Includes/: Contains additional functionality
JwtHelper.php: JWT token generation and validationResponseHandler.php: API response formattingEnvironment.php: Manages environment variablesSessionManager.php: Manages user sessions
- Middleware/: Request processing middleware
AuthMiddleware.php: Authentication validationJwtAuthMiddleware.php: JWT token validationLoggingMiddleware.php: Request loggingMiddlewareInterface.php: Interface for middleware componentsMiddlewareManager.php: Manages middleware execution
- Helpers/: Helper classes
FileHelper.php: Document processing and thumbnail generation
- Views/: Contains the application's view templates
Components/: Reusable UI componentsAddBook.php: Book upload formSupportModal.php: Help center interface with image upload supportDocs.php: Documentation component
Partials/: Partial templates like headers and footers
- Controllers/: Application controllers that handle user requests
-
public/: Contains publicly accessible files
- assets/: Static assets (JS, images, fonts, uploads)
- uploads/: User-uploaded content
- documents/: Uploaded book files
- thumbnails/: Document thumbnails and placeholder images
- uploads/: User-uploaded content
- styles/: CSS files for styling the application
index.php: The entry point of the application
- assets/: Static assets (JS, images, fonts, uploads)
-
storage/: Application storage
- logs/: Application logs
php_errors.log: PHP error logsrequests.log: Request logs
- logs/: Application logs
-
cache/: Cache storage for improved performance
-
certificates/: SSL certificates and credentials
mongodb-ca.pem: MongoDB certificate
-
vendor/: Composer dependencies
- Backend: PHP 8.2, Custom MVC framework
- Database: MongoDB with JSON fallback
- Frontend: HTML5, CSS3, JavaScript, Bootstrap 5
- Authentication: JWT tokens, Session-based auth, CAS integration
- Containerization: Docker, docker-compose
- Web Server: Apache
- Document Processing:
- ImageMagick for PDF thumbnail generation
- LibreOffice for document conversion
- ZipArchive for EPUB handling
- Email: PHPMailer with SMTP support
- Dependencies: Guzzle HTTP client, Firebase JWT
To get started with the E-Lib project:
-
Create Environment File:
cp .env.example .env
Edit the
.envfile with your specific configuration values. -
Required Environment Variables:
APP_ENV: Application environment (development, production)API_BASE_URL: Base URL for API endpointsCAS_SERVER_URL: CAS server URL for authenticationJWT_SECRET_KEY: Secret key for JWT token generation and validationMONGO_URI: MongoDB connection stringMONGO_PASSWORD: MongoDB passwordMONGO_CERT_FILE: Path to MongoDB certificate fileDATABASE_NAME: Name of the MongoDB databaseMAIL_HOST: SMTP server host for sending emailsMAIL_PORT: SMTP server port (typically 587 for TLS)MAIL_USERNAME: SMTP account usernameMAIL_PASSWORD: SMTP account passwordMAIL_ENCRYPTION: Email encryption method (tls/ssl)MAIL_FROM_ADDRESS: Default sender email addressMAIL_FROM_NAME: Default sender nameSUPPORT_EMAIL: Email address for receiving support requests
-
Clone the Repository:
git clone https://github.com/epictetushmu/E-Lib.git cd E-Lib -
Setup Environment:
cp .env.example .env
-
Build and Start the Docker Environment:
docker-compose up -d
-
Access the Application: Open your web browser and navigate to
http://localhost:8080.
-
Requirements:
- PHP 8.2+
- MongoDB 4.0+
- Apache/Nginx
- Composer
-
Install Dependencies:
composer install
-
Configure Web Server: Point your web server to the
publicdirectory as the document root. -
Set Up File Permissions:
chmod -R 755 public/ chmod -R 777 public/assets/uploads/ chmod -R 777 storage/logs/
- Registration: Create an account using the Sign Up form
- Login: Use your email and password to log in
- Finding Books: Browse featured books or use the search function
- Reading Books: Click on "Online Preview" to read in browser
- Downloading: Use the Download button (when available)
- Saving Books: Click "Save to Reading List" to bookmark a book
- Writing Reviews: Rate and comment on books you've read
- Admin Access: Login with an admin account
- Adding Books: Use the "Add Book" form to upload new books
- Managing Content: Edit or delete books as needed
- Bulk Upload: Use mass upload feature for multiple books
- Setting Permissions: Control which books can be downloaded
- Featuring Books: Mark books as featured to highlight them
- Monitoring System: Check logs for errors or suspicious activity
Comprehensive documentation is available within the application at /docs. This includes:
- Technical implementation details
- API endpoints
- Database structure
- Authentication flows
- File management
E-Lib includes robust document handling capabilities:
- PDF: Full support with thumbnail generation and online reading
- Word Documents: .doc and .docx files with conversion to PDF for preview
- PowerPoint: .ppt and .pptx files with thumbnail generation
- EPUB: Electronic publication format with cover extraction
- MOBI/AZW: Kindle formats with basic support
- DJVU: Document format optimized for scanned documents
- Automatic Thumbnail Generation: Creates thumbnails for documents using:
- ImageMagick for PDF files
- LibreOffice for Word document conversion
- ZipArchive for EPUB cover extraction
- Default placeholder images for unsupported formats
- Format Detection: Automatic detection of file types
- Secure Storage: Documents are stored with randomized filenames
- Permission Control: Admin-configurable download permissions
The document processing is handled primarily by the FileHelper class which:
- Detects file types based on extensions
- Extracts thumbnails using the appropriate method for each file type
- Handles file uploads with proper validation
- Manages file storage with optimized paths for both Docker and local environments
E-Lib includes specialized viewers for different document formats to provide a seamless reading experience directly in the browser:
- Built with PDF.js for client-side rendering
- Features:
- Lazy loading of pages for performance optimization
- Page navigation controls
- Zoom functionality
- Responsive design that works on mobile devices
- JWT authentication for secure document access
- High-quality rendering with adjustable scale
- Built with Mammoth.js for DOCX parsing
- Features:
- Renders Word documents directly in the browser
- Preserves document formatting and styles
- Fallback to download option when rendering is not possible
- Compatible with .doc and .docx formats
- For other document formats (PowerPoint, EPUB, DJVU, etc.)
- Provides download options when browser viewing is not available
- Clear format-specific messaging and icons
The document viewing system is implemented through:
-
DocumentViewer.php: A central component that:
- Detects the document type
- Loads the appropriate viewer component
- Handles authentication and permissions
- Manages the UI framework for all viewers
-
Format-specific viewers:
- PdfViewer.php: Handles PDF documents
- WordViewer.php: Handles Word documents
- Additional viewers can be added for other formats
- JWT token-based authentication for document access
- Server-side permission checks before serving documents
- Configurable download permissions that can be set per document
- Protection against direct URL access to document files
E-Lib includes a comprehensive support system to assist users:
The application features an interactive Help Center accessible from any page:
- FAQ Section: Common questions and answers for quick user reference
- Documentation Links: Direct access to detailed documentation pages
- Rich Support Request Form: Advanced form with the following features:
- Rich text editing capabilities
- Image embedding directly in support requests
- Support for pasting images (clipboard integration)
- File attachment functionality for screenshots or documents
- Client-side validation for immediate user feedback
- AJAX submission for a seamless user experience
The Support System is implemented through:
- SupportModal.php: A reusable component that can be included on any page
- REST API Endpoint: Handles support request submissions with attachments
- EmailService Integration: Routes support requests to the support team's email inbox
- Image Processing: Support for multiple image formats and automatic resizing
- User accesses the Help Center through the support icon
- User checks FAQ for immediate answers
- If needed, user submits a detailed support request with optional images
- Request is validated and sent to support staff
- Confirmation is displayed to the user
The application uses PHPMailer to handle all email functionality. To configure email:
-
Set up your SMTP server information in the
.envfile:MAIL_HOST=smtp.example.com MAIL_PORT=587 MAIL_USERNAME=your_username MAIL_PASSWORD=your_password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=support@epictetuslibrary.com MAIL_FROM_NAME="Epictetus Library" SUPPORT_EMAIL=support@epictetuslibrary.org -
Email functionality is available through the
EmailServiceclass which provides:- Support request emails
- General email sending capability
- HTML-formatted emails
Having trouble using the library? Our support team is here to help!
-
Email Support: support@epictetuslibrary.org
-
Help Center: Available in the application
-
Issue Tracker: GitHub Issues
To contribute to this project, please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by the Department of Electrical & Computer Engineering, Hellenic Mediterranean University.