How arunshar2725/smart-contact-manager works
1. Overall shape
- This is a single Spring Boot monolith: one JVM backend serves both HTML pages and application endpoints.
- There is no separate frontend service or SPA runtime; UI is rendered server-side with Thymeleaf and enhanced with static JS/CSS.
2. Presentation layer
- Request entry points are split across controllers such as PageController, RootController, AuthController, UserController, ContactController, AdminController, ApiController, and ContactExportController.
- Templates live under src/main/resources/templates, with shared layout fragments like base.html, navbar.html, and user/sidebar.html, plus role-specific pages for admin and user flows.
- Static assets are served from src/main/resources/static and include Tailwind-generated CSS plus small client scripts for interactions on contact/admin pages.
3. Core domain model
- The main business entities are User and Contact, with supporting models like SocialLink and Providers.
- The README indicates a strict one-to-many relationship: one user owns many contacts, and JPA cascade/mapped-by semantics keep child lifecycle tied to the parent.
- Form objects such as UserForm, ContactForm, ContactSearchForm, FeedbackForm, and SendMessage separate web input from persistence entities.
4. Persistence layer
- Data access is handled through Spring Data repositories: UserRepo, ContactRepo, FeedbackRepo, and SendMessageRepo.
- The app is backed by a relational database; the README specifies MySQL.
- Large text content is modeled explicitly with JPA @Lob/text-style storage, likely for bios, descriptions, and long profile fields.
5. Service layer
- Business logic is concentrated in UserService, ContactService, EmailService, and ImageService, with implementations in .../impl.
- UserServiceImpl and ContactServiceImpl likely orchestrate validation, ownership checks, persistence, and search/update workflows.
- EmailServiceImpl provides outbound messaging, while ImageServiceImpl handles profile/contact image processing and storage concerns.
6. Security and identity
- SecurityConfig defines the authentication/authorization boundary for the app.
- The app supports both standard login and OAuth2 sign-in; the README calls out Google and GitHub providers.
- SecurityCustomUserDetailService integrates application users with Spring Security’s authentication model, while custom handlers manage login success/failure flows.
7. Role-based areas
- The UI and controller structure suggest at least two main roles: normal users and admins.
- User-facing pages cover dashboard, profile, contact CRUD, search, feedback, and account editing.
- Admin pages expose user management and dashboard views, implying privileged access over platform-wide records.
8. API and non-HTML endpoints
- ApiController suggests there are JSON or programmatic endpoints in addition to the server-rendered pages.
- ContactExportController is a separate boundary for exporting contact data, distinct from the normal CRUD UI.
- EmailService and the send-message/feedback forms indicate outbound communication flows separate from direct browser navigation.
9. Validation and error handling
- Input validation is split between standard form validation and custom file validation via FileValidator / ValidFile.
- GlobalExceptionHandler and ResourceNotFoundException centralize failure handling so controllers don’t duplicate error rendering logic.
- Message, MessageType, SessionHelper, and Helper support user feedback, session-scoped alerts, and shared utility behavior.
10. Frontend build and styling
- The UI uses Tailwind CSS, with a local tailwind.config.js and generated CSS artifacts under static/css.
- The README mentions Flowbite, so the visual system is utility-first with component-style enhancements rather than a large custom frontend framework.
- The presence of package.json and node_modules indicates a frontend asset build step exists, but it feeds into a traditional Spring Boot static asset pipeline.
11. Request/data flow
- Typical flow: browser request → Spring MVC controller → service layer → repository/JPA → MySQL → service/controller → Thymeleaf template or JSON response.
- Security filters run before controller logic, determining whether the request becomes an authenticated user session, an OAuth2 callback, or a blocked redirect.
- File/image and email operations branch out from the main CRUD path into specialized services.
12. Operational boundaries
- The codebase is organized as a layered monolith with clear separation between web, service, persistence, and security concerns.
- Application.java is the bootstrap entry point; src/test/java/com/scm/ApplicationTests.java provides minimal application-level test coverage.
- Overall, the architecture is centered on secure contact management with server-rendered pages, relational persistence, and integrated social login.
Main entry points: controller Web Controllers · Application.java Application · UserService.java User Service · ContactService.java Contact Service
Components 18
Presentation
Server-rendered UI, controllers, templates, and static assets.
- Web Controllers · Entry points for pages, auth, user, admin, API, and export flows.
src/main/java/com/scm/controller - Thymeleaf Views · HTML pages and shared fragments rendered on the server.
src/main/resources/templates - Static Assets · Tailwind output and small client scripts for UI behavior.
src/main/resources/static
Application
Business services, forms, and shared helpers.
- User Service · Coordinates profile, account, and user lifecycle operations.
src/main/java/com/scm/Services/UserService.java - Contact Service · Handles contact CRUD, ownership, search, and updates.
src/main/java/com/scm/Services/ContactService.java - Email Service · Sends application emails and message-based notifications.
src/main/java/com/scm/Services/EmailService.java - Image Service · Processes and stores profile and contact images.
src/main/java/com/scm/Services/ImageService.java - Form Models · Separates request input from persistence entities.
src/main/java/com/scm/forms
Security
Authentication, OAuth2, and access control boundary.
- Security Config · Defines login, OAuth2, and authorization rules.
src/main/java/com/scm/config/SecurityConfig.java - User Details · Bridges application users into Spring Security.
src/main/java/com/scm/Services/impl/SecurityCustomUserDetailService.java - Auth Handlers · Handles OAuth success and authentication failure paths.
src/main/java/com/scm/config/OAuthAuthenticationSuccessHandler.java
Persistence
Entities and Spring Data repositories backed by MySQL.
- Domain Entities · Core user, contact, social link, and provider models.
src/main/java/com/scm/entities - Repositories · Data access for users, contacts, feedback, and messages.
src/main/java/com/scm/Repositories - MySQL · Persistent backing store for users, contacts, and messages.
Infrastructure
Bootstrap, configuration, validation, and error handling.
- Application · Bootstraps the monolith and wires the overall runtime.
src/main/java/com/scm/Application.java - Exception Handler · Centralizes not-found and global exception rendering.
src/main/java/com/scm/handlers/GlobalExceptionHandler.java - Validators · Validates uploaded files and custom form constraints.
src/main/java/com/scm/validators - Helpers · Session messages, constants, and small cross-cutting helpers.
src/main/java/com/scm/helpers
Connections 25
- Application → Security Config: configures · Application startup loads the security boundary.
- Application → Web Controllers: hosts · Bootstraps the MVC web layer.
- Application → User Service: wires · Creates the service layer beans.
- Application → Contact Service: wires · Creates the service layer beans.
- Application → Email Service: wires · Creates the service layer beans.
- Application → Image Service: wires · Creates the service layer beans.
- Security Config → User Details: uses · Authentication relies on custom user lookup.
- Security Config → Auth Handlers: delegates · Login success and failure are handled separately.
- Web Controllers → Thymeleaf Views: renders · Controllers resolve server-side HTML views.
- Web Controllers → Form Models: binds · Request bodies and form posts map into form objects.
- Web Controllers → User Service: calls · User-related requests are coordinated through services.
- Web Controllers → Contact Service: calls · Contact CRUD and search flow through the service layer.
- Web Controllers → Email Service: triggers · Feedback and message flows can send outbound email.
- Web Controllers → Image Service: triggers · Profile and contact image actions route here.
- Web Controllers → Exception Handler: handled by · Exceptions are centralized for consistent responses.
- Web Controllers → Validators: validates · Upload and custom input checks happen before persistence.
- User Service → Repositories: persists via · User workflows read and write through repositories.
- Contact Service → Repositories: persists via · Contact workflows read and write through repositories.
- User Service → Domain Entities: maps · User operations act on JPA entities.
- Contact Service → Domain Entities: maps · Contact operations act on JPA entities.
- Repositories → MySQL: stores in · Repositories persist data in MySQL.
- Form Models → Domain Entities: translates to · Forms isolate web input from JPA models.
- Helpers → Web Controllers: supports · Messaging and session helpers are used by web flows.
- Helpers → Security Config: supports · Shared auth-related utilities support security flows.
- Thymeleaf Views → Static Assets: enhanced by · Pages rely on local CSS and JS assets.