Note: This backend project is designed to work seamlessly with the companion frontend project kondim23/connectify-reactjs-frontend (React.js). For a complete experience, clone and run both the backend and frontend repositories.
Connectify is a professional networking web application inspired by LinkedIn, built with Spring Boot, Spring Security, JWT authentication, MySQL, and Maven. It enables users to register, create posts, connect with others, apply for jobs, exchange messages, and receive personalized recommendations. The backend provides secure REST APIs, robust authentication, and scalable architecture for modern web development.
- User registration, authentication, and profile management
- JWT-based stateless security
- Post creation, likes, and media attachments
- MySQL database integration
- RESTful API endpoints
- File upload support (up to 10GB)
- HTTPS/SSL support
- CORS configuration for frontend integration
- Java 17+ (or Java 21 with Spring Boot 3.x)
- Spring Boot
- Spring Security
- Spring Data JPA (Hibernate)
- MySQL
- Maven
- Lombok
- JUnit 5 & MockMvc (for testing)
- Java 17 or 21
- Maven 3.6+
- MySQL 8.x
- (Optional) IDE: VS Code, IntelliJ IDEA, Eclipse
- Clone the repository
git clone https://github.com/kondim23/connectify-springboot-backend.git cd connectify-springboot-backend - Database setup
CREATE DATABASE connectify; CREATE USER 'connectify-test-user'@'localhost' IDENTIFIED BY 'connectify-test-password'; GRANT ALL PRIVILEGES ON connectify.* TO 'connectify-test-user'@'localhost'; FLUSH PRIVILEGES;
- Configuration
Edit
src/main/resources/application.propertiesif needed:spring.datasource.url=jdbc:mysql://127.0.0.1:3306/connectify spring.datasource.username=connectify-test-user spring.datasource.password=connectify-test-password
- Build instructions
./mvnw clean package
- Run instructions
The app will be available at https://localhost:8443.
./mvnw spring-boot:run # or java -jar target/connectify-0.0.1-SNAPSHOT.jar
The application uses a MySQL database with the following main entities and relationships:
- User: Stores user profile and authentication data. Related to posts, likes, views, connections, messages, jobs, job requests, and job views.
- Post: Represents user posts. Related to users, media, likes, views, and comments.
- Media: Stores media files attached to posts.
- Likes: Represents user likes on posts.
- View: Tracks which users have viewed which posts.
- Connection: Represents user-to-user connections (friendships, pending/accepted).
- Message: Stores messages exchanged between users.
- Job: Represents job listings created by users.
- JobRequest: Represents applications to job listings.
- JobView: Tracks which users have viewed which jobs.
- Comment: Stores comments on posts.
- Notification: Stores notifications for likes and comments.
- PostMatrixElement / JobMatrixElement: Used for recommendation system (matrix factorization).
All tables use auto-generated primary keys and foreign keys to manage relationships. The schema supports all main features: users, posts, jobs, connections, messaging, notifications, comments, and recommendations.
This application follows a layered architecture typical for Spring Boot projects:
- Handles HTTP requests and maps them to service methods.
- Located in packages like
com.connectify.User,com.connectify.Posts,com.connectify.Likes, etc. - Example:
UserController,PostController,LikesController. - Uses annotations like
@RestController,@RequestMapping, and@PostMapping.
- Contains business logic and orchestrates data flow between controllers and repositories.
- Example classes:
UserService,PostService,LikeService(if present). - Handles validation, security checks, and transactional operations.
- Uses
@Serviceand@Transactionalannotations.
- Interfaces with the database using Spring Data JPA.
- Example:
UserRepository,PostRepository,LikesRepository,MediaRepository,ViewRepository. - Extends
JpaRepositoryorCrudRepositoryfor CRUD operations. - Uses
@Repositoryannotation.
- Uses Spring Security with JWT for stateless authentication.
- Custom filters like
JWTAuthenticationFilterandJWTAuthorizationFilterhandle token creation and validation. - Security configuration is managed in a class (e.g.,
WebSecurity) using aSecurityFilterChainbean. - Passwords are hashed using
BCryptPasswordEncoder. - Endpoints are protected by roles and JWT tokens; only registration and login are public.
Security Flow:
- User logs in with credentials.
- If valid, a JWT token is generated and returned.
- For protected endpoints, the JWT token must be included in the
Authorizationheader. - Filters validate the token and set the authentication context.
application.propertiesconfigures database, SSL, file upload limits, and security settings.- SSL is enabled for HTTPS on port 8443 using a PKCS12 keystore (
server.p12). - CORS is configured to allow cross-origin requests from any origin.
POST /users/new-user– Register a new userGET /users– List all usersGET /user– Get user by email (param: userEmail)GET /search/{searchData}– Search usersGET /signin– User login (params: userEmail, userPass)PUT /user/{oldEmail}– Update user profilePOST /userimage– Upload user profile imageGET /user/image– Get user profile image (param: userEmail)GET /user/image/remove– Remove user profile image (param: userEmail)
POST /admin/users– Get info for a list of usersPOST /admin– Create/setup a new admin
POST /posts– Create a postGET /allPosts– List all postsGET /posts– Get home page posts (param: userEmail)
POST /likes– Like a postDELETE /likes– Unlike a post (params: userEmail, postId)
POST /comments– Add a comment to a postGET /comments– Get comments of a post (param: postID)
POST /views– Register a view on a post
GET /connections– List all connectionsGET /connections/{email}– Get connections of userGET /connections/users– Get users connected with user (param: userEmail)GET /connections/pending/{email}– Get pending connections of userGET /connections/exist– Check if connection exists (params: email1, email2)POST /connections– Create a new connection requestPUT /connections/accept– Accept a connection (params: userId, senderId)DELETE /connections/discard– Discard a connection (params: userId, userToDisconnectId)
POST /media/upload– Upload media to a postGET /media/type– Get media of a post (param: postId)GET /media/download– Download media by ID (param: mediaId)
GET /jobs– Get recommended jobs for user (param: userEmail)POST /jobs– Create a job listing
POST /jobs/requests– Apply to a jobGET /jobs/requests– Get job requests for user (param: userEmail)GET /jobs/requests/single– Get single job request (params: userEmail, jobId)
POST /job-views– Register a view on a job
GET /messages– List all messagesPOST /messages– Post a new messageGET /messages/{userEmail}– Get chat messages (param: connectedEmail)GET /messages/chatters/{senderEmail}– Get all acceptors for sender
GET /notifications/likecomment– Get like/comment notifications (param: userEmail)
This application already integrates matrix factorization techniques for personalized post and job recommendations. Matrix factorization is a collaborative filtering approach commonly used in recommendation systems (such as those for movies, products, or social feeds).
- User-Item Matrix: The system constructs a matrix where rows represent users and columns represent posts or jobs. Each cell contains a score (e.g., like, view, application, or implicit feedback) based on user interactions.
- Factorization: This matrix is decomposed into two lower-dimensional matrices—one representing user features and one representing item (post/job) features. This reveals latent factors that explain observed interactions.
- Prediction: By multiplying the user and item feature matrices, the system predicts missing scores (i.e., how likely a user is to like or engage with a post/job they haven't seen yet).
- Posts: The application suggests posts to users based on their previous likes, views, and interactions, as well as those of similar users, using the matrix factorization model.
- Jobs: Job postings are recommended by analyzing user profiles, applications, and engagement history, leveraging the same collaborative filtering approach.
- Workflow Example:
- The backend collects user-post and user-job interaction data (likes, views, applications).
- The user-item matrix is built and updated regularly.
- Matrix factorization (e.g., SVD or ALS algorithms) is applied to learn latent features.
- For each user, the system recommends top-N posts or jobs with the highest predicted scores.
- The recommendation engine is implemented as a scheduled service within the backend, updating recommendations as new data arrives.
- Currently, matrix factorization is not directly exposed via REST endpoints, but its results can be used internally to enhance user experience and drive personalized suggestions in the application.
- The implementation uses Java-based libraries and custom logic for matrix factorization and prediction.
This approach enables scalable, data-driven recommendations that improve as more users interact with the platform.
- The recommendation system is tested with a dataset generated in
DatabaseInitialization.java. ApplicationConstants.javacontains theIMPORT_DATASETflag, which, when set to true, imports test records into the database.- The dataset includes users of four specialties (programmer, engineer, economist, doctor) with a specific connection pattern and random connections between specialties.
- Each user has created one post and one job listing, and has viewed and expressed interest in posts and job listings of connected users.
- The recommendation system ranks posts and job listings based on a dynamically calculated score.