# Migrating from Developing Asynchronous Multi-Threading Programs to Reactive Programs in Java
## 5 Proposed Solution
### Project Structure
#### Database Structure  
The database structure supporting the application's services and functionalities is defined according to the diagram in Figure 2.  
* The \"users\" table defines the list of user accounts within the application.
* The \"tweets\" define the list of messages within the application. This table has a many-to-one relationship with the \"mentions\" table, using the foreign key \"tweet_id\" to reference the associated entity.
* The \"hashtags\" table defines the list of tags extracted from message contents.
* The \"mentions\" table defines the user mentions within messages. This table has a many-to-one relationship with the \"tweets\" table using the foreign key \"tweet_id\" to reference the associated entity.
* The \"tweet_hashtag\" table defines the join enabling the many-to-many relationship between messages and tags. This table has a many-to-one relationship with the \"tweets\" using the foreign key \"tweet_id\" and with the \"hashtags\" table using the foreign key \"hashtag_id\" to reference the associated entities.
* The \"follows\" table defines the subscriptions between users.
* The \"likes\" table stores the list of acknowledgments given by users to existing messages or replies.
* The \"replies\" table stores the list of submitted replies by users to existing messages.
* The \"retweets\" table stores the list of redistribution of existing messages by the users.
* _Project Organization_  
The asynchronous and reactive projects share a similar structure for organizing the packages, with the primary aim of capturing and separating the responsibilities of eachmodule, thereby facilitating maintenance and code flexibility. Figure 3 presents the project's detailed package organization structure.  
Figure 3: Package structure for backend services.  
Figure 2: Database diagram.  
The main packages within the projects are:  
* The \"client\" package contains classes for communicating with the other services in the application.
* The \"config\" package centralizes config classes for various components of the application, such as caching, security, etc.
* The \"controller\" package includes classes that expose the application's entry points, receiving and processing user requests.
* The \"entity\" package contains the entities or data models equivalent to the objects persisted in the database.
* The \"exception\" package defines specific exceptions used in the application for error handling.
* The \"mapper\" package groups the classes that provide the conversion between data transfer objects (DTO) and entities.
* The \"model\" package contains models used for transferring information, without directly exposing persistent entities.
* The \"repository\" package includes interfaces and implementations for accessing persistent data and managing database operations.
* The \"service\" package contains the core business logic of the application, which is implemented in classes that organize and sequence calls to repositories and other necessary components.
* The \"util\" package centralizes utility classes, used in various parts of the application, such as validation methods, conversions, etc.