A full-stack social media application built with Spring Boot (Backend) and React (Frontend). The project is primarily focused on clean RESTful API design, backend architecture, and real-world business logic, supported by a lightweight but functional frontend.
This repository demonstrates secure authentication, role-based authorization, DTO-driven data exposure, and scalable backend patterns, along with a modern React-based UI to showcase API functionality.
-
Enhanced Frontend Architecture
- Introduced
AuthContextfor global authentication and role management - Refactored
TweetListinto reusableTweetItemcomponents
- Introduced
-
Optimistic UI Updates
- Like and Retweet actions provide instant visual feedback before server response
-
Robust Error Handling
- Backend:
GlobalExceptionHandlerfor consistent and meaningful API errors - Frontend:
react-toastifyfor user-friendly notifications (e.g. duplicate username, unauthorized actions)
- Backend:
-
Feed Pagination
- Main tweet feed supports pagination to avoid heavy data loading and improve performance
-
Extended Test Coverage
- Backend unit and integration tests cover validation errors, authorization rules, and edge cases
-
Codebase Cleanup
- Removed unnecessary comments
- Fixed Turkish character encoding issues
- Improved overall readability and maintainability
- Secure user registration and login
- Role-Based Access Control (RBAC) with
USERandADMINroles - HTTP Basic Authentication with BCrypt password hashing
- Create, Read, Update, Delete (CRUD) tweets
- Feed endpoint supports pagination
- Feed sorting based on creation time and retweet count
- Like / Dislike
- Toggle-based system with duplicate prevention
- Backend returns
likedstatus for the current user
- Retweet
- Retweet with self-retweet prevention
- Backend returns
isRetweetedstatus for the current user
- Comments
- Add, update, and delete comments (CRUD)
- View user profiles including their tweets and retweets
- Admin-only endpoints and UI to list and manage users
- Layered architecture: Controller, Service, Repository, Entity
- DTO Pattern to prevent direct entity exposure and protect sensitive data
- Global exception handling for validation, authorization, and business rule violations
- Built as a demonstrative UI to interact with and showcase backend capabilities
- Modular component design with reusable tweet and comment components
- Global state management using React Context API (
AuthContext) - Responsive UI using Tailwind CSS
- Real-time counters with Optimistic UI updates
- Inline tweet and comment editing
- Dropdown menus for tweet and comment actions
- Notifications via react-toastify
- SPA navigation with React Router DOM
- Protected routes for Admin-only views
- Language: Java 17
- Framework: Spring Boot 3.x (Web, Data JPA, Security, Validation)
- Database: PostgreSQL
- Build Tool: Maven
- Testing: JUnit 5, Mockito
- Library: React 19
- Build Tool: Vite
- Styling: Tailwind CSS
- State Management: React Hooks & Context API
- HTTP Client: Axios
This project is organized as a monorepo containing both backend and frontend applications:
twitter-api-application/
├── twitter-api-backend/ # Spring Boot Application
│ ├── src/
│ ├── mvnw
│ └── pom.xml
└── twitter-api-frontend/ # React Application
├── src/
├── package.json
└── vite.config.js
- Java 17 or higher
- Node.js & npm
- PostgreSQL (running on port 5432, database named
twitter)
Navigate to the backend directory:
cd twitter-api-backendConfigure your database in src/main/resources/application.properties if needed.
Run the application:
# Windows
./mvnw spring-boot:run
# Linux/Mac
./mvnw spring-boot:runThe backend will start on http://localhost:3000.
To grant ADMIN privileges to a user:
-
Register a new user with the username "admin" (or any desired username for the admin).
-
After registration, execute the following SQL command in your PostgreSQL client (e.g., pgAdmin, psql) to assign the
ADMINrole to this user:INSERT INTO public.user_role (user_id, role_id) SELECT u.id, r.id FROM user_account u, app_role r WHERE u.username = 'admin' AND r.authority = 'ADMIN' ON CONFLICT (user_id, role_id) DO NOTHING;
Navigate to the frontend directory:
cd twitter-api-frontendInstall dependencies:
npm installRun the development server:
npm run devThe frontend will start on http://localhost:3200.
The backend includes unit and integration tests. To run them:
cd twitter-api-backend
./mvnw clean testOğuzhan KAYA
- GitHub: https://github.com/Devoguzkaya