Psyter Web Application - Enhanced Documentation

Overview

The Psyter Web Application is an ASP.NET MVC 5 web portal that serves as the primary user interface for the Psyter telemedicine platform. It provides comprehensive functionality for patients, care providers, administrators, and other stakeholders to access mental health services, manage appointments, conduct video sessions, and handle various administrative tasks.

Technology Stack

  • Framework: ASP.NET MVC 5.2.3 (.NET Framework 4.7.2)
  • Language: C# with Razor view engine
  • Frontend:
  • jQuery 3.3.1
  • Bootstrap 3.0.0 / Bootstrap 5 (mixed usage)
  • Custom CSS with RTL support for Arabic
  • JavaScript/TypeScript
  • Backend Services:
  • RESTful API integration (PsyterAPI)
  • Google Analytics Data API integration
  • gRPC services
  • Key Libraries:
  • Newtonsoft.Json 13.0.1 (JSON serialization)
  • DocumentFormat.OpenXml 2.11.3 (Excel/Word document generation)
  • SpreadsheetLight 3.5.0 (Excel operations)
  • Microsoft Application Insights (telemetry)
  • Google APIs (Analytics, Auth)
  • Grpc.Core 2.46.3 (gRPC communication)

Architecture

Pattern: Model-View-Controller (MVC)
- Models: Data structures for API requests/responses, view models
- Views: Razor views organized by feature and language (English/Arabic)
- Controllers: Business logic, API orchestration, session management

Key Components:
1. Controllers - Organized by role and feature
2. DataAccess Layer - API communication (ApiDataAccess, DALManager)
3. Common - Shared utilities, constants, authentication
4. Filters - Authorization, authentication, exception handling
5. Views - Bilingual UI (English/Arabic) with Razor templates

Project Structure

Web/
├── Psyter/                          # Main web application
│   ├── App_Start/                   # Application configuration
│   │   ├── BundleConfig.cs          # JS/CSS bundling
│   │   ├── FilterConfig.cs          # Global filters
│   │   └── RouteConfig.cs           # URL routing
│   ├── Common/                      # Shared utilities
│   │   ├── AppConstants.cs          # Application constants
│   │   ├── APIAuthenticationToken.cs# API token management
│   │   └── Common.cs                # Common helper methods
│   ├── Controllers/                 # MVC Controllers
│   │   ├── Accountant/              # Accountant features
│   │   ├── Admin/                   # Admin features
│   │   │   └── Catalogue/           # Catalog management
│   │   ├── Patient/                 # Patient/Client features
│   │   ├── Physician/               # Care provider features
│   │   ├── WebController.cs         # Public pages
│   │   ├── UserManagerController.cs # User management
│   │   ├── CommonController.cs      # Shared endpoints
│   │   └── ...
│   ├── DataAccess/                  # Data layer
│   │   ├── ApiDataAccess.cs         # API HTTP client
│   │   └── DALManager.cs            # Data access manager
│   ├── Filters/                     # Custom filters
│   │   ├── AuthenticateUser.cs      # Authentication
│   │   ├── IsAdmin.cs               # Role-based filters
│   │   ├── exceptionFilter.cs       # Exception handling
│   │   └── ...
│   ├── Models/                      # Data models
│   │   ├── Request/                 # API request DTOs
│   │   ├── Response/                # API response DTOs
│   │   ├── Enums/                   # Enumerations
│   │   └── ...
│   ├── Views/                       # Razor views
│   │   ├── Web/                     # Public pages
│   │   │   ├── English/             # English views
│   │   │   └── Arabic/              # Arabic views
│   │   ├── Patient/                 # Patient views
│   │   ├── Physician/               # Provider views
│   │   ├── Admin/                   # Admin views
│   │   ├── Shared/                  # Shared layouts/partials
│   │   └── ...
│   ├── Content/                     # Static assets
│   │   ├── css/                     # Stylesheets
│   │   │   ├── Arabic/              # RTL styles
│   │   │   └── ...
│   │   ├── images/                  # Images
│   │   ├── fonts/                   # Custom fonts
│   │   ├── stylesheets/             # Page-specific styles
│   │   └── payslip/                 # Payslip templates
│   ├── Scripts/                     # JavaScript files
│   │   ├── JS/                      # Custom scripts
│   │   └── ...                      # Third-party libraries
│   ├── Web.config                   # Application configuration
│   ├── Global.asax.cs               # Application lifecycle
│   ├── packages.config              # NuGet packages
│   └── Psyter.csproj                # Project file
├── azure-pipelines.yml              # CI/CD pipeline
└── Psyter.sln                       # Visual Studio solution

