Skip to content

Instantly share code, notes, and snippets.

@vakho10
Created January 13, 2026 14:22
Show Gist options
  • Select an option

  • Save vakho10/69082edd0bf5089ba1f3330766599302 to your computer and use it in GitHub Desktop.

Select an option

Save vakho10/69082edd0bf5089ba1f3330766599302 to your computer and use it in GitHub Desktop.
Simple Blog Assignment

๐Ÿ“ Simple Blog Application

๐ŸŒฑ Spring Boot Student Assignment


๐Ÿ“Œ Project Overview

This project is a beginner-to-intermediate Spring Boot application designed to help students understand how real-world web applications are built using the Spring ecosystem.

You will develop a fully functional blog platform where users can:

  • Register and log in securely ๐Ÿ”
  • Create and manage blog posts โœ๏ธ
  • Comment on posts ๐Ÿ’ฌ
  • Organize content using categories ๐Ÿท๏ธ

By the end of this assignment, you will have built an application that closely resembles production-grade Java web applications, following clean architecture and best practices.


๐ŸŽฏ Learning Objectives

By completing this project, students will gain hands-on experience with:

โœ… Spring Boot โ€“ application configuration, auto-configuration, and project structure โœ… Spring MVC โ€“ controllers, request mapping, and model-view separation โœ… Spring Data JPA โ€“ ORM, repositories, and database interaction โœ… Spring Security โ€“ authentication, authorization, and password hashing โœ… Thymeleaf โ€“ server-side rendering and dynamic HTML templates โœ… RESTful design โ€“ clean and predictable URL patterns โœ… Relational database modeling โ€“ entities, relationships, and constraints


๐Ÿš€ Project Features

๐Ÿ‘ค User Management

  • ๐Ÿ†• Registration: Anonymous users can create accounts (username, email, password)
  • ๐Ÿ”‘ Authentication: Secure login and logout using Spring Security
  • ๐Ÿ›ก๏ธ Authorization: Only authenticated users may create, edit, or delete content

๐Ÿ“ Post Management

  • โž• Create Posts: Authenticated users can write blog posts with titles, content, and categories
  • ๐Ÿ‘€ View Posts: Anyone (including anonymous users) can read posts
  • โœ๏ธ Edit Posts: Users may edit only their own posts
  • ๐Ÿ—‘๏ธ Delete Posts: Users may delete only their own posts
  • ๐Ÿท๏ธ Categorization: Posts may belong to one or more categories

๐Ÿ’ฌ Comment System

  • โž• Add Comments: Authenticated users can comment on any post
  • โœ๏ธ Edit Comments: Users can edit their own comments
  • ๐Ÿ—‘๏ธ Delete Comments: Users can delete their own comments
  • ๐Ÿ‘๏ธ View Comments: Everyone can see comments under posts

๐Ÿ—„๏ธ Database Schema

Design the following tables with proper constraints and relationships.


๐Ÿ‘ค Users Table

Column Type Constraints
id Long ๐Ÿ”‘ Primary Key, Auto-increment
username String Unique, Not Null, Max 50
email String Unique, Not Null, Valid format
password String Not Null (BCrypt-hashed)
created_at LocalDateTime Not Null, Default: now
enabled Boolean Default: true

๐Ÿ“ Posts Table

Column Type Constraints
id Long ๐Ÿ”‘ Primary Key
title String Not Null, Max 200
content Text Not Null
author_id Long ๐Ÿ”— FK โ†’ Users(id)
created_at LocalDateTime Not Null
updated_at LocalDateTime Nullable

๐Ÿ’ฌ Comments Table

Column Type Constraints
id Long ๐Ÿ”‘ Primary Key
content Text Not Null, Max 1000
post_id Long ๐Ÿ”— FK โ†’ Posts(id)
author_id Long ๐Ÿ”— FK โ†’ Users(id)
created_at LocalDateTime Not Null
updated_at LocalDateTime Nullable

๐Ÿท๏ธ Categories Table

Column Type Constraints
id Long ๐Ÿ”‘ Primary Key
name String Unique, Not Null
description String Nullable

๐Ÿ” Post_Categories (Junction Table)

Column Type Constraints
post_id Long FK โ†’ Posts(id)
category_id Long FK โ†’ Categories(id)
๐Ÿ”‘ Composite Primary Key

