# A compliance platform, from a database in the browser to APIs.

> A subscription compliance product synced data straight from the browser to the database. It is being rebuilt: APIs with permissions checked on the server, separate services, containers and repeatable releases on AWS. We follow the project on infrastructure, security and the release plan.

- Sector: Business services
- Practice: Security
- Status: Ongoing
- URL: https://cloudfactory.it/en/projects/compliance-saas-api-docker-aws/

## In brief

Together with the product's developer, we follow the rebuild of a subscription compliance product. The new version removes the browser's direct access to the database: every operation goes through APIs that check roles and permissions on the server. The backend is split into services, the frontend moves to Vite, releases use versioned Docker images. We set eight conditions on the release plan, starting with the data migration.

- **8** conditions set on the release plan before production
- **2** environments, staging and production, isolated on the same machine

## Context

The product helps companies manage compliance obligations, with documents and email and SMS communications. The frontend is Quasar and Vue, the backend Node.js, data in CouchDB, documents on S3. Our role is coordination: architecture, AWS infrastructure, security and release, alongside the people writing the code.

## The problem

In the previous version the browser synced data with the database through PouchDB, and roles and permissions were checked mostly in the client. The backend was a single service, the frontend built with Webpack. The database schema is changing, and every client's data has to be migrated without losing any.

## What we did

1. **APIs with server-side permissions.** The new version removes direct database access: the frontend calls APIs that check roles and permissions on the server. Data encryption moves to the server too.
2. **Separate services.** The backend is split into services for the web API, command-line management, communications, scheduling, external APIs, the OpenAI integration and document storage. The frontend moves from Webpack to Vite.
3. **Repeatable releases.** Versioned Docker images on Amazon ECR, staging and production on AWS: a deploy pulls a ready-made image instead of building on the server, and rolling back means using the previous image.
4. **Eight conditions before production.** CouchDB migration with services stopped, original data kept intact as a rollback and a dry run on staging with real data; separate networks, ports and names between staging and production; keys out of the configuration file; an IAM role for ECR instead of static credentials; backups with a tested restore; security of the new endpoints, including the one that generates PDFs; healthchecks and automatic restarts; a written cutover sequence.
5. **Customer support.** Support emails reach an Odoo helpdesk as tickets for the product team: requests were not arriving: we fixed reception in the helpdesk and set up forwarding from the product's domain.

## How it went

The rebuild is ongoing. The new version goes to staging first with a copy of real data, then to production on a new address, following the agreed sequence.

## Tools

Node.js, Quasar, Vue, Vite, CouchDB 3.5, Docker, Amazon ECR, Amazon S3, OpenAI API, Odoo

## FAQ

### Why remove database sync from the browser?

Because checks made in the client can be bypassed. With APIs every read and write goes through a check on the server, which decides based on roles and permissions.

### Can staging and production live on the same machine?

Yes, if they are isolated: separate Docker networks, distinct ports and names and resource limits, so a test never touches production.

### How do you migrate data safely?

With services stopped, keeping the original data intact as a way back, and rehearsing the whole procedure on staging with a copy of real data first.

---

Cloudfactory S.r.l., Rome. Contact: hello@cloudfactory.it
