How ehmenzala/biblioweb-php works
Project type and purpose
• This is a monolithic, full-stack PHP web application named “Biblioweb,” built on Apache/PHP 8.0. It provides a virtual library interface with an admin dashboard, book search, personal uploads, and a custom REST-style API.
File structure
• Top-level PHP entrypoints: index.php and Router.php dispatch all incoming requests.
• “public” directory holds static assets (CSS, JS, images) served directly by Apache.
• “src” directory follows an MVC-like structure:
• api/ApiRouter.php – handles JSON API routes
• controllers/ – HTTP controllers for pages and API
• services/ – business logic layer
• repository/ – data access layer (CRUD with models)
• models/ – data structures/entities
• views/ – HTML templates for each page
• utilities/Authenticator.php – authentication helper
• “db” contains SQL scripts for schema and seed data.
README for additional insights
• Confirms features (admin dashboard, search, uploads, custom API) and tech stack (PHP/Apache).
a. Main components
• Client (Browser)
• Web Server (Apache + .htaccess)
• PHP Front Controller (index.php → Router.php)
• MVC Layers:
– Controllers (HTTP and API)
– Services (AuthorService, BookService, etc.)
– Repository (AuthorRepository, BookRepository, etc.)
– Models (Author, Book, Genre, User)
• Views (HTML templates)
• Public Assets (CSS, JS, images)
• Database (MySQL scripts in db/)
• Utilities (Authenticator)
b. Relationships and interactions
• Browser sends HTTP/HTTPS requests → Apache
• Apache routes to index.php (front controller)
• Router dispatches to either ApiRouter (for API) or appropriate Controller
• Controller calls Service layer for business logic
• Service calls Repository to read/write Models to the Database
• Controller renders a View (HTML) or returns JSON (API)
• Static assets bypass PHP and are served directly from public/
c. Architectural patterns and principles
• Front Controller pattern (index.php + Router.php)
• Layered (n-tier) architecture: Presentation (views), Application (controllers), Business (services), Data (repository)
• MVC-inspired separation of concerns
• Repository pattern for DB access
• Single codebase monolith, no microservices
d. Key technologies/frameworks
• PHP 8.0.x
• Apache HTTP Server, .htaccess for URL rewriting
• MySQL (SQL scripts in db/)
• Vanilla JS for dashboard interactivity
• CSS for styling, organized per page in public/css/
Elements
• Labels: Browser, Apache, Front Controller, ApiRouter, Controllers, Services, Repositories, Models, Views, Static Assets, Database
• Browser → Apache → Front Controller → Router → Controller → Service → Repository → Database
• Controller → View → Browser
• Browser → Static Assets
• Browser ↔ API endpoints (JSON)
• Web layer (green): Browser, Apache, Front Controller, Router
• Application layer (blue): Controllers, Services, Repository, Models
• Data layer (orange): Database
• Assets layer (gray): CSS/JS/Images
• Utilities (purple): Authenticator