Introduction
Overview
The development process involves two main repositories: laravel-website and WHAM, each serving a specific purpose within the project structure. The Service Repository Design Pattern is employed for efficient data management and separation of concerns.
- Toolstation - Laravel : This repository hosts the Laravel-based implementation of the Toolstation website, containing specific website-related code and configurations.
- Shared Code Base : WHAM acts as a shared codebase, providing Interfaces, Service layer, Repository layer, and Models. It serves as the foundation for the Laravel website, offering generic functionalities.
The Laravel project utilizes many more repositories, but these are the two main repositories that are used for initial setup, for more information on the other repositories, please refer to the Repositories section.
Design pattern : Service Repository Design Pattern
The project follows the Service Repository Design Pattern, ensuring a clear separation between business logic and data access logic. This pattern enhances modularity and simplifies maintenance.
Shared Codebase Components
- Interfaces: Located within the
contractsfolder of WHAM, interfaces define the contract for various components. For instance:
// ProductServiceInterface within WHAM
interface ProductServiceInterface {
public function getProductById($productId);
// Other method declarations...
}
- Service Layer: WHAM contains implementations of interfaces. For example,
ProductServiceimplementsProductServiceInterface
// ProductService implementation within WHAM
class ProductService implements ProductServiceInterface {
public function getProductById($productId) {
// Logic to retrieve product by ID
}
// Other method implementations...
}
- Repository Layer: Concrete implementations of repositories are found in WHAM, providing methods for data access:
// ProductRepository implementation within WHAM
class ProductRepository implements ProductRepositoryInterface {
public function getProductById($productId) {
// Database query to retrieve product by ID
}
// Other database operations...
}
Overrides and Customizations
Any specific implementations or overrides related to Interfaces, Service layer, Repository layer, or Models for the Toolstation website should be implemented inside the laravel-website repository. For example, if a customized product service is required
// CustomProductService extending ProductService
class CustomProductService extends ProductService {
public function getProductById($productId) {
// Custom logic to retrieve product by ID specific to the Laravel website
}
// Additional customizations...
}
Technologies Used
Backend
- PHP Version
7.0.33 - Node Version
12.16 - Laravel Version
5.5
Frontend
- VueJS Version
2.6.12 - Vuex Version
3.1.0
Database Connection
- Currently, the default value for
DB_CONNECTIONis set to main. - The website employs two types of database hosts for distinct operations.
- The
MASTERdatabase is utilized for bothReadandWriteoperations. - The
SLAVEdatabase, on the other hand, is exclusively used forReadoperations. - You can verify the database connection using tools such as MySQL Workbench or any other suitable tool.
Conclusion
By following the Service Repository Design Pattern and segregating shared functionalities in WHAM from website-specific implementations in the laravel-website repository, the Toolstation website development team ensures a scalable, modular, and maintainable codebase. Developers can efficiently collaborate, extend functionalities, and customize the website according to specific requirements while building upon a robust foundation provided by the WHAM shared codebase.