How berru-g/projet-messagerie works
Project type and purpose
• This is a monolithic full-stack PHP/MySQL web application (“Template PHP/MySQL”) providing a social file-sharing platform with authentication, posts, likes, private/public file uploads (CSV, JSON, Excel, images, PDFs), basic PWA support (manifest.json, sw.js), and a built-in data-visualization toolkit.
• The README describes user flows (login/register, file upload, search, data-to-chart, social feed) and highlights core features: secure authentication, posts, likes, profile dashboard, file sharing, data-visualization, and protection against SQL/XSS.
File structure
• Top-level entry point: index.php.
• assets/: static front-end (CSS, JS, images, videos, small No-Code SQL-builder UI).
• includes/: PHP backend utilities (config.php, config.sql, functions.php, header/footer, delete/toggle file/share handlers).
• pages/: distinct PHP “controllers”/views for each feature (login, register, SQL-editor, data-to-chart, gallery, profile, search, factures, wallet API).
• uploads/: filesystem storage for user-uploaded files organized by user ID.
• wallet/: PHP API for cryptocurrency wallet integration.
• lang/: localization JSON files.
• manifest.json & sw.js: PWA manifest and service worker.
• .github/workflows/deploy.yml: CI/CD deployment pipeline.
• .htaccess files: Apache hosting configuration (.hta_host, .hta_local).
Key architectural patterns
• MVC-style separation by grouping controllers (pages/), views/templates (includes/header.php, footer.php), and model interactions (includes/functions.php + config.php + MySQL).
• Monolithic server handles HTTP, PHP execution, database access, and file I/O.
• PWA caching layers on the client via service worker.
• CI/CD pipeline deploying from GitHub to target web server.
Main components & their responsibilities
a. Client (Web Browser)
• Renders HTML/CSS/JS from assets/, supports PWA (manifest, service worker).
• Interacts via HTTP(S) with the web server.
• Executes data-visualization scripts (data-to-chart.js, sqleditor.js, wallet.js).
b. Web Server (Apache/Nginx + PHP-FPM)
• Serves static assets (assets/, SQL-builder-NoCode).
• Routes dynamic requests to index.php/pages/*.php.
• Loads includes/ (config, shared header/footer, business logic).
• Handles authentication, sessions, CRUD operations on posts/likes, file uploads.
• Implements wallet API endpoints (wallet/api_wallet.php).
c. Database (MySQL)
• User table, posts table, likes table, file metadata table (mysql schema from includes/config.sql).
• Stores authentication credentials, profile data, social graph, file share metadata.
d. File Storage (Server Filesystem)
• uploads/: stores user files (CSV/JSON/Excel/Image).
• profile_pictures/: avatars.
e. CI/CD & Hosting
• GitHub Actions (.github/workflows/deploy.yml) builds/tests (if any), then deploys code to .hta_host environment.
• .hta_local for local development.
f. External dependencies (optional/inferred)
• Potential email/SMS service for password resets (not in repo but may exist).
• Google Sheets API support (upload CSV/Google Sheet mention).
Relationships & data flows
• User → HTTP Request → Web Server → PHP Execution → MySQL (read/write) → PHP → HTTP Response → User.
• File upload: User → POST file → Web Server saves to uploads/ → metadata written to MySQL → confirmation to User.
• Data-to-chart: User loads JSON/CSV → JS fetches file via HTTP → Chart.js (or custom) renders on browser.
• Social Feed: User posts image/PDF → PHP stores file + post metadata → MySQL update → other users fetch feed.
• PWA: Browser registers sw.js → caches assets/pages → serves cached content offline.
• Routing Layer: index.php + pages/*.php
• Business Logic Layer: includes/functions.php, includes/toggle_share.php, wallet/api_wallet.php
• Config Layer: includes/config.php (.sql)
• PWA Support: manifest.json, sw.js
Architectural patterns & technologies
• MVC-style separation (controllers in pages/, views in includes/, models via functions+MySQL).
• Monolith over microservices—everything runs on one server.
• PWA pattern (offline caching via service worker).
• Front-end tools: vanilla JS, Chart (data-to-chart), SQL-builder No-Code UI.
• Security: prepared statements via includes/functions.php, input sanitization, XSS protection.