How sua0649/java-smms works
Purpose and Runtime
JAVA-SMMS is a Spring Boot REST backend for a social-media-management ERP dashboard. The application starts from src/main/java/com/Shaheer/smms/SmmsApplication.java, exposes HTTP APIs on port 8080 by default, and provides Actuator health checks. It runs on Java 26, is built with Maven, and persists to MySQL using environment-provided JDBC credentials.
Request and Domain Layer
Controllers are the API boundary and group operations by ERP domain: authentication, users, accounts, campaigns, invoices, assets/inventory, and analytics. Representative entry points:
• src/main/java/com/Shaheer/smms/Controller/AuthController.java
• src/main/java/com/Shaheer/smms/Controller/CampaignController.java
• src/main/java/com/Shaheer/smms/Controller/AnalyticsController.java
The request path is controller → service → repository → MySQL. DTOs separate API payloads from persisted entities, especially for authentication and update operations.
Authentication and Authorization
Authentication is handled through auth endpoints and JWT issuance/validation:
• src/main/java/com/Shaheer/smms/Service/AuthService.java
• src/main/java/com/Shaheer/smms/Service/JWTService.java
• src/main/java/com/Shaheer/smms/Security/JwtAuthenticationFilter.java
SecurityConfig defines the Spring Security boundary, while the JWT filter processes protected requests before controllers. User identity is backed by AuthUser and its repository, with MyUserDetailsService integrating stored users into Spring Security.
Core Business Modules
Services hold module behavior and coordinate persistence:
• Account/access management: src/main/java/com/Shaheer/smms/Service/AccountService.java, src/main/java/com/Shaheer/smms/Model/Account.java
• Campaign and sponsorship management: src/main/java/com/Shaheer/smms/Service/CampaignsService.java, src/main/java/com/Shaheer/smms/Model/Campaign.java
• Asset and equipment tracking: src/main/java/com/Shaheer/smms/Service/AssetsService.java, src/main/java/com/Shaheer/smms/Model/AssetsTracking.java
• Inventory/equipment: src/main/java/com/Shaheer/smms/Service/InventoryService.java, src/main/java/com/Shaheer/smms/Model/Equipment.java
• Invoicing: src/main/java/com/Shaheer/smms/Service/InvoiceService.java, src/main/java/com/Shaheer/smms/Model/Invoices.java
• Dashboard metrics: src/main/java/com/Shaheer/smms/Service/AnalyticsService.java, src/main/java/com/Shaheer/smms/Model/PerformanceMetrics.java
Persistence Boundary
JPA model classes represent the relational schema; Spring Data repositories isolate database operations per aggregate. Important persistence paths include:
• src/main/java/com/Shaheer/smms/Repository/CampaignRepository.java
• src/main/java/com/Shaheer/smms/Repository/InvoicesRepository.java
• src/main/java/com/Shaheer/smms/Repository/PerformanceMetricsRepository.java
Invoice querying has a dedicated specification utility at src/main/java/com/Shaheer/smms/Utiliity/InvoiceSpecs.java, indicating dynamic/filterable invoice retrieval. Schema evolution is delegated to JPA ddl-auto=update.
Configuration and External Infrastructure
Application configuration is in src/main/resources/application.properties; runtime secrets/configuration come from DB_URL, DB_USERNAME, DB_PSWD, and TOKEN. Required external services are MySQL and a client consuming the REST API. Production places Nginx in front of the API and separately serves a frontend not present in this repository.
Deployment Topology
GitHub Actions deployment is defined at .github/workflows/deploy.yml. The intended EC2 deployment runs two systemd-managed Spring Boot JARs—blue on 8080 and green on 8081—behind Nginx. Deployment copies a new artifact, starts the inactive instance, gates proxy switching on /actuator/health, reloads Nginx, then stops the prior instance. This makes Actuator availability part of the release-control boundary.
Components 19
Edge & Release
- REST client
- Nginx · Routes production traffic to the active release.
- GitHub Actions
.github/workflows/deploy.yml - Blue/green JARs · Runs API instances on ports 8080 and 8081.
Spring Boot API
- SMMS application · REST API and Actuator health endpoint.
src/main/java/com/Shaheer/smms/SmmsApplication.java - Domain controllers · Auth, users, accounts, campaigns, invoices, assets, and analytics APIs.
src/main/java/com/Shaheer/smms/Controller/AuthController.java - Campaign API
src/main/java/com/Shaheer/smms/Controller/CampaignController.java - Analytics API
src/main/java/com/Shaheer/smms/Controller/AnalyticsController.java - Application configuration · Reads JDBC and token values from environment variables.
src/main/resources/application.properties
Security
- Security configuration
- JWT authentication filter · Validates protected requests before controllers.
src/main/java/com/Shaheer/smms/Security/JwtAuthenticationFilter.java - Authentication service
src/main/java/com/Shaheer/smms/Service/AuthService.java - JWT service · Issues and validates JWTs.
src/main/java/com/Shaheer/smms/Service/JWTService.java
Business Modules
- ERP services · Coordinates account, campaign, asset, inventory, invoice, and analytics behavior.
src/main/java/com/Shaheer/smms/Service/AccountService.java - Campaign service
src/main/java/com/Shaheer/smms/Service/CampaignsService.java - Analytics service
src/main/java/com/Shaheer/smms/Service/AnalyticsService.java
Persistence
- JPA repositories · Persistence operations per aggregate.
src/main/java/com/Shaheer/smms/Repository/CampaignRepository.java - Invoice specifications · Builds filterable invoice queries.
src/main/java/com/Shaheer/smms/Utiliity/InvoiceSpecs.java - MySQL · JPA manages schema updates.
Connections 19
- REST client → Nginx: HTTPS requests
- Nginx → Blue/green JARs: active instance
- Blue/green JARs → SMMS application: runs
- GitHub Actions → Blue/green JARs: deploys and switches · Health-gates proxy cutover via Actuator.
- SMMS application → Security configuration: configures
- Security configuration → JWT authentication filter: installs
- JWT authentication filter → Domain controllers: authorized requests
- Domain controllers → Authentication service: auth operations
- Authentication service → JWT service: issues tokens
- Campaign API → Campaign service: campaign operations
- Analytics API → Analytics service: metrics requests
- Domain controllers → ERP services: domain operations
- ERP services → JPA repositories: persists aggregates
- Campaign service → JPA repositories: campaign data
- Analytics service → JPA repositories: metrics data
- JPA repositories → MySQL: JPA queries
- Invoice specifications → JPA repositories: invoice filters
- Application configuration → SMMS application: runtime configuration
- Nginx → SMMS application: health check · Uses /actuator/health during release switching.