How jomaroto/tani-back works
Project Type and Purpose
• This is a Java Spring‑Boot RESTful backend service (“TANI”) deployed via Google App Engine (see app.yaml, gcloudignore).
• It exposes endpoints for user management, products, orders, notifications, image handling, and email. Authentication is JWT‑based with Firebase integration.
File Structure Analysis
Top‑Level
• build.gradle, gradlew wrapper → Gradle‑based build and dependency management
• app.yaml → GAE deployment descriptor
• src/main/java/tani → Spring‑Boot code organized by layer
Layers under “tani”:
• config → security filters (FiltroToken), JWT utilities, Firebase initialization
• controllers → REST controllers (AutenticacionController, UsuarioController, ProductoController, PedidoController, NotificacionController)
• dto → request/response objects, organized by feature (usuario, producto, pedido, detallepedido, notificacion, otros)
• exceptions → global exception handler
• model → JPA entities and enums
• repositories → Spring Data JPA interfaces for each entity
• services/interfaces and services/impl → business‑logic interfaces and their implementations (e.g., UsuarioServicioImpl, ProductoServicioImpl, EmailServicioImpl, ImagenesServicioImpl)
Tests under src/test/java/tani/test → unit/integration tests per feature
1. Clients
– Web or Mobile frontend
– Third‑party cron/jobs (if any) for batch notifications or email
2. API Layer
– Spring MVC Controllers (HTTP endpoints)
– JWT Authentication Filter → intercepts requests, validates token via JWTUtils + FirebaseConfig
3. Service Layer
– Business services (UsuarioServicio, ProductoServicio, PedidoServicio, DetallePedidoServicio, NotificacionServicio, EmailServicio, ImagenesServicio)
– Orchestrate workflows across entities, handle validation, trigger external calls (email, Firebase notifications, image storage)
4. Data Access Layer
– Spring Data Repositories → CRUD against relational database (e.g., Cloud SQL)
5. Persistence
– SQL Database (MySQL/Postgres) storing tables: Usuario, Producto, ProductoTalla, Pedido, DetallePedido, Notificacion
6. External Services
– Firebase Cloud Messaging → push notifications
– SMTP or email‑relay service → EmailServicioImpl
– Cloud Storage or CDN → ImagenesServicioImpl
Relationships and Data Flow
– Controllers → Service Layer calls (business methods)
– Services → Repositories → Database
– Services → External Services (Email, Firebase, Image Storage)
– Controllers ← Exception Handler (global) for uniform error responses
– Config components (JWT filter) applied at the HTTP ingress to secure controller methods
Architectural Patterns & Principles
– Layered (Controller → Service → Repository → Database)
– Separation of Concerns: DTOs isolate API contract; Entities represent persistence; Services contain business logic
– Dependency Injection via Spring to wire config, repos, services
– Filter Chain for security (JWT, Firebase token validation)
– Externalization of cross‑cutting concerns: email, image storage, notifications
Detailed Capture of Essential Elements
– Illustrate entity flow: Repositories map Entities ↔ Database
– Highlight configurations (FirebaseConfig) that integrate external services
– Ensure test suite is represented as a separate bubble for “Automated Tests” interfacing at the controller and service layers