{"id":16648991,"url":"https://github.com/rohan-bhautoo/gym-software","last_synced_at":"2025-03-12T12:14:58.556Z","repository":{"id":136017648,"uuid":"458926173","full_name":"rohan-bhautoo/Gym-Software","owner":"rohan-bhautoo","description":"The Gym-Software is a network application, based in Java, which utilises multi-threaded programming and is connected to a database.","archived":false,"fork":false,"pushed_at":"2022-07-06T18:32:45.000Z","size":553,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-19T05:45:15.956Z","etag":null,"topics":["java","multithreading","network-application","server-client-application","socket-programming"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rohan-bhautoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-13T20:41:19.000Z","updated_at":"2024-12-29T22:36:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"32514e1c-f765-4d5a-a62e-b91be914de8b","html_url":"https://github.com/rohan-bhautoo/Gym-Software","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FGym-Software","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FGym-Software/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FGym-Software/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohan-bhautoo%2FGym-Software/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohan-bhautoo","download_url":"https://codeload.github.com/rohan-bhautoo/Gym-Software/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243213981,"owners_count":20254902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","multithreading","network-application","server-client-application","socket-programming"],"created_at":"2024-10-12T09:06:15.904Z","updated_at":"2025-03-12T12:14:58.534Z","avatar_url":"https://github.com/rohan-bhautoo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"200\" height=\"200\" src=\"https://github.com/rohan-bhautoo/Gym-Software/blob/main/gym_software_logo.png\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eGym Software\u003c/h1\u003e\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.0-brightgreen.svg\" /\u003e\n  \u003cimg alt=\"Java\" src=\"https://img.shields.io/badge/Java-ED8B00?logo=java\u0026logoColor=white\" /\u003e\n  \u003cimg alt=\"MariaDB\" src=\"https://img.shields.io/badge/MariaDB-964B00?logo=mariadb\u0026logoColor=white\" /\u003e\n  \u003cimg alt=\"JDK\" src=\"https://img.shields.io/badge/JDK-\u003e=11.0.14-blue.svg\" /\u003e\n\u003c/p\u003e\n\n## Description\n\u003e The Gym Software is a network application, based in Java, which utilises multi-threaded programming and is connected to a database. The software implementation will enable staff members to add, update, delete and view the bookings of each client.\n\u003e \n\u003e With the use of multi-threading, the Gym Software will be accessible to mutiple clients to connect at the same time and interact with the database.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"400\" src=\"https://github.com/rohan-bhautoo/Gym-Software/blob/main/Images/Main.png\"\u003e\n\u003c/p\u003e\n\n## Prerequisite\n\n### Java Development Kit (JDK) \n\u003e JDK version 11 is used for this project as it includes the JavaFX library. Download it [here](https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html).\n\u003e \n\u003e For Windows:\n```sh\nset JAVA_HOME=\"C:\\[Path to folder]\\Java\\jdk-11.0.14\n```\n\u003e Enter the Environment Variables in System Properties.\n\u003e \n\u003e Add **%JAVA_HOME%\\bin** into Path.\n```sh\n%JAVA_HOME%\\bin\n```\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"400\" src=\"https://github.com/rohan-bhautoo/Point-Of-Sales-System/blob/master/Screenshots/Env%20Variable.png\"\u003e\n\u003c/p\u003e\n\n### MariaDB\n\u003e MariaDB Server is one of the most popular open source relational databases. It’s made by the original developers of MySQL and guaranteed to stay open source. It is part of most cloud offerings and the default in most Linux distributions. Download it [here](https://mariadb.org/download/).\n\u003e \n\u003e The five tables below will be used to store information in the database.\n\n\u003ctable align=\"center\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003eTrainer\u003c/th\u003e\n    \u003cth\u003eClient\u003c/th\u003e\n    \u003cth\u003eSpecialism\u003c/th\u003e\n    \u003cth\u003eBooking\u003c/th\u003e\n    \u003cth\u003eTrainerSpecialism\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\u003ctd\u003e\n         \n| TrainerID (PK) | \n| :------------- |\n| Name           |   \n| Sex            |   \n| Phone          |\n      \n\u003c/td\u003e\u003ctd\u003e\n      \n| ClientID (PK) |\n| :------------ |\n| ClientName    |\n| Weight        |\n      \n\u003c/td\u003e\u003ctd\u003e\n    \n| SpecialismID (PK) |\n| :---------------- |\n| Focus             |\n| Duration          |\n| Cost              |\n    \n\u003c/td\u003e\u003ctd\u003e\n      \n| BookingID (PK)    |\n| :---------------- |\n| BookingDate       |\n| StartTime         |\n| ClientID (FK)     |\n| SpecialismID (FK) |\n| TrainerID (FK)    |\n    \n\u003c/td\u003e\u003ctd\u003e\n    \n| SpecialismID (FK) |\n| :---------------- |\n| TrainerID (FK)    |\n    \n\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n### JDBC Driver\n\u003e A JDBC driver is a software component enabling a Java application to interact with a database. \n\u003e \n\u003e To connect with individual databases, JDBC (the Java Database Connectivity API) requires drivers for each database. The JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database. Download the JDBC Driver [here](https://www.mysql.com/products/connector/).\n\n## Software Design\n\u003e A Server-Client setup refers to socket programming in Java where a client sends messages to the server and the server shows them using a socket connection.\n\u003e \n\u003e A socket in Java is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"200\" src=\"https://github.com/rohan-bhautoo/Gym-Software/blob/main/Images/Socket-connection.png\"\u003e\n\u003c/p\u003e\n\n### Server\n\u003e The server will instantiate its object and wait for the client request. Once the client sends the request, the server will communicate back with the response.\n\u003e \n\u003e The ServerSocket is binded to the port number 8080, which is passed as an argument to the constructor of the class ServerSocket.\n```java\nfinal int PORT = 8080;\ntry (ServerSocket serverSocket = new ServerSocket(PORT)) {\n  while (true) {\n    Socket socket = serverSocket.accept();\n    new Thread(new ServerRunnable(socket)).start();\n  }\n}\n```\n\n\u003e The getOutputStream() method is used to send the output through the socket.\n```java\nOutputStream outputStream = socket.getOutputStream();\n```\n\n\u003e The getInputStream() method is used to receive messages, through the socket, from the Client side.\n```java\nInputStream inputStream = socket.getInputStream();\n```\n\n\u003e Database connection is set in the [ServerRunnable.java](/Gym%20Software/src/ServerRunnable.java).\n```java\nprivate Connection connection = Database.connectDb();\n```\n\n### Client\n\u003e In order to establish a connection to the server, a socket is required.\n```java\nString hostName = \"localhost\";\nint port = 8080;\nSocket socket = new Socket(hostName, port);\n```\n\u003e where the first argument is the IP addres of Server (127.0.0.1/localhost) and the second argument is the TCP port which will be the same on the server-side. \n\n### Testing\n\u003e Testing shows that the software has meet its requirements and it is printing the expected output.\n\n#### Validation Testing\n\u003e Before sending data to the server, the client side must validate the user input. In the gym software, regex expressions are used to validate all user inputs from console.\n\n##### IDs\n```java\n^[B][0-9]{3}+$\n```\n\n\u003e The ^ symbol means the start of the string which is the user input and $ sign is end of string. In the regex above, the string must always start with a capital B and continue with only 3 numeric values.\n\u003e \n\u003e Examples:\n\u003e \n\u003e Good format: B001, B123, B999 \n\u003e \n\u003e Bad format: C001, B0001, JC21, BB01\n\u003e \n\u003e The same format is used to validate the trainerID, SpecialismID and ClientID.\n\n##### Date\n```java\n\\d{4}\\\\-(0?[1-9]|1[012])\\\\-(0?[1-9]|[12][0-9]|3[[01])*\n```\n\u003e The “\\\\d{4}” ensures that the user input for year is YYYY. The “(0?[1-9]|1[012])” part checks if user months input is between 01 to 12. And the last part allows only numbers between 01 to 31 to be accepted.\n\n##### Time\n```java\n([01]?[0-9]|2[0-3]):[0-5][0-9]\n```\n\u003e It ensures that the time is between 00:00 to 23:59. Even 9:0 is accepted but it will be reconverted to 09:00 in the table booking.\n\n## Usage\n\u003e After installing MariaDB, import the table from [SQL](/Gym%20Software/src/SQL/GymTable.sql) folder, to the database, using the following command.\n```sh\nmysql -u root -p\n```\n\n```sh\nsource C:\\[Path to folder]\\SQL\\GymTable.sql\n```\n\u003e The [Server.java](/Gym%20Software/src/Server.java) will have to be executed first, then the [Client.java](/Gym%20Software/src/Client.java).\n```sh\njavac *.java\n```\n```sh\njava Server\n```\n```sh\njava Client\n```\n\n### Commands\n\u003e Use the following commands in order to use the software.\n\n#### Add Booking\n```sh\nADD \u003cBookingID\u003e \u003cBookingDate\u003e \u003cStartTime\u003e \u003cClientID\u003e \u003cSpecialismID\u003e \u003cTrainerID\u003e\n```\n\n#### List All Bookings\n```sh\nLISTALL\n```\n\n#### List Personal Trainer\n```sh\nLISTPT \u003cTrainerID\u003e\n```\n\n#### List Client Bookings\n```sh\nLISTCLIENT \u003cClientID\u003e\n```\n\n#### List Booking Date\n```sh\nLISTDAY \u003cBookingDate\u003e\n```\n\n#### Update Booking\n```sh\nUPDATE UPDATE \u003cBookingDetail\u003e \u003cNewValue\u003e \u003cBookingID\u003e\n```\n\n#### Delete Booking\n```sh\nDELETE \u003cBookingID\u003e\n```\n\n## Author\n\n👤 **Rohan Bhautoo**\n\n* Github: [@rohan-bhautoo](https://github.com/rohan-bhautoo)\n* LinkedIn: [@rohan-bhautoo](https://linkedin.com/in/rohan-bhautoo)\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohan-bhautoo%2Fgym-software","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohan-bhautoo%2Fgym-software","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohan-bhautoo%2Fgym-software/lists"}