How talhayaseen57/blacksheep works
Project Type and Purpose
• BlackSheep is a full-stack, server-side rendered e-commerce web application built with Spring Boot (Java), Thymeleaf, and PostgreSQL.
• It follows the classic MVC (Model-View-Controller) layered architecture, with user-facing pages delivered via Thymeleaf templates and dynamic behavior via JavaScript.
• Persistence is handled via Spring Data JPA repositories to a PostgreSQL database. Security is managed with Spring Security. Deployed on Heroku using an embedded Tomcat.
File Structure Highlights
• src/main/java/com/blacksheep
• web: Controllers (CartController, ProductsController, PaymentController, etc.)
• service: Business logic services (ProductService, PaymentService, CustomerService, ProfileService)
• repositories: Spring Data JPA interfaces for domain entities (ProductRepository, OrderRepository, etc.)
• domain/POJOS: JPA Entities (Product, Order, Customer, Guest, Item, Profile) and form DTOs.
• security: Spring Security config and custom user details.
• exceptions: Custom exceptions for error handling.
• src/main/resources
• static: CSS, JS, images.
• templates: Thymeleaf templates for pages and error fragments.
• application.properties: Database & server config.
• database.sql: Initial schema and seed data.
• Procfile/pom.xml: Deployment config (Heroku) and build.
Main Components & Their Interactions
• Client Browser: Renders HTML/CSS/JS, initiates HTTP(S) requests (GET/POST).
• Web Server (Spring Boot/Tomcat): Receives requests, routes to Controllers.
• Controllers (MVC Layer):
• Validate input, delegate to Services, choose views.
• Service Layer:
• Encapsulates business rules, orchestrates transactions, calls Repositories.
• Repository Layer (Spring Data JPA):
• CRUD and query operations on PostgreSQL.
• Database (PostgreSQL): Stores domain data (products, orders, customers).
• Security Layer (Spring Security):
• Intercepts requests, enforces authentication/authorization, integrates with CustomerDetailsServiceImpl.
• Static Resource Handler:
• Serves CSS/JS/images directly.
• External Services:
• Heroku deployment platform.
• (Optionally) any external payment gateway invoked by PaymentService.
Architectural Patterns & Design Principles
• Layered Architecture (Controller → Service → Repository → Database).
• MVC for web interaction.
• Domain-Driven Design: Entities in domain package.
• Spring Security filter chain for authentication/authorization.
• Exception handling via @ControllerAdvice and custom exceptions.
• Separation of concerns: templates vs. static assets vs. business logic.