Blazor WebAssembly Frontend
The frontend is built using Blazor WebAssembly, a client-side web framework that runs .NET code directly in the browser using WebAssembly.Project Structure
Technology Stack
Core Framework
- .NET 9.0 with Blazor WebAssembly SDK
- C# 11 language features
- Nullable reference types enabled
- Implicit usings enabled
UI Component Libraries
MudBlazor (v8.6.0)- Material Design components
- Rich set of UI controls
- Responsive grid system
- Built-in themes and styling
- Additional specialized components
- Calendar and scheduling components
- Data visualization
- Form controls
- Beautiful, responsive alerts
- Confirmation dialogs
- Toast notifications
Other Libraries
- ClosedXML (v0.105.0) - Excel file generation
- Microsoft.IdentityModel.JsonWebTokens (v8.11.0) - JWT token handling
Application Entry Point
TheProgram.cs file configures the Blazor WebAssembly host:
- Root component mounted to
#appelement - HeadOutlet for dynamic head content
- Base address:
https://localhost:7123/(API endpoint)
Service Registration
HTTP Client
Application Services
Authentication Architecture
Custom Authentication State Provider
The application uses a customAuthenticationStateProvider for JWT-based authentication:
- User logs in through
Login.razor AuthServicecalls API and receives JWT token- Token stored in browser (localStorage/sessionStorage)
CustomAuthenticationStateProviderreads token- Token included in subsequent API requests
- Authorization state propagates to all components
Service Layer Pattern
The frontend uses interface-based services to communicate with the API:IExpedienteService
- Manages request/case data (expedientes)
- CRUD operations for requests
- Search and filtering
- Status updates
IUsuarioService
- User management operations
- User CRUD operations
- Role management
- Password changes
ICalendarioService
- Calendar and date management
- Holiday/non-working day tracking
- Deadline calculations
AuthService
- User authentication
- Login/logout operations
- Token management
- Session handling
Page Structure
Modulo Solicitudes (Request Module)
Key Pages:Login.razor- User authenticationInicio de Solicitudes.razor- Create new requestsIndice de Expedientes.razor- List all requestsDetalles de Expediente.razor- View request detailsHistorial de Solicitudes.razor- Request historyCalendarioRadzen.razor- Calendar managementCreacionUsuarios.razor- User creationVerEventosVencimiento.razor- View deadlines
RecursosRevision (Review Resources Module)
Key Pages:RecursoRevisionRegistroMenu.razor- Review resource menuAgregarRecursoRevision.razor- Add review resourcesRecursoRevisionBusqueda.razor- Search review resourcesRecursoRevisionExpedienteDigital.razor- Digital case fileRecursosRevisionEstadisticas.razor- Statistics and reports
Component Communication
Parent-Child Communication
- Parameters (
[Parameter]) for passing data down - EventCallbacks for child-to-parent communication
- Cascading parameters for deep hierarchies
State Management
- Service-based state (scoped services)
AuthenticationStatecascading parameter- Browser storage for persistence
Progressive Web App (PWA)
The application is configured as a PWA:- Offline capability
- Install to home screen
- Service worker for caching
- App-like experience on mobile
wwwroot/service-worker.js- Development service workerwwwroot/service-worker.published.js- Production service worker
HTTP Communication
All API communication usesHttpClient with JSON serialization:
Typical Service Method:
Error Handling
- SweetAlert2 for user-friendly error messages
- Try-catch blocks in service methods
- HTTP status code checking
- Standardized
ResponseAPIwrapper
Styling & Theming
- Component-specific CSS files (
.razor.css) - Scoped CSS for component isolation
- MudBlazor theming system
- Custom CSS in
wwwroot/css/
Asset Management
wwwroot/ Directory:- Static files served directly
- Images, CSS, JavaScript
- Service worker files
- App manifest for PWA
auditoria.js- Custom audit functionality
Build & Deployment
Build Output:- WebAssembly modules (
.wasm) - .NET assemblies (
.dll) - Static assets
- All published to
bin/Release/net9.0/publish/wwwroot/
- Static file hosting (Azure Static Web Apps, Netlify, etc.)
- IIS with static file serving
- Any web server capable of serving static files
Best Practices
Performance
- Lazy loading for large components
- Virtual scrolling for long lists
- Debouncing for search inputs
- Minimal re-renders with
ShouldRender()
Security
- JWT tokens stored securely
- HTTPS-only communication
- Input validation on forms
- XSS prevention (automatic in Blazor)
Code Organization
- One component per file
- Services in separate interfaces
- Shared models in SolicitudesShared project
- Consistent naming conventions
Next Steps
- Backend Architecture - Understanding the API
- Database Architecture - Data layer details
- Development Setup - Setting up your environment