Watch the demo video below:
This project is a social networking web application built with Java and Spring Boot, allowing users to interact through posts, comments, and likes. It is designed to manage user sessions and provide a user-friendly interface for engaging with content.
- User Registration: New users can register and be saved into the database.
- User Login & Sessions: Session management ensures that user sessions are handled securely.
- Posts Management: Users can create and view posts.
- Commenting System: Users can add comments to posts and delete their comments.
- Likes: Users can like posts.
- Navigation: Simple navigation for users to browse different sections of the app.
The project follows a typical Java Spring Boot structure. Below is an overview of the main directories and files:
- config:
SecurityConfiguration.java
: Handles security and authentication configurations.
- controller:
CommentController.java
: Manages creating and deleting comments.HomeController.java
: Handles requests for the home page.LikesController.java
: Manages like actions on posts.NavbarController.java
: Manages the navigation bar and its interactions.PostLoginController.java
: Handles actions post-login.PostsController.java
: Manages creating, displaying, and interacting with posts.SessionController.java
: Manages session checks to ensure user authentication.UsersController.java
: Handles user registration and user-related operations.
- model:
Comment.java
: Represents the comment entity.Like.java
: Represents the like entity.Post.java
: Represents the post entity.User.java
: Represents the user entity.
- repository:
CommentRepository.java
: Data access forComment
entities.LikeRepository.java
: Data access forLike
entities.PostRepository.java
: Data access forPost
entities.UserRepository.java
: Data access forUser
entities.
- db/migration:
- Contains SQL scripts for database migrations:
V1_init.sql
: Initial database setup.V2_create_users_table.sql
: Creates the users table.V3_add_timestamp_column.sql
: Adds a timestamp column to tables.V4_no_nulls.sql
: Ensures no null values for critical fields.V5_add_user_id_to_posts.sql
: Adds user IDs to the posts.V6_likes_table.sql
: Creates the likes table.V7_create_comments_table.sql
: Creates the comments table.
- Contains SQL scripts for database migrations:
- static:
- images: Contains images for the application.
main.css
: Stylesheet for the application.
- templates:
- fragments:
confirmation.html
,confirmation_comment.html
: Confirmation messages.edit.html
,edit_comment.html
: Templates for editing posts and comments.footer.html
,new_comment.html
,postcards.html
: UI elements.
- posts:
index.html
: Home page for posts with a list of posts and forms for creating and commenting on posts:contentReference[oaicite:0]{index=0}.feed.html
: Displays a central feed of posts with functionality for adding and editing posts and comments:contentReference[oaicite:1]{index=1}.friends.html
: Manages friend interactions, displaying a list of friends:contentReference[oaicite:2]{index=2}.my-posts.html
: Shows posts made by the logged-in user, providing a personalised view:contentReference[oaicite:3]{index=3}.navbar.html
: Contains the navigation bar with links to the feed, friends, my posts, and profile pages:contentReference[oaicite:4]{index=4}.profile.html
: Displays user profile information and related actions:contentReference[oaicite:5]{index=5}.
- fragments:
- Contains test cases for the application, ensuring each feature works as expected.
- Project Object Model file for managing dependencies using Maven.
- Configuration for containerising the application using Docker.
- Specifies files and directories that should be ignored by Git.
- Java 17 or higher
- Spring Boot 3.x
- Maven for dependency management
-
Clone the repository:
git clone https://github.com/harhar2000/acebook.git cd acebook
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Access the application at
http://localhost:8080
.
- User Registration:
POST /users
- Check Session:
GET /check-session
- Create Post:
POST /posts
- Create Comment:
POST /comments
- Delete Comment:
DELETE /comments/{comment_id}
- Like Post:
POST /likes
- Java & Spring Boot: Backend framework for building RESTful services.
- Spring Security: For handling user authentication and authorisation.
- H2 Database: In-memory database for quick setup and testing.
- Thymeleaf: Template engine for rendering HTML pages.
- Maven: Dependency management.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature
). - Commit your changes (
git commit -m 'Add your feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
Feel free to reach out if you have any questions or suggestions!