๐ Social Media App with Real-Time Chat and Post Feed (Spring Boot + React)


๐ก What Is It?
This project is a full-stack Social Media Application where users can:
Create personal or business profiles
Post text updates, images, or videos
Connect and interact with friends
Chat with other users in real time
Manage content visibility and privacy
It's built using Spring Boot for the backend and React.js for the frontend, incorporating features like JWT authentication, WebSocket real-time messaging, and responsive UI with Material UI.
๐ฏ Key Features
๐ User Authentication: Register/Login with JWT-based secure sessions.
๐ News Feed: Users can create, update, delete, and view posts.
๐ฌ Live Chat: WebSocket-based real-time chat using STOMP and SockJS.
๐ฑ Responsive Design: UI adapts to desktop and mobile.
๐งฉ Modular Codebase: Component-based frontend and service-layered backend.
๐ธ Media Uploads (extensible): Designed to support file/image/video uploads.
โ๏ธ Admin-friendly setup: REST APIs documented via Swagger (if enabled).
๐ง Tech Stack
Layer | Tools Used |
Frontend | React, Redux, React Router, Material UI |
Backend | Spring Boot 3.5, Spring MVC, Spring WebSocket, Spring Data JPA |
Security | Spring Security with JWT |
Real-time | STOMP over WebSocket, SockJS fallback |
Database | MySQL (can also use MongoDB) |
Dev Tools | Swagger, Git, VSCode, Postman |
โ Problems Faced and โ Solutions
1. JWT Conflicts Between Multiple UserDetailServices
Problem:
Spring Boot threw an error because both AuthService
and UserService
implemented UserDetailsService
, and Spring couldnโt resolve which one to inject.
Solution:
Marked the correct
AuthService
with@Primary
annotation.Alternatively, used
@Qualifier("authService")
in the JWT filter to inject the appropriate service.
2. Deprecated Methods in JWT Library
Problem:
Methods like Jwts.parser()
and signWith(SignatureAlgorithm, String)
were deprecated in newer jjwt
versions.
Solution:
Updated the JWT signing code to use
signWith(key, algorithm)
withSecretKeySpec
.Used
Jwts.parserBuilder()
instead of the deprecated parser.
3. Duplicate <Router>
Error in React
Problem:
React app crashed due to <Router>
being rendered inside another <Router>
.
Solution:
Ensured
<BrowserRouter>
is only declared once at the root level (App.jsx
).All route components use
Routes
andRoute
correctly within that scope.
4. WebSocket STOMP Client Was Not Connecting
Problem:
Frontend was not able to connect to the /ws
endpoint or receive messages.
Solution:
Confirmed that WebSocket endpoint
/ws
was correctly registered in Spring Boot withSockJS
.Allowed CORS in
WebSocketConfig
and ensured Spring Boot server was running at correct host/port.Used
stompClient.connect()
callback to manage post-connect subscriptions.
5. Material UI Styling & Responsiveness
Problem:
Raw React components lacked polish and responsiveness.
Solution:
Replaced basic HTML inputs with Material UI
<TextField>
,<Button>
,<Box>
, etc.Used MUIโs
sx
prop and breakpoints to make chat and post UIs responsive.
6. Frontend Fails on combineReducers()
Problem:Store does not have a valid reducer
error was thrown when setting up Redux.
Solution:
Verified that all reducers were functions and imported correctly.
Ensured
combineReducers({ key: reducer })
was returning a valid object.
๐ Learnings and Best Practices
Prefer
@Primary
or@Qualifier
to avoid ambiguity in Spring's auto-wiring.Keep WebSocket logic modular to support future chat features like private messaging or typing indicators.
Always ensure CORS and endpoint paths are aligned across frontend and backend.
Avoid deeply nested routers in React. Keep your routing hierarchy clean.
Separate chat components (
ChatRoom
,MessageInput
,MessageBubble
) for maintainability.
๐ What's Next?
Planned enhancements:
๐ Private 1-on-1 Chat
๐ผ๏ธ Media Upload and Preview
๐งต Hashtags and Topic Trends
๐ Post search/filter
๐ง AI moderation or summarization of chats and posts (using OpenAI)
๐ง Conclusion
This Social Media App showcases how a full-stack developer can create a scalable, interactive social platform using Spring Boot and React. From authentication to real-time chat, it includes key modern app features and solves common development issues with practical, production-ready solutions.
Subscribe to my newsletter
Read articles from CodeReacher directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

CodeReacher
CodeReacher
Hi, I'm CodeReacher, a budding technical content writer with a passion for simplifying complex tech concepts. I come from a Computer Science background and love creating clear, engaging content around topics like Web development, DevOps, or cloud. I recently started Code Reacher, a blog dedicated to sharing practical, reference-rich tech articles for developers and learners. I'm eager to grow in the field and contribute meaningful content to the tech community.