Architecture Overview
The system uses a monolithic Blazor Server architecture with the following key characteristics:Interactive Components
Server-side rendering with real-time SignalR connection for UI updates
Service Layer
Dependency-injected services handling business logic and data access
SQL Server Database
Stored procedures for data operations with ADO.NET
External Integrations
PayPal, email services, geolocation APIs, and currency conversion
High-Level Architecture Diagram
Architectural Layers
1. Presentation Layer
The presentation layer consists of Razor Components organized by feature area:Component Organization
Component Organization
- Interactive Server render mode (
InteractiveServer) - Real-time UI updates via SignalR
- Component-based architecture with data binding
- Custom preloader with random loading messages
2. Service Layer
The service layer implements dependency injection with scoped services registered inProgram.cs. Services are organized by domain:
Service Lifetimes:
- Scoped: Most services (one instance per HTTP request/SignalR connection)
- Singleton:
MailNotificationDispatcher(shared across application) - HttpClient: Factory pattern for external API calls
3. Data Access Layer
Data access is implemented using ADO.NET with SQL Server and stored procedures:Data Access Pattern Example
Data Access Pattern Example
TourService.cs - Stored Procedure Call
- Direct ADO.NET for performance
- Stored procedures for complex operations
- Parameterized queries to prevent SQL injection
- Async/await throughout
Authentication & Security
Authentication Flow
AndanDo implements a JWT-based authentication system with cookie storage:Security Features
Password Hashing
PBKDF2 with 100,000 iterations, SHA256, 16-byte salt
JWT Tokens
Configurable expiration (default 120 minutes)
Protected Storage
ProtectedLocalStorage for secure client-side data
Role-Based Access
Role verification for admin and creator features
External Integrations
AndanDo integrates with several external services:Payment Processing
PayPal Integration
PayPal Integration
- Service:
PaypalServicewith HttpClient factory - Configuration: Sandbox/production mode, client credentials
- Implementation: REST API integration for order creation and capture
- Location:
Services/Paypal/PaypalService.cs
Email Notifications
SMTP Email Service
SMTP Email Service
- Library: MailKit for SMTP
- Features: HTML emails, password reset, booking confirmations
- Configuration: SMTP host, port, TLS, credentials
- Dispatcher: Singleton
MailNotificationDispatcherfor queued sending
Geolocation
Nominatim & Google Maps
Nominatim & Google Maps
- Search: Nominatim API for address autocomplete
- Maps: Google Maps JavaScript API for tour locations
- Features: Geolocation with normalized search (removes accents/spaces)
Currency Conversion
Currency Conversion Service
Currency Conversion Service
- Service:
CurrencyConversionServicewith HttpClient - Purpose: Real-time exchange rates for international pricing
- Location:
Services/Utility/CurrencyConversionService.cs
Middleware Pipeline
The ASP.NET Core middleware pipeline is configured inProgram.cs:47-67:
Program.cs
The pipeline order is critical: authentication must come before authorization, and antiforgery must be enabled for Blazor Server to protect against CSRF attacks.
State Management
AndanDo uses multiple state management strategies:UserSession
Scoped service storing current user data during the SignalR connection
ProtectedLocalStorage
Encrypted browser storage for persisting JWT and session data
Component State
Local component state with
@bind directivesCascading Parameters
CascadingAuthenticationState for auth state propagationReal-Time Communication
Blazor Server uses SignalR for real-time server-to-client communication:- Connection: Persistent WebSocket or long-polling connection
- Render Mode:
InteractiveServeron components - Reconnection: Built-in reconnection UI with
<ReconnectModal /> - Preloader: Custom loading screen during initial connection
Performance Considerations
Optimization Strategies
- Scoped Services: One instance per connection reduces memory overhead
- Async/Await: All I/O operations are asynchronous
- Stored Procedures: Optimized database queries
- Static Assets: Mapped with fingerprinting for cache efficiency
- Image Uploads: Stored locally in
wwwroot/uploads/
Scalability Notes
Configuration Management
Configuration is managed throughappsettings.json and environment-specific files:
appsettings.json
Configuration sections are bound to strongly-typed options classes using
builder.Services.Configure<T>() for type safety and IntelliSense support.Next Steps
Tech Stack
Explore the technologies and NuGet packages used
Project Structure
Deep dive into code organization and file structure
Database Schema
Learn about the SQL Server database design
API Integration
External API integration patterns