How najidmohamed/annotationapp works
Project Type and Purpose
• This is a full-stack, server-rendered web application for managing text annotation tasks.
• Built with Spring Boot (Java), Thymeleaf templates for the UI, Spring Data JPA for persistence, and a relational database (H2/MySQL/PostgreSQL).
• Key use cases: administrators create datasets and assign annotation tasks in bulk; annotators log in, view assigned text pairs, submit annotations.
Main Components
A. Client Layer
• Web Browser (UI)
– Renders HTML/CSS/JS served by Thymeleaf templates and static resources.
• REST Client (could be AJAX or external scripts consuming JSON endpoints for task assignment).
B. Web Server Layer (Spring Boot Application)
1. Controllers (Spring MVC)
– Handle incoming HTTP requests (login, admin pages, annotator pages, REST endpoints).
– Package: ma.najid.annotationapp.Controller
2. Service Layer
– Business logic for user accounts, annotators, tasks, datasets, email notifications.
– Interfaces under ma.najid.annotationapp.service; implementations in service.impl.
3. Repository Layer (Spring Data JPA)
– CRUD operations and custom queries for entities (Annotation, Annotator, Dataset, etc.).
– Package: ma.najid.annotationapp.repository
4. Domain Models & DTOs
– Entities (ma.najid.annotationapp.Model) map to database tables.
– DTOs (ma.najid.annotationapp.dto) for request/response payloads, decoupling internal models from API.
5. Configuration & Initialization
– application.properties for datasource and app settings.
– DataInitializer populates initial roles, users, sample data.
– ThymeleafConfig for view resolver customizations.
C. Persistence Layer
• Relational Database
– Tables mirror Entity classes (UserAccount, Tache, Annotation, etc.).
– Schema initialized via migration.sql and JPA.
D. External Services
• Email Service (SMTP) for notifications (package: ma.najid.annotationapp.service.Email).
• File storage (uploads directory for dataset files).
Component Interactions and Data Flow
1. User requests a page or REST endpoint from Browser → Spring Controllers.
2. Controller orchestrates:
– Validates input, transforms to DTOs.
– Calls Service layer methods.
3. Service layer applies business rules, uses Repositories to query/update the Database.
4. If needed, Service layer calls EmailService to send notifications.
5. Controller returns:
– Thymeleaf template name + Model attributes → rendered HTML.
– Or JSON response for REST operations.
6. Browser renders response; user interacts further.
Architectural Patterns & Principles
• Layered (Presentation → Business → Data).
• MVC for web layer (Thymeleaf views + Controllers).
• Repository pattern via Spring Data JPA.
• Dependency injection throughout.
• DTOs to decouple web API from domain models.
• Configuration classes for modular setup.