How it0xhl/prueba-mantenimiento-de-clientes works
1. Repository shape
- This is a three-part system: Angular frontend, Spring Boot backend, and SQL Server database assets.
- The repo is organized so each layer can run independently, but the intended path is frontend → REST API → SQL Server.
2. Frontend boundary
- The frontend/ app is an Angular 21 SPA built around a single business feature: client maintenance.
- Main UI pieces are split into:
- pages/cliente-page: the screen/container for the feature
- components/cliente-form: create/update form
- components/cliente-table: list, pagination, and row selection
- main.ts and app.config.ts indicate a modern Angular bootstrap setup rather than a classic NgModule-heavy app.
3. Frontend state and data flow
- core/cliente.store.ts is the key client-side state boundary: it likely coordinates list loading, selection, and mutation results.
- services/cliente.service.ts is the API adapter that talks to the backend.
- models/cliente.model.ts defines the client shape used in the UI; format.util.ts suggests presentation helpers for dates/text.
- Typical flow is: user edits form → store/service sends request → table refreshes from API → UI shows success/error feedback.
4. Frontend validation and UX
- Validation is enforced before submission using Angular reactive forms, matching backend rules.
- The UI supports:
- live search
- pagination with page-size choices
- row selection for edit
- confirm-before-delete behavior
- Because validation exists in both tiers, the frontend is not trusted as the only guardrail.
5. Backend structure
- The backend is a Spring Boot 3.5 API under com.prueba.clientes.
- Layers are cleanly separated:
- controller/ClienteController.java for HTTP endpoints
- service/ClienteService + service/impl/ClienteServiceImpl for business logic
- repository/ for persistence access
- domain/Cliente.java as the JPA entity
- dto/ for request/response contracts
- exception/ for centralized error handling
6. Backend API contract
- The API base is /api/v1/clientes.
- Responses are wrapped in a consistent envelope via ApiResponse and PageResponse, so the UI always receives structured success/message/data payloads.
- The backend exposes the full CRUD set plus paginated search:
- list with search/paging
- get by id
- create
- update
- delete
7. Backend persistence model
- Cliente maps to the SQL Server table dbo.Cliente.
- The persistence strategy is intentionally mixed:
- Spring Data JPA for read/create/update flows
- stored procedure for delete
- ClienteRepositoryCustom and ClienteRepositoryCustomImpl are the boundary for custom database behavior, most likely including the delete procedure and possibly search logic.
8. Database subsystem
- The database/ folder is a first-class part of the architecture, not just seed data.
- It contains scripts to:
- create the database
- create tables
- create stored procedures
- seed initial data
- The key operational dependency is SQL Server 2022, and the system expects a preloaded schema plus procedure dbo.usp_EliminarCliente.
9. Cross-cutting concerns
- WebCorsConfig defines the frontend-to-backend trust boundary for browser calls.
- OpenApiConfig documents the API, surfacing Swagger/OpenAPI for interactive exploration.
- GlobalExceptionHandler and ResourceNotFoundException centralize error translation so the API returns controlled responses rather than raw stack traces.
- Validation is mirrored in both frontend and backend using Jakarta Validation on the server side.
10. Runtime and deployment topology
- Local runtime is explicitly container-assisted:
- docker-compose.yml brings up SQL Server on exposed port 14336
- backend runs on 8081
- frontend runs on 4200
- Environment variables drive DB and CORS configuration, so the backend is configurable without code changes.
- start.bat acts as an orchestration entrypoint on Windows: it checks Docker, starts the DB, initializes scripts, and opens backend + frontend sessions.
11. Test boundaries
- Backend tests are split by layer:
- ClienteControllerTest
- ClienteServiceImplTest
- This suggests the architecture is validated at both HTTP and service boundaries, not just unit-level entity tests.
12. Architecture diagram takeaway
- The main draw should be: Angular SPA on the left, Spring Boot REST API in the middle, and SQL Server with schema + stored procedure scripts on the right.
- The most important internal arrows are:
- UI form/table → Angular store/service → REST controller
- controller → service → repository/JPA
- delete path → custom repository → stored procedure
- shared error/validation/doc config wrapping the API on the backend side.
Main entry points: ClienteController.java Cliente API · ClienteRepository.java Cliente repo · cliente.store.ts Client store · docker-compose.yml Runtime bootstrap
Components 18
Angular SPA
Client-side application for customer maintenance
- Angular app · Angular 21 bootstrap and application composition
frontend/src/app/app.ts - Cliente page · Top-level screen for client maintenance
frontend/src/app/pages/cliente-page/cliente-page.ts - Cliente form · Create and update form with validation and submit actions
frontend/src/app/components/cliente-form/cliente-form.ts - Cliente table · Search, pagination, row selection, and delete/edit entry points
frontend/src/app/components/cliente-table/cliente-table.ts - Client store · Coordinates loading, selection, mutations, and refresh flows
frontend/src/app/core/cliente.store.ts - API service · Front-end adapter to the REST API
frontend/src/app/services/cliente.service.ts - Client model · Shared client shape used by the Angular feature
frontend/src/app/models/cliente.model.ts
Spring API
REST backend with service, persistence, and cross-cutting layers
- Cliente API · HTTP boundary for /api/v1/clientes
backend/src/main/java/com/prueba/clientes/controller/ClienteController.java - Cliente service · Service interface and implementation for CRUD and search logic
backend/src/main/java/com/prueba/clientes/service/impl/ClienteServiceImpl.java - Cliente repo · Spring Data repository and custom persistence boundary
backend/src/main/java/com/prueba/clientes/repository/ClienteRepository.java - Cliente entity · Maps client records to dbo.Cliente
backend/src/main/java/com/prueba/clientes/domain/Cliente.java - API DTOs · Request, response, page, and envelope models
backend/src/main/java/com/prueba/clientes/dto/ClienteRequest.java - Error handling · Global exception mapping and not-found translation
backend/src/main/java/com/prueba/clientes/exception/GlobalExceptionHandler.java - API config · CORS and OpenAPI configuration for browser access and docs
backend/src/main/java/com/prueba/clientes/config/WebCorsConfig.java
SQL Server Assets
Database schema, procedures, and seed scripts
- Schema scripts · Database and table creation scripts
database/02_create_tables.sql - Stored proc · Delete procedure boundary used by the backend
database/03_stored_procedures.sql - Seed data · Initial data load scripts
database/04_seed_data.sql
Other components
- Runtime bootstrap · Docker Compose and Windows start script for local environment
docker-compose.yml
Connections 23
- Angular app → Cliente page: hosts · Application renders the maintenance screen
- Cliente page → Cliente form: uses · Page composes the edit/create form
- Cliente page → Cliente table: uses · Page composes the searchable table
- Cliente form → Client store: submit · Form actions flow through shared state
- Cliente table → Client store: selection/search · Table drives paging, selection, and refresh
- Client store → API service: API calls · Store delegates persistence operations to HTTP adapter
- API service → Cliente API: REST · Frontend calls the client API endpoints
- Client store → Client model: reads/writes · State is shaped by the shared client model
- Cliente API → API DTOs: contracts · Controller exchanges request/response envelopes
- Cliente API → Cliente service: delegates · HTTP layer forwards operations to the service layer
- Cliente service → Cliente repo: persists · Service uses repository abstraction for data access
- Cliente service → Cliente entity: maps · Business logic works over the JPA entity model
- Cliente repo → Cliente entity: orm · Repository persists Cliente entities
- Cliente repo → Schema scripts: reads/writes · Entity table defined in schema scripts
- Cliente repo → Stored proc: delete path · Custom repository invokes stored procedure for delete
- Cliente API → Error handling: handled by · Controller exceptions are normalized centrally
- Cliente API → API config: configured by · CORS and OpenAPI shape the API boundary
- Schema scripts → Seed data: initialized by · Seed scripts populate the created schema
- Runtime bootstrap → Schema scripts: starts · Local orchestration initializes database assets
- Runtime bootstrap → Cliente API: starts · Orchestration brings up backend runtime
- Runtime bootstrap → Angular app: starts · Orchestration brings up frontend runtime
- API service → API config: cors-sensitive · Browser calls rely on server CORS configuration
- Cliente API → API DTOs: returns · Structured ApiResponse and PageResponse envelopes