Overview
Pro Stock Tool’s frontend is built with vanilla HTML, CSS, and JavaScript following a modular architecture. This guide covers the file structure, configuration, and setup of frontend components.Architecture Overview
The frontend follows a Model-View-Controller (MVC) pattern:- Views (
view/,*.html) - HTML templates for each page - Controllers (
controllers/) - JavaScript business logic and API calls - Styles (
styles/) - CSS stylesheets for UI components - Assets (
img/) - Images and static resources
Directory Structure
Initial Setup
Verify File Structure
Ensure all files are in the correct directories:You should see:
database/directorycontrollers/directoryview/directorystyles/directoryimg/directorylogin.htmlInicio-Sesion.html
Configure Base URLs
The application uses absolute paths starting with All paths in HTML files use the root-relative format:
/. Ensure your Apache DocumentRoot is set correctly:For subdirectory deployments, you’ll need to update all paths to include the subdirectory prefix.
Page Structure
Entry Points
The application has two main entry points:1. Registration Page (login.html)
- User registration form with email, name, ID, and password
- Client-side validation
- Password visibility toggle
- Alert notifications
- Connects to
/database/registro.phpAPI
2. Login Page (Inicio-Sesion.html)
- Split-screen design with feature highlights
- Login form with email and password
- Link to registration page
Application Views
All application pages follow a consistent structure:Navigation System
The navigation is dynamically generated byheader-footer.js:
Header Configuration
The header component includes:- Logo and branding: Links to home page
- Page title: Automatically set based on current page
- Search box: Global product search
- Notifications: Bell icon for alerts
- User profile: Avatar and user information
Navigation Menu
The sidebar navigation includes:Path Resolution
The navigation automatically detects whether pages are in the root or/view/ directory:
API Integration
Fetch API Pattern
All controllers use the Fetch API for backend communication:API Endpoints
Each module connects to its corresponding PHP endpoint:| Module | Endpoint | Methods |
|---|---|---|
| Registration | /database/registro.php | POST |
| Warehouses | /database/bodega.php | GET, POST, PUT, DELETE |
| Categories | /database/categorias.php | GET, POST, PUT, DELETE |
| Subcategories | /database/subcategorias.php | GET, POST, PUT, DELETE |
| Suppliers | /database/proveedores.php | GET, POST, PUT, DELETE |
| Parameters | /database/parametros.php | GET, POST, PUT, DELETE |
Error Handling
Standardized error handling pattern:Form Validation
Client-side validation is implemented in controllers:Registration Form Example
Alert System
Global alert/notification system:Styling System
Global Styles
Theheader-footer.css provides base styles for:
- Layout grid system
- Navigation sidebar
- Header bar
- Typography
- Color scheme
- Responsive breakpoints
Component-Specific Styles
Each page has its own stylesheet:Responsive Design
Mobile-first approach with breakpoints:Configuration
API Base URL
For different environments, you may need to configure the API base URL:Environment Detection
Performance Optimization
Accessibility
Pro Stock Tool implements accessibility best practices:Semantic HTML
ARIA Attributes
Keyboard Navigation
All interactive elements are keyboard accessible:Troubleshooting
Assets Not Loading (404 Errors)
Issue: CSS/JS files return 404 Solution: Check that paths are correct relative to DocumentRoot:JavaScript Not Executing
Issue: Controllers don’t run Solution: Check browser console for errors:CORS Errors
Issue:Access-Control-Allow-Origin errors
Solution: Ensure PHP files include CORS headers:
Modal Not Opening
Issue: Modals don’t display Solution: Check CSS and JavaScript:Next Steps
Server Setup
Configure Apache and PHP server
Database Configuration
Set up MySQL database