Wannonces : announcements platform with integrated messaging in PHP

Wannonces : announcements platform with integrated messaging in PHP (February 2025)
Introduction and context
This project was carried out as part of an individual continuous assessment project in the second year of the Computer Science BUT. The objective: to improve an existing PHP classified announcements platform by adding a complete messaging feature.
The messaging functionality was created in two and a half days, under great constraint. As the interface was secondary, I spent little time on it.
The initial platform allowed viewing announcements, but without any way to contact the authors. I therefore designed and implemented a hierarchical messaging system allowing users to exchange around published announcements.
- Problem: How to allow users of an announcements platform to communicate with each other in a structured way?
- Objective: Develop a messaging system with nested replies, while respecting the MVC architecture and clean architecture principles.
Project architecture
The MVC Pattern
The project follows a modified Model-View-Controller (MVC) pattern, with a clear separation of responsibilities:
- Model (domain/): The entities
Post,User,Messages, andUserPostsrepresent business data - View (gui/): The
View*classes generate the HTML displayed to the user - Controller (control/):
Controllers.phphandles user actions,Presenter.phpprepares data for display
Layered architecture
The code is organized into distinct layers:
This organization allows modifying a layer without impacting the others. For example, changing the database would only require modifying DataAccess.php.
The messaging system
Database design
I created a Messages table with the following fields:
messageid: unique identifierpostid: link to the relevant announcementsenderlogin: author of the messagecontent: message contentdate: timestampparentid: reference to the parent message (for replies)
The parentid field allows creating a tree structure: a message can be a reply to another message, thus forming discussion threads.
Building the message tree
The MessageService class contains the tree construction algorithm. The process is done in two passes:
- First pass: creation of an array indexed by
messageidfor quick access - Second pass: attaching each message to its parent via
parentid
Messages without a parent (parentid null or 0) become root messages. This approach avoids recursive SQL queries and works in O(n).
Hierarchical display
The Presenter generates the HTML recursively. Each nesting level receives an alternating CSS class (color-primary / color-secondary) to visually distinguish conversation levels.

Display of a discussion thread with several levels of replies. The color alternation facilitates reading.
Implemented features
Authentication
The application has a login system based on PHP sessions. Each protected page verifies the presence of a valid session before displaying its content.
List of announcements
After logging in, the user accesses the list of announcements sorted by descending date. Each announcement displays its title and author.
Viewing an announcement
The detail page displays the title, author, publication date, and complete content of the announcement. A button allows access to messages.
Creating announcements
Connected users can publish new announcements via a dedicated form.
Messaging per announcement
Each announcement has its own discussion space. Users can post messages and reply to existing messages.
Nested replies
The system allows replying directly to a message. The reply is displayed below the original message, with a visual offset.
Centralization of messages
A dedicated page allows the user to see all messages received on their announcements, grouped by announcement.
Navigation
A menu allows access to the different sections: announcements, creation, messages, and logout.
Possible actions
The main possible actions:
- Log in / Log out
- View the list of announcements
- View the detail of an announcement
- Create a new announcement
- Send a message on an announcement
- Reply to an existing message
- View received messages
Technical choices
PDO and prepared statements
Database access uses PDO with prepared statements for write operations. This approach protects against SQL injections.
Date formatting
Dates are formatted in French directly in the Presenter, with an array of translated months. The display "23 janvier 2025 14:30:00" is more readable than a raw timestamp.
CSS and readability
The style uses a palette of blues (#406882, #2C5876) on a dark background (darkslategray). Golden links (gold) contrast with the background to remain visible.
Summary and skills
This project allowed me to consolidate several skills:
- Software architecture: practical application of the MVC pattern and layered architecture
- PHP and OOP: namespaces, classes, inheritance, dependency injection
- Database: relational schema design, SQL queries, PDO
- Algorithms: tree construction from flat data, recursive traversal
- User interface: HTML forms, sessions, navigation
The code produced is maintainable and extensible. Adding a new type of message or a moderation feature would only require localized modifications.
Gallery





















Login page - The sober and functional welcome interface





















