ChâTop is a rental property management backend API built with Spring Boot. This project provides a comprehensive REST API for managing rental properties in tourist areas, including user authentication, property listings, and messaging system. The backend serves as the foundation for the existing Angular frontend application, replacing the previously used mock data from Mockoon and Postman.
- User Authentication & Authorization: JWT-based authentication system
- Rental Property Management: CRUD operations for rental properties
- User Management: User registration, login, and profile management
- Messaging System: Communication between users and property owners
- RESTful API: Well-structured REST endpoints
- Database Integration: MySQL database with JPA/Hibernate
- API Documentation: OpenAPI/Swagger documentation
- Security: Spring Security with OAuth2 resource server
Before running this project, make sure you have the following installed:
- Java 21 or higher
- Maven 3.9 or higher
- MySQL 8.0 or higher
- Git (for cloning the repository)
git clone https://github.com/IbrahimAlsabr/ChaTop.git
cd rentals-backend- Create a MySQL database named
rentals_database - Update the database credentials in
src/main/resources/application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/rentals_database spring.datasource.username=your_username spring.datasource.password=your_password
# On Windows
./mvnw.cmd spring-boot:run
# On Unix/Linux/macOS
./mvnw spring-boot:runmvn spring-boot:runThe application will start on http://localhost:8080
Once the application is running, you can access the interactive API documentation at:
- Swagger UI:
http://localhost:8080/swagger-ui.html - OpenAPI JSON:
http://localhost:8080/v3/api-docs
The project follows a layered architecture pattern with clear separation of concerns:
- Controller Layer: REST controllers handle HTTP requests and responses, implementing the API endpoints
- Service Layer: Business logic implementation, containing the core application functionality
- Repository Layer: Data access abstraction using Spring Data JPA repositories
- Entity Layer: JPA entities representing the database schema
- DTO Layer: Data Transfer Objects for API communication and data validation
- Configuration Layer: Security configuration, JWT setup, and application configuration
This architecture ensures maintainability, testability, and follows Spring Boot best practices for enterprise applications.
POST /api/auth/login- User loginPOST /api/auth/register- User registrationGET /api/auth/me- Get current user profile
GET /api/rentals- Get all rental propertiesGET /api/rentals/{id}- Get rental by IDPOST /api/rentals- Create new rental (authenticated)PUT /api/rentals/{id}- Update rental (authenticated)DELETE /api/rentals/{id}- Delete rental (authenticated)
GET /api/messages- Get user messages (authenticated)POST /api/messages- Send message (authenticated)
To build the application for production:
./mvnw clean packageThe JAR file will be created in the target/ directory.
This backend is designed to work with the existing Angular frontend. The frontend repository can be found at: OpenClassrooms Frontend Repository
ChâTop est une API backend de gestion de locations immobilières construite avec Spring Boot. Ce projet fournit une API REST complète pour gérer les propriétés locatives dans les zones touristiques, incluant l'authentification des utilisateurs, les annonces de propriétés et le système de messagerie. Le backend sert de fondation pour l'application frontend Angular existante, remplaçant les données mockées précédemment utilisées via Mockoon et Postman.
- Authentification et Autorisation des Utilisateurs : Système d'authentification basé sur JWT
- Gestion des Propriétés Locatives : Opérations CRUD pour les propriétés locatives
- Gestion des Utilisateurs : Inscription, connexion et gestion des profils utilisateurs
- Système de Messagerie : Communication entre utilisateurs et propriétaires
- API RESTful : Points de terminaison REST bien structurés
- Intégration Base de Données : Base de données MySQL avec JPA/Hibernate
- Documentation API : Documentation OpenAPI/Swagger
- Sécurité : Spring Security avec serveur de ressources OAuth2
Avant d'exécuter ce projet, assurez-vous d'avoir installé :
- Java 21 ou supérieur
- Maven 3.9 ou supérieur
- MySQL 8.0 ou supérieur
- Git (pour cloner le dépôt)
git clone https://github.com/IbrahimAlsabr/ChaTop.git
cd rentals-backend- Créez une base de données MySQL nommée
rentals_database - Mettez à jour les identifiants de la base de données dans
src/main/resources/application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/rentals_database spring.datasource.username=votre_nom_utilisateur spring.datasource.password=votre_mot_de_passe
# Sur Windows
./mvnw.cmd spring-boot:run
# Sur Unix/Linux/macOS
./mvnw spring-boot:runmvn spring-boot:runL'application démarrera sur http://localhost:8080
Une fois l'application en cours d'exécution, vous pouvez accéder à la documentation interactive de l'API à :
- Swagger UI :
http://localhost:8080/swagger-ui.html - OpenAPI JSON :
http://localhost:8080/v3/api-docs
Le projet suit un modèle d'architecture en couches avec une séparation claire des responsabilités :
- Couche Contrôleur : Les contrôleurs REST gèrent les requêtes et réponses HTTP, implémentant les points de terminaison de l'API
- Couche Service : Implémentation de la logique métier, contenant les fonctionnalités principales de l'application
- Couche Repository : Abstraction d'accès aux données utilisant les repositories Spring Data JPA
- Couche Entité : Entités JPA représentant le schéma de base de données
- Couche DTO : Objets de Transfert de Données pour la communication API et la validation des données
- Couche Configuration : Configuration de sécurité, configuration JWT et configuration de l'application
Cette architecture assure la maintenabilité, la testabilité et suit les meilleures pratiques Spring Boot pour les applications d'entreprise.
POST /api/auth/login- Connexion utilisateurPOST /api/auth/register- Inscription utilisateurGET /api/auth/me- Obtenir le profil de l'utilisateur actuel
GET /api/rentals- Obtenir toutes les propriétés locativesGET /api/rentals/{id}- Obtenir une location par IDPOST /api/rentals- Créer une nouvelle location (authentifié)PUT /api/rentals/{id}- Mettre à jour une location (authentifié)DELETE /api/rentals/{id}- Supprimer une location (authentifié)
GET /api/messages- Obtenir les messages de l'utilisateur (authentifié)POST /api/messages- Envoyer un message (authentifié)
Pour construire l'application pour la production :
./mvnw clean packageLe fichier JAR sera créé dans le répertoire target/.
Ce backend est conçu pour fonctionner avec le frontend Angular existant. Le dépôt frontend peut être trouvé à : Dépôt Frontend OpenClassrooms