๐Ÿ”— Entity Relationships

  • ๐Ÿ‘ค User โ†’ Posts: One-to-Many
  • ๐Ÿ‘ค User โ†’ Comments: One-to-Many
  • ๐Ÿ“ Post โ†’ Comments: One-to-Many
  • ๐Ÿ“ Post โ†” Categories: Many-to-Many

๐ŸŒ Application Endpoints

๐ŸŒ Public Endpoints (No Login Required)

Method Endpoint Purpose
GET / Home page
GET /posts View all posts
GET /post/{id} View single post
GET /category/{id} Posts by category
GET /register Registration page
POST /register Register user
GET /login Login page
POST /login Login processing

๐Ÿ”’ Protected Endpoints (Login Required)

Method Endpoint Purpose
GET /post/new Create post form
POST /post/new Save new post
GET /post/{id}/edit Edit post
POST /post/{id}/edit Update post
POST /post/{id}/delete Delete post
POST /post/{id}/comment Add comment
POST /comment/{id}/edit Edit comment
POST /comment/{id}/delete Delete comment
GET /logout Logout

โญ Optional (Advanced)

  • /profile โ€“ User profile page
  • /my-posts โ€“ Userโ€™s own posts
  • /categories โ€“ All categories

๐Ÿ› ๏ธ Implementation Task Order

1๏ธโƒฃ Create JPA Entities ๐Ÿงฉ

  • Use @Entity, @Id, @GeneratedValue
  • Define relationships properly
  • Apply constraints (nullable, unique)
  • Use Lombok where appropriate

Entities: User, Post, Comment, Category


2๏ธโƒฃ Create Repository Interfaces ๐Ÿ“ฆ

  • Extend JpaRepository
  • Add meaningful query methods

3๏ธโƒฃ Service Layer ๐Ÿง 

  • Encapsulate business logic
  • Perform validation
  • Handle exceptions cleanly

4๏ธโƒฃ Spring Security ๐Ÿ”

  • Configure authentication
  • Use BCryptPasswordEncoder
  • Protect routes
  • Customize login/logout

5๏ธโƒฃ Controllers ๐ŸŽฎ

  • Use @Controller
  • Map endpoints with @GetMapping / @PostMapping
  • Pass data via Model

6๏ธโƒฃ Thymeleaf Templates ๐ŸŽจ

Use:

  • th:text, th:each, th:if
  • Form binding (th:object)
  • Security expressions (sec:authorize)
  • Layout fragments

7๏ธโƒฃ Testing & Refinement ๐Ÿงช

  • Test all flows
  • Validate security rules
  • Handle edge cases
  • Add error pages (403, 404, 500)

โš™๏ธ Technical Requirements

๐Ÿ“ฆ Dependencies

  • Spring Web
  • Spring Data JPA
  • Spring Security
  • Thymeleaf + Security Extras
  • Validation
  • H2 / MySQL / PostgreSQL
  • Lombok (optional)

โš™๏ธ Configuration

  • Database connection
  • Hibernate DDL auto
  • Thymeleaf settings
  • Server port

๐ŸŒŸ Bonus Challenges

  • Pagination ๐Ÿ“„
  • Search ๐Ÿ”
  • User profiles ๐Ÿ‘ค
  • Likes โค๏ธ
  • Rich text editor โœจ
  • Image uploads ๐Ÿ–ผ๏ธ
  • Roles (ADMIN / USER) ๐Ÿ›ก๏ธ
  • Email verification ๐Ÿ“ง
  • Password reset ๐Ÿ”‘
  • REST API ๐ŸŒ

๐Ÿ“ค Submission Guidelines

Students must submit:

  1. โœ… Git repository
  2. ๐Ÿ“„ README.md
  3. ๐Ÿ—„๏ธ Database schema or SQL
  4. ๐Ÿ“ธ Screenshots
  5. โœ๏ธ Short reflection document

๐Ÿงช Evaluation Criteria

Category Weight
Functionality 40%
Code Quality 25%
Database Design 15%
Security 10%
UI/UX 10%

๐Ÿ“š Resources

  • Spring Boot Docs
  • Spring Data JPA Guide
  • Spring Security Reference
  • Thymeleaf Docs
  • Baeldung Tutorials

โœจ Good luck! This project mirrors real enterprise Spring applications, so treat it as both a learning exercise and a portfolio piece.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment