This project is a modern, full-stack application designed to be a scalable social blogging platform. It features RESTful API communication, robust security using JWT, and a smooth user experience with infinite scrolling and robust error handling.
This project is split into two distinct parts: a Java Spring Boot backend for API and security, and an Angular frontend for the user interface.
| Category | Technology | Description |
|---|---|---|
| Framework | Spring Boot 3 | Used for rapid application development and building a microservice architecture. |
| Security | Spring Security | Handles authentication (login/registration) and authorization (role-based access control). |
| Authentication | JWT (JSON Web Tokens) | Stateless, token-based authentication for secure API access. |
| Persistence | Spring Data JPA / Hibernate | Object-Relational Mapping (ORM) for efficient database interaction. |
| Database | PostgreSQL | Robust, open-source relational database used for data storage. |
| Utility | Lombok | Reduces boilerplate code (getters, setters, constructors). |
| Category | Technology | Description |
|---|---|---|
| Framework | Angular | A platform for building efficient and scalable single-page applications (SPAs). |
| Communication | HttpClient & Interceptors |
Manages HTTP requests and automatically attaches JWT tokens. |
| Routing | Angular Router | Handles client-side navigation and route guarding. |
| UI/UX | Custom CSS | Styling the application, including the infinite scroll user experience. |
Follow these steps to get the project running locally.
- Java Development Kit (JDK) 17+
- Node.js (LTS version)
- Angular CLI (
npm install -g @angular/cli) - PostgreSQL Database
- An IDE (IntelliJ IDEA or VS Code recommended)
- Ensure your PostgreSQL server is running.
- Create a new database for the project (e.g.,
blog_db).
-
Navigate to the
/backenddirectory. -
Open the
application.properties(orapplication.yml) file. -
Configure the database connection details:
# application.properties spring.datasource.url=jdbc:postgresql://localhost:5432/blog_db spring.datasource.username=<YOUR_DB_USERNAME> spring.datasource.password=<YOUR_DB_PASSWORD> # Hibernate will automatically create tables (set to update after first run) spring.jpa.hibernate.ddl-auto=update # Configure your JWT secret key application.security.jwt.secret-key=<YOUR_VERY_LONG_SECRET_KEY>
-
Run the Spring Boot application:
./mvnw spring-boot:run
(Or run the main class from your IDE). The backend will start on
http://localhost:8080.
-
Navigate to the
/frontenddirectory. -
Open the environment file (
src/environments/environment.ts). -
Ensure the
apiUrlpoints to your running backend:// src/environments/environment.ts export const environment = { production: false, apiUrl: 'http://localhost:8080/api' // Base API path };
-
Install the required dependencies:
npm install
-
Start the Angular development server:
ng serve -o
The frontend will automatically open in your browser on
http://localhost:4200.
- Custom JWT Authentication Filter: Handles token validation, manages the
SecurityContext, and implements advanced error handling for banned/deleted users to ensure proper client-side logout/redirection. - Role-Based Access Control (RBAC): Utilizes Spring Security's
@EnableMethodSecurityandhasAuthority("ADMIN")for endpoint protection. - Infinite Scroll: Implemented in the Angular component using the
@HostListener('window:scroll')to efficiently load posts page-by-page. Special care is taken to prevent scroll jumping by reserving image space with CSS aspect ratios and carefully restoring the scroll position. - Data Integrity (ON DELETE CASCADE): JPA/Hibernate is configured using
@OnDelete(action = OnDeleteAction.CASCADE)on foreign keys to automatically clean up related data (posts, comments) when a user is deleted by an administrator.