{"id":15131469,"url":"https://github.com/ayushkhodankar/chatapplication","last_synced_at":"2026-01-18T17:33:29.595Z","repository":{"id":255733843,"uuid":"853499673","full_name":"Ayushkhodankar/ChatApplication","owner":"Ayushkhodankar","description":"This is a RESTful chat application built with Spring Boot that allows users to register, log in, and exchange messages in real-time.","archived":false,"fork":false,"pushed_at":"2025-01-06T15:12:32.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T21:12:05.769Z","etag":null,"topics":["java","jwt-authentication","mysql","spring","spring-boot","spring-security","springjpa"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ayushkhodankar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-09-06T19:26:32.000Z","updated_at":"2025-01-30T18:04:29.000Z","dependencies_parsed_at":"2025-02-11T23:35:24.817Z","dependency_job_id":"440846e8-7849-41e9-813f-bfb3359c4438","html_url":"https://github.com/Ayushkhodankar/ChatApplication","commit_stats":null,"previous_names":["ayushkhodankar/chatapplication"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ayushkhodankar%2FChatApplication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ayushkhodankar%2FChatApplication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ayushkhodankar%2FChatApplication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ayushkhodankar%2FChatApplication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ayushkhodankar","download_url":"https://codeload.github.com/Ayushkhodankar/ChatApplication/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399886,"owners_count":20932880,"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","jwt-authentication","mysql","spring","spring-boot","spring-security","springjpa"],"created_at":"2024-09-26T03:42:13.360Z","updated_at":"2026-01-18T17:33:29.557Z","avatar_url":"https://github.com/Ayushkhodankar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chat Application with Spring Boot, JWT, and Spring Security\n\n\u003ch2\u003eOverview\u003c/h2\u003e\n\u003cp\u003e\n    This is a RESTful chat application built with \u003cstrong\u003eSpring Boot\u003c/strong\u003e that allows users to register, log in, and exchange messages in real-time. The application is secured using \u003cstrong\u003eJWT (JSON Web Tokens)\u003c/strong\u003e for authentication and \u003cstrong\u003eSpring Security\u003c/strong\u003e for authorization.\n\u003c/p\u003e\n\n\u003ch2\u003eFeatures\u003c/h2\u003e\n\u003cul\u003e\n    \u003cli\u003eUser Registration and Login with JWT authentication.\u003c/li\u003e\n    \u003cli\u003eSecure message exchange between users.\u003c/li\u003e\n    \u003cli\u003eMessages are associated with sender and receiver information.\u003c/li\u003e\n    \u003cli\u003eSpring Security handles user authentication and access control.\u003c/li\u003e\n    \u003cli\u003eMySQL database used to store users and chat messages.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch2\u003eTechnologies Used\u003c/h2\u003e\n\u003cul\u003e\n    \u003cli\u003e\u003cstrong\u003eSpring Boot\u003c/strong\u003e - Backend framework.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eSpring Security\u003c/strong\u003e - For authentication and authorization.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eJWT (JSON Web Tokens)\u003c/strong\u003e - For stateless authentication.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eSpring Data JPA\u003c/strong\u003e - For database interaction.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eMySQL\u003c/strong\u003e - Relational database.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch2\u003eGetting Started\u003c/h2\u003e\n\n\u003ch3\u003ePrerequisites\u003c/h3\u003e\n\u003cp\u003eBefore you begin, ensure you have the following installed:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003e\u003cstrong\u003eJava 11+\u003c/strong\u003e\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eMaven\u003c/strong\u003e\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eMySQL\u003c/strong\u003e (or any relational database)\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eInstallation and Setup\u003c/h3\u003e\n\u003col\u003e\n    \u003cli\u003eClone the repository:\n        \u003cpre\u003e\u003ccode\u003egit clone https://github.com/your-username/chat-application.git\u003c/code\u003e\u003c/pre\u003e\n    \u003c/li\u003e\n    \u003cli\u003eNavigate to the project directory:\n        \u003cpre\u003e\u003ccode\u003ecd chat-application\u003c/code\u003e\u003c/pre\u003e\n    \u003c/li\u003e\n    \u003cli\u003eOpen \u003cstrong\u003esrc/main/resources/application.properties\u003c/strong\u003e and configure your database:\n        \u003cpre\u003e\u003ccode\u003e\nspring.datasource.url=jdbc:mysql://localhost:3306/chatdb\nspring.datasource.username=root\nspring.datasource.password=yourpassword\nspring.jpa.hibernate.ddl-auto=update\njwt.secret=mysecretkey\n        \u003c/code\u003e\u003c/pre\u003e\n    \u003c/li\u003e\n    \u003cli\u003eCreate the database in MySQL:\n        \u003cpre\u003e\u003ccode\u003eCREATE DATABASE chatdb;\u003c/code\u003e\u003c/pre\u003e\n    \u003c/li\u003e\n    \u003cli\u003eBuild and run the application:\n        \u003cpre\u003e\u003ccode\u003emvn spring-boot:run\u003c/code\u003e\u003c/pre\u003e\n    \u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch3\u003eRunning the Application\u003c/h3\u003e\n\u003cp\u003eOnce the application is running, it will be available on \u003cstrong\u003ehttp://localhost:8080\u003c/strong\u003e.\u003c/p\u003e\n\n\u003ch4\u003eAPI Endpoints\u003c/h4\u003e\n\u003cul\u003e\n    \u003cli\u003e\u003cstrong\u003ePOST\u003c/strong\u003e \u003ccode\u003e/auth/register\u003c/code\u003e - Register a new user.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003ePOST\u003c/strong\u003e \u003ccode\u003e/auth/login\u003c/code\u003e - Authenticate a user and get a JWT.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003ePOST\u003c/strong\u003e \u003ccode\u003e/chat/send\u003c/code\u003e - Send a message to another user (requires JWT).\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eGET\u003c/strong\u003e \u003ccode\u003e/chat/messages\u003c/code\u003e - Retrieve chat history for the authenticated user (requires JWT).\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch4\u003eSample JSON for Registration\u003c/h4\u003e\n\u003cpre\u003e\u003ccode\u003e\n{\n  \"username\": \"john\",\n  \"password\": \"password123\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch4\u003eSample JSON for Sending a Message\u003c/h4\u003e\n\u003cpre\u003e\u003ccode\u003e\n{\n  \"content\": \"Hello, how are you?\",\n  \"receiverUsername\": \"alice\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch3\u003eAuthentication with JWT\u003c/h3\u003e\n\u003cp\u003eWhen a user successfully logs in using the \u003ccode\u003e/auth/login\u003c/code\u003e endpoint, the server responds with a JWT. This token should be included in the header of every subsequent request to secure endpoints (e.g., sending or fetching messages).\u003c/p\u003e\n\n\u003cp\u003eFor example, add the following header:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eAuthorization: Bearer your-jwt-token\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch2\u003eArchitecture\u003c/h2\u003e\n\u003cp\u003eThe chat application follows a layered architecture:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003e\u003cstrong\u003eController Layer\u003c/strong\u003e: Handles HTTP requests and responses.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eService Layer\u003c/strong\u003e: Contains the business logic and interacts with repositories.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eRepository Layer\u003c/strong\u003e: Manages data persistence using JPA and interacts with the database.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eDatabase Schema\u003c/h3\u003e\n\u003cp\u003eThe application uses two tables:\u003c/p\u003e\n\u003col\u003e\n    \u003cli\u003e\u003cstrong\u003eUsers\u003c/strong\u003e:\n        \u003cul\u003e\n            \u003cli\u003e\u003ccode\u003eid\u003c/code\u003e: Auto-generated user ID.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003eusername\u003c/code\u003e: Unique username.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003epassword\u003c/code\u003e: Encrypted user password.\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eChat Messages\u003c/strong\u003e:\n        \u003cul\u003e\n            \u003cli\u003e\u003ccode\u003eid\u003c/code\u003e: Auto-generated message ID.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003econtent\u003c/code\u003e: Text content of the message.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003esender_id\u003c/code\u003e: ID of the user who sent the message.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003ereceiver_id\u003c/code\u003e: ID of the user who received the message.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003etimestamp\u003c/code\u003e: When the message was sent.\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch2\u003eSecurity\u003c/h2\u003e\n\u003cp\u003eThe application uses \u003cstrong\u003eSpring Security\u003c/strong\u003e to secure user registration, login, and messaging functionalities:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003eAll endpoints, except for \u003ccode\u003e/auth/register\u003c/code\u003e and \u003ccode\u003e/auth/login\u003c/code\u003e, are secured and require a valid JWT token.\u003c/li\u003e\n    \u003cli\u003ePasswords are stored in an encrypted format using BCrypt.\u003c/li\u003e\n    \u003cli\u003eJWT tokens are used to authorize users for accessing protected endpoints.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch2\u003eTesting the API\u003c/h2\u003e\n\u003cp\u003eYou can test the API using tools like \u003cstrong\u003ePostman\u003c/strong\u003e or \u003cstrong\u003ecURL\u003c/strong\u003e. Here's an example of using cURL to test the login functionality:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e\ncurl -X POST http://localhost:8080/auth/login -H \"Content-Type: application/json\" -d '{\n  \"username\": \"john\",\n  \"password\": \"password123\"\n}'\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003cp\u003eThis will return a JWT token which can then be used to access the secure \u003ccode\u003e/chat/send\u003c/code\u003e and \u003ccode\u003e/chat/messages\u003c/code\u003e endpoints.\u003c/p\u003e\n\n\u003ch2\u003eContributing\u003c/h2\u003e\n\u003cp\u003eIf you'd like to contribute to the project, feel free to submit a pull request or open an issue on the GitHub repository. All contributions are welcome!\u003c/p\u003e\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\u003cp\u003eThis project is licensed under the MIT License.\u003c/p\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayushkhodankar%2Fchatapplication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayushkhodankar%2Fchatapplication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayushkhodankar%2Fchatapplication/lists"}