Features

User Roles

  1. Patients/Clients - Book appointments, screening, video sessions
  2. Care Providers - Manage schedule, appointments, prescriptions
  3. Administrators - System configuration, user management
  4. Accountants - Financial reports, payment management
  5. Content Managers - Content management
  6. Marketing Managers - Promotional campaigns
  7. SEO Managers - SEO optimization
  8. Organizations - Corporate accounts management

Core Functionality

Public Features

  • Bilingual interface (English/Arabic with RTL support)
  • Home page with service information
  • Care provider listings and profiles
  • Psychological assessments/screening
  • User registration (patients and care providers)
  • Login/logout, password reset
  • FAQ, About Us, Contact pages
  • Blog/Content pages
  • Privacy Policy, Terms & Conditions

Patient Features

  • Profile management
  • Care provider search and filtering
  • Appointment booking and management
  • Screening questionnaires
  • Video/audio sessions
  • Messaging with providers
  • Prescription viewing
  • Payment processing
  • Diary/journal
  • Homework assignments
  • Session history
  • Referral management

Care Provider Features

  • Profile and CV management
  • Availability/schedule management
  • Appointment management
  • Patient list and history
  • Video/audio session interface
  • Prescription creation
  • Clinical notes
  • Homework assignment
  • Group session management
  • Package management
  • Financial reports (payslips)
  • Referral management
  • Collaboration tools

Admin Features

  • User management
  • Care provider verification
  • Catalog management (specialties, services, etc.)
  • Promotion/discount management
  • Payment configuration
  • System configuration
  • Reports and analytics
  • Organization management
  • Event management

Setup Instructions

Prerequisites

  1. Development Environment:
    - Visual Studio 2017 or later
    - .NET Framework 4.7.2 or later
    - IIS Express or IIS 10+
    - SQL Server (for session state, if configured)

  2. Dependencies:
    - NuGet Package Manager
    - Node.js (for frontend build tools, if used)

Installation Steps

  1. Clone the Repository

    git clone <repository-url>
    cd Psyter/Web
    

  2. Restore NuGet Packages

    # In Visual Studio
    Tools > NuGet Package Manager > Restore NuGet Packages
    
    # Or via command line
    nuget restore Psyter.sln
    

  3. Configure Application Settings

Edit Web/Psyter/Web.config:

<appSettings>
  <!-- API Base URL -->
  <add key="PsyterApiBasePath" value="https://your-api-url/"/>

  <!-- Application Token -->
  <add key="PsyterApplicationToken" value="your-app-token"/>

  <!-- Session Timeout (seconds) -->
  <add key="SessionTimeoutCountDown" value="180"/>
</appSettings>

  1. SSL Configuration

Ensure SSL certificate is properly configured in IIS or IIS Express.
- The application requires HTTPS
- Update IISExpressSSLPort in project properties if needed

  1. Build the Solution

    # In Visual Studio
    Build > Build Solution (Ctrl+Shift+B)
    
    # Or via MSBuild
    msbuild Psyter.sln /p:Configuration=Release
    

  2. Run the Application

    # In Visual Studio
    F5 (Debug) or Ctrl+F5 (Without Debugging)
    
    # Or configure IIS
    # Point IIS to the Psyter/bin directory
    

Environment Configuration

Development

  • Debug mode enabled
  • Detailed error messages
  • No caching
  • Local API endpoints

Production

  • Custom errors enabled
  • HTTPS enforced
  • Security headers configured
  • Caching enabled
  • Production API endpoints

API Integration

The application depends on the following APIs:
1. PsyterAPI - Main backend API (configured in PsyterApiBasePath)
2. Media Upload API - Media/file uploads
3. Scheduling API - Appointment scheduling (if separate)

Update API endpoints in Web.config:

<add key="PsyterApiBasePath" value="https://api.psyter.com/"/>

Security Configuration

Important security headers are configured in Web.config:
- X-Frame-Options: SAMEORIGIN
- X-XSS-Protection: 1; mode=block
- X-Content-Type-Options: nosniff
- Strict-Transport-Security (HSTS)
- Content-Security-Policy (commented out - needs review)
- HTTP-only cookies
- SSL/TLS required

Development Guidelines

