- Регистрация
- 9 Май 2015
- Сообщения
- 1,480
- Баллы
- 155

In developing a modern SaaS product for managing , we required a robust, scalable architecture that could support multi-tenancy, secure authentication, and seamless integration with government systems. After evaluating several toolsets, we chose the TMS Software ecosystemspecifically TMS Sphinx, TMS Aurelius, TMS XData, and TMS WEB Corefor its tight integration with Delphi, powerful abstractions, and developer efficiency.
Gift Aid is a UK tax relief that allows charities to claim an extra 25p for every £1 donated by UK taxpayers, at no additional cost to the donor. To receive this relief, charities must submit claims to HMRC, traditionally via paper or legacy systems. Since 2013, HMRC has required that all Gift Aid claims be submitted digitally through the Charities Online service, using either online forms or a machine-readable XML interface for bulk submissions. This shift has driven the need for compliant, automated, and scalable solutions like GiftAider.
To meet this need, developed a Windows desktop applicationGiftAider Desktopwhich enabled charities to prepare and submit their Gift Aid claims digitally. It allowed organisations to import donation data from existing systems or spreadsheets, or enter donations manually. That core functionality has now evolved into a full **SaaS platform**, rebuilt from the ground up using the TMS Software stack, with all the benefits of web access, scalability, and automation.

GiftAider screenshot
Project Overview
Our product enables charities to automate and manage Gift Aid submissions. It supports:
- Multi-tenancy, with a dedicated Firebird database per tenant
- Centralized authentication and authorization via a separate auth application built with TMS Sphinx
- A RESTful API backend developed in TMS XData
- A modern browser-based frontend using TMS WEB Core
- Full support for HMRC API submission protocols and audit compliance
- Background job processing for bulk submissions, including queuing, retry logic, and result tracking
Our architecture is based on a clean separation of concerns, structured for scalability and maintainability:
Layer | Technology | Role |
Authentication | TMS Sphinx | Central auth service using OAuth2/OpenID Connect |
Backend | TMS XData + Aurelius | Multi-tenant REST API and ORM-powered data layer |
Frontend | TMS WEB Core | Responsive SPA with token-based session handling |
Storage | FirebirdSQL | Dedicated schema-per-tenant isolation |
To achieve tenant isolation, we adopted a database-per-tenant model rather than a shared-schema approach. This design ensures:
- Strong data segregation and security
- Easier tenant-specific migrations and backups
- Lower risk of cross-tenant impact during updates or failures
Each tenant's Firebird database is provisioned on registration. Schema setup and updates are handled using Aurelius' schema management tools. At runtime, the tenant context is resolved from the incoming requesttypically via subdomain or HTTP headerand the correct database connection is instantiated dynamically using a factory pattern compatible with Aurelius and XData.
Authentication and Authorization with TMS Sphinx
All authentication and user management is handled by a dedicated auth service built with TMS Sphinx. Key features include:
- OAuth2 and OpenID Connect flows (authorization code, refresh token, etc.)
- Centralized user management and login history
- JWT access and refresh tokens for secure API access
Our main application remains stateless and does not directly manage user credentials. Instead, it consumes tokens issued by Sphinx and validates them via XData middleware on each API request. This separation of concerns ensures both better security and scalability.
Backend API with XData and Aurelius
The backend exposes all application functionality through a secure RESTful API built on XData, backed by Aurelius for ORM-based data access. Our design includes:
- Versioned, modular endpoints for long-term maintainability
- Tenant-aware middleware to dynamically bind the correct database context
- Clean separation between data access, business logic, and transport
- The bearer token is validated and decoded
- Tenant context is extracted from the token or request header
- A dynamic database connection is created
- The requested operation is executed within a scoped transaction
This pattern ensures full isolation and consistency while retaining the flexibility of a shared codebase.
Frontend in TMS WEB Core
We developed the entire frontend in TMS WEB Core, allowing Delphi developers to produce a modern web application without leaving the Pascal ecosystem. Highlights include:
- A responsive SPA that consumes the XData API
- Full integration with the OAuth2 authentication flow via the Sphinx app
- UI components bound to Aurelius DTOs
- Strong typing and design-time component layout with rapid feedback loops
Using TMS WEB Core means our Delphi developers can maintain both frontend and backend layers, streamlining the development process and reducing cognitive overhead.
Background Job Processing
To support high-volume submissions, especially for charities with large donor bases, we implemented background job processing for bulk Gift Aid claims.
This system:
- Uses Omni Thread Library
- Queues submission jobs in a dedicated job table
- Processes jobs asynchronously via a worker thread/service
- Includes retry logic for transient failures (e.g., network errors with HMRC)
- Logs all submission attempts and outcomes for auditing and reporting
By offloading large operations from the UI and main request pipeline, we maintain performance and responsiveness while ensuring reliability for high-throughput tenants.
Conclusion
Leveraging the full TMS Software stack allowed us to build a scalable, Delphi-native SaaS solution with clean separation of concerns and rapid time to market. With authentication handled by Sphinx, RESTful APIs via XData, database interaction through Aurelius, and a browser-based UI via WEB Core, weve delivered a modern platform tailored to the needs of UK charities managing Gift Aid submissions.
The platform includes background job processing for bulk submissions, allowing large claim files to be queued, processed asynchronously, and submitted to HMRC with full traceability, logging, and retry support.
Well continue to refine the platform and explore additional capabilities such as:
- SSO across partner portals
- Usage metering and subscription management
- Enhanced auditing and monitoring across tenant activity
This blog was written by our client Russell Weetch from and reviewed by Wagner Landgraf
Источник: