Backend programında öğrendiğin her şeyi tek bir uygulamada birleştiriyorsun: REST API + JPA (veritabanı) + Spring Security (kimlik & yetki) + birim testleri. Küçük bir blog/forum servisi: kullanıcılar kayıt olur, ADMIN gönderi yazıp siler, giriş yapan herkes yorum yapabilir, okuma herkese açıktır. Süre: ~10-14 saat.
Bu, haftalık projelerden daha büyük ve entegre bir projedir — bitirince elinde portföye koyabileceğin tam bir Spring Boot API olur.
Controller ──> Service ──> Repository (JpaRepository) ──> H2
▲
SecurityFilterChain (yazma=ADMIN, yorum=giriş yapan, okuma=herkes)
CustomUserDetailsService + BCryptPasswordEncoder
User(username, hash'li password, role:ADMIN/MEMBER)Post(title, content, authorUsername)Comment(postId, text, authorUsername) — gönderiyepostIdile bağlı
entity/,repository/(JpaRepository+ türetilmiş sorgular:findByAuthorUsername,findByPostId)dto/(RegisterRequest,UserResponse,PostRequest,CommentRequest—@Validhazır)security/(SecurityConfig,CustomUserDetailsService),controller/GlobalExceptionHandler,application.properties
AuthService(1-3): kayıt — dup kontrol, şifre hash, kaydet.PostService(4-7): create, findAll, findByAuthor, delete.CommentService(8-9): addToPost (postId ile), findByPost.AuthController(10):POST /register→UserResponse(şifre dönmez), 201.PostController(11-14):GET /posts,GET /posts/author/{username},POST /posts(201),DELETE /posts/{id}(200).CommentController(15-16):GETvePOST /posts/{postId}/comments.
💡 Yetki kuralları
SecurityConfig'de hazır — controller'da rol kontrolü yazma. Spring Security isteği daha controller'a gelmeden 401 (kimlik yok) / 403 (yetki yok) ile reddeder.
| Method | Yol | Erişim |
|---|---|---|
| POST | /register |
herkes |
| GET | /posts, /posts/author/{username} |
herkes |
| GET | /posts/{postId}/comments |
herkes |
| POST | /posts |
ADMIN |
| DELETE | /posts/{id} |
ADMIN |
| POST | /posts/{postId}/comments |
giriş yapan herkes |
mvn spring-boot:run
curl -i -X POST localhost:8080/register -H "Content-Type: application/json" \
-d '{"username":"admin","password":"sifre123","role":"ADMIN"}'
curl -i -u admin:sifre123 -X POST localhost:8080/posts -H "Content-Type: application/json" \
-d '{"title":"İlk Yazı","content":"Merhaba dünya","authorUsername":"admin"}'
curl -i localhost:8080/posts
curl -i -u admin:sifre123 -X POST localhost:8080/posts/1/comments -H "Content-Type: application/json" \
-d '{"text":"Güzel yazı","authorUsername":"admin"}'- REST: CRUD, path variable (
/{id},/author/{username}), iç içe kaynak (/posts/{id}/comments),ResponseEntity+ durum kodları - JPA:
@Entity,JpaRepository, türetilmiş sorgular,deleteById - Security:
SecurityFilterChain, BCrypt, rol bazlı yetki (hasRole) +authenticated - DTO + validation:
@Valid, hassas alanı gizleme (UserResponse) - Test: Mockito (servis) + MockMvc (
@WithMockUser, 401/403/201)
21 test: AuthServiceTest, PostServiceTest, CommentServiceTest (Mockito) + SecurityTest (MockMvc — rol/erişim). 1. student_id.txt'ye Kaizu numaranı yaz. 2. mvn test. 3. 21/21 → panelde yeşil tik.
Kısmi çalıştırmada skor gönderilmez — tik için tüm testleri koştur.
Takılırsan "Çözümü Göster" (3 gün sonra). Test çıktısındaki "beklenen/gelen" en iyi ipucudur.