Coding Standards

  1. C# Conventions
    - Follow Microsoft C# coding conventions
    - Use meaningful variable names
    - Add XML documentation for public methods
    - Use async/await for I/O operations

  2. Frontend
    - Separate JavaScript files for major features
    - Use jQuery for DOM manipulation
    - Maintain consistent CSS naming
    - Support both LTR and RTL layouts

  3. Security
    - All user inputs must be validated
    - Use parameterized API calls
    - Implement CSRF protection
    - Sanitize HTML output
    - Use authentication filters

Adding New Features

  1. Create Controller Action

    [Authorize]
    [IsClient] // or appropriate role filter
    public async Task<ActionResult> NewFeature()
    {
        // Implementation
    }
    

  2. Create View
    - Create English view: Views/[Area]/English/[Feature].cshtml
    - Create Arabic view: Views/[Area]/Arabic/[Feature].cshtml

  3. Add Route (if needed)

    routes.MapRoute(
        name: "NewFeature",
        url: "new-feature",
        defaults: new { controller = "Controller", action = "Action" }
    );
    

  4. Create Model/DTO (if needed)
    - Request models in Models/Request/
    - Response models in Models/Response/

Localization

The application supports English and Arabic:
- Language is stored in Session[SessionVariables.CurrentLanguage]
- Views are organized by language
- Use language-specific resource files or inline translations
- Ensure RTL support for Arabic layouts

Deployment

Azure DevOps Pipeline

The project includes azure-pipelines.yml:

trigger:
- master

pool: 'DevWebServerAgentPool'

steps:
- NuGet restore
- VS Build (Release configuration)
- Publish artifacts
- Copy to deployment directory

Manual Deployment

  1. Build Release Package

    msbuild Psyter.sln /p:Configuration=Release /p:DeployOnBuild=true
    

  2. Publish to IIS
    - Copy build output to IIS directory
    - Configure application pool (.NET Framework 4.7.2)
    - Set up SSL certificate
    - Configure security settings

  3. Post-Deployment
    - Verify Web.config transformations
    - Test API connectivity
    - Check SSL configuration
    - Verify session state
    - Test authentication

Troubleshooting

Common Issues

  1. API Connection Failures
    - Verify PsyterApiBasePath in Web.config
    - Check firewall/network settings
    - Validate API authentication token

  2. Session Timeout Issues
    - Check SessionTimeoutCountDown setting
    - Verify session state configuration
    - Check application pool recycling

  3. Arabic/RTL Layout Issues
    - Verify correct CSS files are loaded
    - Check language session variable
    - Ensure RTL-specific styles are applied

  4. Video Session Issues
    - Check WebRTC compatibility
    - Verify media permissions
    - Check WebSocket connections (if used)

  5. File Upload Issues
    - Check IIS upload size limits
    - Verify media API endpoint
    - Check file permissions

Logging

Application Insights is configured for telemetry:
- Performance monitoring
- Exception tracking
- Dependency tracking
- Custom events

Access logs through Azure Portal or Application Insights dashboard.

Testing

Manual Testing

  • Test all user roles
  • Verify bilingual functionality
  • Test video/audio sessions
  • Validate payment flows
  • Check mobile responsiveness

Browser Compatibility

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)
  • Mobile browsers

Performance Optimization

  1. Bundling and Minification - Configured in BundleConfig.cs
  2. Caching - Static content caching configured
  3. CDN - Consider CDN for static assets
  4. Image Optimization - Optimize images before upload
  5. Lazy Loading - Implement for heavy content

Security Considerations

  1. HTTPS Only - Enforced via configuration
  2. Authentication - Session-based with filters
  3. Authorization - Role-based access control
  4. CSRF Protection - Anti-forgery tokens
  5. XSS Prevention - Input validation and encoding
  6. SQL Injection - API layer handles data access
  7. Security Headers - Configured in Web.config

Maintenance

Regular Tasks

  • Update NuGet packages quarterly
  • Review and rotate API tokens
  • Monitor Application Insights
  • Review error logs weekly
  • Update SSL certificates before expiry
  • Test backup/restore procedures

Updates

  • Follow semantic versioning
  • Document breaking changes
  • Test in staging before production
  • Maintain rollback plan
  • API Documentation: See APIs folder
  • Mobile Apps: See Android/AndroidCareProvider folders
  • Database Schema: Contact DBA team
  • Architecture Diagrams: See docs/code-structure/

Support

For technical issues or questions:
- Create an issue in the repository
- Contact the development team
- Review the audit documentation in /Audit/Web/

License

[Specify license information]


Last Updated: November 2025
Version: 1.0
Maintained By: Psyter Development Team