Introducing Fenix's BookStore Backend: A Monolithic Architecture Approach
Fenix's BookStore backend project, known as monolithic_arch_springboot, is an exemplary implementation of a bookstore system using a monolithic architecture. This architecture serves as the initial version of the bookstore's backend and aligns with future versions that will be developed using microservices, service mesh, and serverless architectures, all demonstrating the same business functionalities.
Understanding the Monolithic Architecture
For those new to the concept of "The Fenix Project," it's beneficial to start by exploring its comprehensive guide. The monolithic architecture is straightforward and easy to grasp, making it an excellent entry point into understanding modern software architecture. It lays a solid foundation for transitioning to more complex architectures like microservices.
Running the Program
There are several methods to deploy and run this application, allowing users to interact with the system effortlessly:
Using Docker
One convenient method is deploying the application as a Docker container by executing:
$ docker run -d -p 8080:8080 --name bookstore icyfenix/bookstore:monolithic
After execution, access the application through your browser at http://localhost:8080. The system has a pre-existing user with credentials (user: icyfenix, pw: 123456), and new users can register for testing.
This setup uses HSQLDB in-memory mode by default, which doesn’t persist data post execution. To use a file-based setup or another independent database like MySQL, activate the configuration with the "PROFILES" environment variable:
$ docker run -d -p 8080:8080 --name bookstore icyfenix/bookstore:monolithic -e PROFILES=mysql
Remember, you'll need appropriate database connectivity, referencing the application’s configuration files.
Running from Source Code with Maven
To run the program directly from the source using Maven, follow these steps:
-
Clone the repository:
$ git clone https://github.com/fenixsoft/monolithic_arch_springboot.git
-
Navigate to the project directory:
$ cd monolithic_arch_springboot
-
Build the project:
$ ./mvnw package
-
Deploy the application:
$ java -jar target/bookstore-1.0.0-Monolithic-SNAPSHOT.jar
Access the application at http://localhost:8080.
Running in an IDE
For development enthusiasts, running the project within an IDE like IntelliJ IDEA simplifies the process:
- Clone and open the project using the Maven import option.
- IntelliJ recognizes the SpringBoot framework and sets up BookstoreApplication as the initial startup class.
- Execute the main method in BookstoreApplication to start the system.
Technical Components
The backend is crafted using standard Java technology specifications without being tied to specific implementations, allowing flexibility. Key components include:
- RESTful Services: Implemented with JAX-RS (Jersey 2).
- Dependency Injection: Provided by SpringBoot's Spring Framework.
- Persistence: Managed through Spring Data JPA.
- Data Validation: Achieved with Hibernate Validator.
- Web Server: Delivered by embedded Tomcat, which can be swapped with Jetty or Undertow.
Certain non-standard implementations, like authentication via Spring Security, are used due to the lack of native OAuth2 and JWT support in JSR 375.
Project Structure
The design follows a Domain-Driven Design (DDD) layered architecture, primarily organized into four layers:
- Resource Layer: Corresponds to the UI layer, facilitating user interactions, typically via RESTful APIs.
- Application Layer: Exposes the core functionalities of the software and orchestrates tasks among domain objects.
- Domain Layer: Contains the business logic, focusing on business concepts, state information, and rules.
- Infrastructure Layer: Provides utility services like persistence and remote communication, supporting other layers.
Licensing
The code utilizes the Apache 2.0 License, allowing freedom to modify and redistribute, provided proper attribution and the inclusion of the license. The documentation follows a Creative Commons Attribution 4.0 International License, allowing sharing and adaptation under similar terms with non-commercial clauses.
In summary, Fenix's BookStore backend is an ideal starting point for understanding monolithic architecture and provides insightful exposure to software architecture evolution.