BUILD ON A CLEAR FOUNDATION

The map of
Modella.

From first startup to your next feature. Understand how the Lottie editor, identity and catalogues fit into one solution.

For new developers23 Nov 2026
SIMPLE OUTSIDE. MODULAR INSIDE.System view
Your browserReact · editing · local draft
SPA
Same origin · cookies + CSRF
One Spring Boot application
accesscataloglottie
Domain → use cases → adapters
MySQLOne schema
FilesOne volume
SMTPRecovery
No external identity provider
THE STACKJava 21Spring Boot 4.1.3React 18Vite 7MySQL 8.4 testedpnpm 11.25.0

START HERE

Your first walkthrough.

Four stops from the repository to a saved edit.

  1. Prepare the tools

    Java 21, Node ≥ 22.13, pnpm 11.25.0, Docker and an available MySQL instance. Maven runs with ./mvnw.

    View local startup
  2. Reserve your schema

    Create a dedicated database and application account. Flyway creates the tables; Hibernate validates the schema.

    Understand the tables
  3. Enter the studio

    Start Compose, sign in with the initial administrator and change the temporary password before continuing.

    Understand access
  4. Save an animation

    Create a project, import a resource and edit it. Saving uses revisions to detect concurrent changes.

    Follow an edit
The organising idea

Three business modules live within one monolith. They share a process, database and storage, while keeping their models and ports separate.

FROM THE REPOSITORY TO THE STUDIO

Deploy with the right context.

Choose an environment. Each path uses configuration already present in the repository.

compose.yaml

A local environment, your MySQL.

Compose starts frontend, monolith and mailpit. MySQL must already exist; no database container is created.

  1. Install and create the configuration. The initialiser generates .env with 0600 permissions and refuses to overwrite it.
  2. Fill in the credentials yourself. Configure DB_USER, DB_PASSWORD and the dedicated schema in DB_NAME. Check host and port.
  3. Build and start. Enter the studio and inspect the temporary password yourself in your local file.
From the repository root
pnpm install --frozen-lockfile
pnpm setup:local dev@example.com
# Completa tu .env antes de arrancar.
docker compose up -d --build
Studiohttp://localhost:18089Development emailhttp://localhost:18026
MySQL on your machine

In Docker Desktop, host.docker.internal:3306 points to the host. localhost inside the container points to that container itself.

Development cookies

For local HTTP: COOKIE_SECURE=false and PUBLIC_URL=http://localhost:18089. The initialiser already suggests these values.

compose.dokploy.yaml

HTTPS in front. Private network behind.

Traefik terminates TLS. Caddy serves the SPA on internal port 80 and proxies the API to the monolith on 8080. This Compose file publishes no host ports.

  1. Docker Compose service. Connect the private repository, use branch main and Compose Path ./compose.dokploy.yaml. Keep Isolated Deployments disabled for this configuration.
  2. Connect the existing MySQL instance. Use its Internal Host and internal port. DB_NETWORK must be an existing network shared with MySQL; by default, dokploy-network.
  3. Fill in Environment. Configure credentials and SMTP in Dokploy; preserve JWT_SECRET and INSTALLATION_ID between deployments.
  4. Configure Domains and deploy. Domain lottiej.acode.es, path /, service frontend, port 80, HTTPS and Let's Encrypt.
BrowserHTTPS · 443Traefik / DokployPrivate HTTP · 80Caddy / frontend/api/* · 8080Spring Boot / monolith

Do not add a separate backend domain. A shared origin keeps cookies and CSRF consistent.

Read the full Dokploy guide
Preserve the installation across updates

Do not combine the two Compose files. Keep the same service/project and volume mono-files. Update images without running docker compose down -v.

DNS and networking

The A record must point to the VPS. If an AAAA record exists, it must also resolve to a server serving the application. MySQL needs no Internet exposure.

First startup

Flyway applies migrations and Spring validates the schema. The initial administrator is created only when no users exist; changing initial variables does not edit an existing account.

Two development processes

Java and Vite, with local reload.

Export connection variables yourself for a dedicated schema in your MySQL instance. The backend also needs the JWT key, initial credentials and SMTP configuration.

  1. Configure DB_URL, DB_USER and DB_PASSWORD for your schema, with the UTC timezone.
  2. Set JWT_SECRET, INITIAL_ADMIN_EMAIL, INITIAL_ADMIN_PASSWORD, PUBLIC_URL and COOKIE_SECURE=false for local HTTP.
  3. Start Java and, in another terminal, Vite. The Vite proxy forwards /api and /public to localhost:8080.
Backend terminal
./mvnw spring-boot:run
Frontend terminal
pnpm --filter @modella/frontend dev

Use the URL printed by Vite. The backend listens on 8080.

Which configuration matters and where it is defined
Group Variables Responsibility
Persistence DB_HOST · DB_PORT · DB_NAME · DB_USER · DB_PASSWORD Compose constructs DB_URL; native execution sets DB_URL directly. Use a dedicated schema.
Identity JWT_SECRET · INITIAL_ADMIN_EMAIL · INITIAL_ADMIN_PASSWORD HS256 signing with a Base64 key of at least 32 bytes, and initial account creation in empty installations.
Origin PUBLIC_URL · COOKIE_SECURE · INSTALLATION_ID Recovery links, HTTPS cookies and a stable identity to separate drafts.
Email SMTP_HOST · SMTP_PORT · SMTP_AUTH · SMTP_STARTTLS · SMTP_USERNAME · SMTP_PASSWORD · MAIL_FROM Production requires real SMTP; Mailpit belongs only in the local environment.
Files STORAGE_PATH · FONTS_PATH In containers: files in /data/files and bundled fonts in /data/fonts.

BOUNDARIES THAT MAKE CHANGE EASIER

One monolith. Three domains.

Rules stay inside; HTTP, SQL and files connect through adapters.

lottie

The editor and its projects

JSON v1 document, optimistic revision, private resources, animation import and export.

ProjectService · DocumentValidator
catalog

Reusable content

Catalogues and items with metadata, files or external URLs, duplication and resource publishing.

CatalogService · CatalogRules
access

Identity in-house

Users, local credentials, roles, permissions, auditing and protection of the last administrator.

AccessService · IdentityRules

From browser to persistence

Production container and service view.

React and Caddy connect to a Spring Boot monolith using MySQL, a file volume and SMTP.
Source: repository Compose files, Dockerfiles, Caddy and Spring configuration.
domain

Models and invariants. No Spring or JPA.

application

Use cases and port contracts.

adapters

REST, persistence and storage.

configuration

Dependency wiring with Spring.

Class diagrams

Selected real classes. See the generated reference for all members.

ProjectService at the centre of the use case

The domain validates; ports resolve data and files.

ProjectController depends on ProjectService, which uses DocumentValidator, ProjectRepository and ResourceStorage. Its adapters are ProjectPersistence and PrivateStorage.
Solid arrow: dependency. Triangle with dashed line: interface implementation.

Metadata and files behind two ports

CatalogRules filters editable fields before persistence.

CatalogController uses CatalogService; the service depends on CatalogRules, CatalogRepository and CatalogStorage, implemented by CatalogPersistence and PublicStorage.
PublicFileController checks current metadata before serving a catalogue file.

Coordinate, validate and audit access

Administration is separated from credential and session details.

AccessController uses AccessService, which depends on IdentityDirectory, IdentityGuard and AuditTrail. Their implementations are LocalIdentityDirectory, DatabaseIdentityGuard and DatabaseAudit.
The identity_lock lock prevents concurrent removal of the last two administrative access assignments.

FOLLOW AN ACTION THROUGH THE SYSTEM

What happens when you edit.

The interface preserves your work; the server decides which version can be committed.

You editDocument + history in React
250 msDraft in IndexedDB
2 secondsScheduled REST save
Revision + 1Only when the expected revision matches

A conditional write without silent overwrites

The UPDATE atomically compares and increments the revision.

The editor sends the document and revision. The API authenticates and validates CSRF; ProjectService validates resources, and persistence updates only when the revision matches. It returns a new revision or a 409 error.
A 409 response stops automatic retries and preserves the local draft.

The cookie identifies; the database decides privileges

The revocable session, user status and current permissions are checked.

The SPA obtains CSRF and sends credentials; the server rate-limits attempts, verifies BCrypt and records a session. It issues a JWT in a cookie and checks its validity and permissions on every request.
First access requires changing the temporary password before using business APIs.

Delete metadata now; retry disk operations later

The deletion intent is committed in the same business transaction.

ProjectService locks the project, queues file keys and deletes its metadata. After commit, FileCleanup processes the queue and retries disk failures.
Uploads and duplication use the reverse compensation: a rollback attempts to remove newly created files.
Try it here · local simulation

Two tabs, one revision.

Both start at revision 7. Save from A, then from B: see why the server rejects the second write.

This example does not call the API or modify projects.

Server revision 7
Tab Aespera revisión 7
Tab Bespera revisión 7
Ready to save. Choose a tab.
The frontend engine

document.mjs manages layers, tracks and history. compiler.mjs converts to Lottie JSON. SVG, text, curves and packages have their own modules; the WASM player prefers WebGL and can fall back to Canvas.

The original file matters

dotLottie packages can preserve other animations, themes and state machines. Export protects their structural references; it does not transform the editor's v1 document format.

FROM FORM TO AUTHENTICATED SESSION

Login with Spring Validator and JWT.

Spring Validator checks received data, BCrypt verifies the password and Spring Security validates the JWT and access on every request.

Validación

Is the input valid?

Spring MVC integrates Jakarta Validation through Spring Validator. @Valid activates DTO constraints before the controller method executes.

Login DTO · @NotBlank · @Email · @Size
Autenticación

Do the credentials match?

AuthAccounts looks up the local user, checks that the account is enabled and uses PasswordEncoder.matches to compare the password with its BCrypt hash.

BCrypt cost 12 · SQL transaction
Sesión

Can access continue?

The server signs a 30-minute JWT and delivers it in a cookie. Each protected request checks the token, persisted session and current privileges.

HS256 · auth_sessions · Spring Security
Obtain CSRFGET /api/v1/csrf
Validate the DTOPOST /api/v1/auth/login
Verify and recordBCrypt + auth_sessions
Issue JWT cookie200 · authenticated: true
Spring Validator in the controller

A valid DTO still needs authentication.

In AuthController, the JSON body is bound to Login with @Valid @RequestBody. Annotations check presence, email format and length; they do not query the account or verify the password.

  1. Before the controller: CSRF. The SPA preserves the same-origin cookie and sends the token in the header named by /csrf. It is also required for login.
  2. Before the method: validate. A violated constraint produces a field error that ApiErrors transforms into Problem Details with status 422.
  3. Inside login: authenticate. Attempts are limited by IP and account, then the enabled user and password are checked. Incorrect credentials produce a uniform 401 response.
  4. Record before signing. authenticateAndOpen locks the user row and creates the SQL session in the same transaction, coordinating with password changes.
AuthController.Login · actual constraints
public record Login(
    @NotBlank @Email @Size(max = 254)
    String email,

    @NotBlank @Size(max = 72)
    String password
) {}

// Parámetro de entrada del método login:
// @Valid @RequestBody Login data

The policy for new passwords—12–72 printable ASCII characters—applies to account creation, changes and resets. The login DTO checks the limits shown here.

What the JWT contains and how it is validated

AuthController builds the claims and NimbusJwtEncoder signs with HS256. LocalSecurity configures the decoder and per-request checks.

Claim / check Value in Modella Purpose
iss and aud modella-mono and modella-web Identify the issuer and audience accepted by the decoder.
sub Local user identifier. Links the token to the enabled user and current assignments.
jti Session UUID. Must exist in auth_sessions, belong to the subject and remain valid.
iat and exp Issue and expiry times, 1800 seconds apart. Limit JWT lifetime to 30 minutes, without silent renewal.
HS256 signature Key JWT_SECRET in Base64, at least 32 bytes long. The decoder checks integrity and algorithm. Signing does not encrypt claims; the token contains no passwords.
Roles and permissions Queried from the database on every request. The JWT carries no copy of privileges. Disabling users or changing assignments takes effect on the next request.
How the browser receives it

The cookie MODELLA_TOKEN uses HttpOnly, SameSite=Strict, path / and Secure in production. The JSON response contains authenticated: true; the SPA neither receives the JWT in JSON nor stores it in localStorage. It then queries GET /api/v1/session to load the user, permissions and mustChangePassword.

How access is revoked

Logout deletes the session row and removes the cookie. Changing or resetting a password invalidates all user sessions. Even a saved copy of an unexpired JWT is rejected when SQL detects a revoked session.

STATELESS does not remove application session records

SessionCreationPolicy.STATELESS avoids using a Spring Security HttpSession to preserve authentication between requests. Modella maintains auth_sessions to check JWT validity and revocation. If must_change is active, the server restricts business APIs until the temporary password is changed.

Which error belongs to each login stage
Status Origin What the frontend displays or checks
400 JSON that cannot be parsed or bound correctly. Review the body and types sent to the API.
422 DTO Jakarta Validation constraints. Display errors beside the form fields.
401 Incorrect credentials or, on protected routes, an invalid token/session. Display the access error or request a new login.
403 Invalid CSRF; on protected routes, permissions or an outstanding initial password change. Check CSRF, session status and operation permissions.
429 More than ten attempts in the persistent fifteen-minute window per IP or account. Wait before retrying; rejection does not clear the counter.

THE PERSISTENT STRUCTURE

One database, clear responsibilities.

14 tables declared in V1__monolith.sql. JSON for editable content; explicit ownership and identity relationships.

Ownership of resources and items

Bytes live on disk; keys and metadata live in SQL.

A project has zero or more private resources. A catalogue has zero or more items. file_key values logically link to files on disk.
PK = primary key · FK = foreign key · UQ = unique constraint. Multiplicities reflect physical relationships.

Roles, permissions and revocable sessions

Definitions are identified by the (name, permission) pair.

Users relate to assignments, sessions and one recovery record per user. Definitions have a composite name/type key. Role permissions reference two definitions of different types.
identity_assignments stores direct assignments; identity_role_permissions defines inherited permissions.

Coordination and recovery

Four independent tables, without business foreign keys.

pending_file_deletions stores deletion tasks; identity_lock coordinates administrators; audit_entries stores audits and auth_attempts limits attempts. No foreign keys connect these tables.
The queue and audit trail outlive the business records they describe.
Dictionary of the 14 tables
Table What it stores Rule to remember
lottie_projects JSON document, name, revision and date. The expected revision protects saving.
lottie_resources Private-file metadata and key. Required project_id; cascading SQL deletion.
catalogs Catalogue, public code, status and payload. Stable unique_code; entity revision.
catalog_elements Item, type, metadata and optional file. Required catalog_id; the service removes children first.
identity_users Profile, unique email, hash and status. must_change blocks business operations until the password changes.
identity_definitions Local roles and permissions. Composite PK: name + permission.
identity_assignments Roles and permissions assigned to users. FK to user and definition; composite key prevents duplicates.
identity_role_permissions Permissions making up a role. Composite FKs and CHECK distinguish roles from permissions.
auth_sessions Active session identified by JWT ID. FK to user and expiry; logout deletes the row.
password_resets SHA-256 of the recovery token. One link per user; single-use, 15 minutes.
auth_attempts Counter and expiry per bucket. Persistent windows shared across instances.
identity_lock One coordination row, id = 1. Transactional lock for administrative access.
audit_entries Actor, action, resource and outcome. Independent transaction; no credentials or bodies.
pending_file_deletions Key, attempts and pending-deletion date. Unique file_key; delete the file first, then the task.
The schema has one owner: Flyway

Hibernate uses ddl-auto: validate. After deploying a version, add a new migration; do not edit V1 or an applied migration. Rolling back an image does not automatically revert the database.

OPERATE WITH CONTEXT

Integrated security and recovery.

Controls live on the server. Interface states help explain them.

Revocable sessions

30-minute HS256 JWT in an HttpOnly, SameSite Strict cookie, Secure in production. The database checks session, status and privileges on every request.

Local credentials

BCrypt with cost 12. New passwords use 12–72 printable ASCII characters. Single-use 15-minute recovery, with only its SHA-256 persisted.

Explicit authorisation

admin administers identity. lottie-manage and catalog-manage enable each area. The initial role editor includes both permissions.

Inspected content

The server checks content and format, sanitises SVG and limits ZIP files. Only catalogue files with current metadata are served publicly.

Limits that shape a feature

Distinguish transport, use-case and document limits.

20 MiBUpload per editor resource
100 MiBCatalogue file and multipart limit
12 MiBSerialised document when saving
10 / 15 minPersistent sign-in attempts per IP/account

Editor uploads are also limited to 60 per minute and identity per instance. A ZIP allows up to 1000 entries, 20 MiB per entry and 64 MiB uncompressed. The multipart request limit is 102 MiB.

After deployment

  • Check for HTTP 200 from the page and /api/v1/csrf.
  • Review startup, migrations and MySQL connectivity.
  • Sign in, change the initial password and create/open a project.
  • Test email using your production SMTP.
curl --silent --output /dev/null \
  --write-out '%{http_code}\n' https://lottiej.acode.es/
curl --silent --output /dev/null \
  --write-out '%{http_code}\n' https://lottiej.acode.es/api/v1/csrf

What to preserve

  • Back up the MySQL schema and volume together mono-files, within a consistent window.
  • Validate restoration in an isolated installation before relying on it.
  • Preserve INSTALLATION_ID; rotating JWT_SECRET invalidates issued tokens.
  • Correlate errors using X-Request-Id; do not copy secrets or sensitive bodies into logs.
The repository provides no complete automated backup/restore procedure. It must be defined as part of environment operations.
Diagnose common failures
Signal What to check
401 / 403 Valid session, Secure cookie/origin, CSRF header, current permissions and initial password change.
409 when saving Another tab committed a different revision. Preserve the draft and resolve the conflict before reloading.
422 Problem Details includes field errors: document structure, references, formats and limits.
429 Attempt or upload limit. Check the window and Retry-After when returned.
Unknown database / Access denied Schema existence, credentials and application-account permissions.
Communications link failure Internal host, port, shared network and MySQL listening from Docker.
Recovery email does not arrive SMTP configuration, TLS and delivery. The public response is uniform and does not reveal whether the account exists.

Known limitations: no MFA or silent renewal. Recovery email is synchronous; a transactional outbox would be a future improvement, not a current feature.

YOUR NEXT CHANGE

Find the right place. Check the contract.

Before adding infrastructure, locate the rule and its owning module.

modella_lottie_mono/
backend/src/main/java/com/modella/
├── access/       # identidad local
├── catalog/      # catálogos y elementos
├── lottie/       # proyectos del editor
└── support/      # archivos, web y seguridad
backend/src/main/resources/
└── db/migration/ # esquema Flyway
frontend/src/
├── platform/     # API, navegación y UI
├── pages/        # panel y autenticación
└── lottie/
    ├── core/     # documento y compilación
    └── components/ # controles y hooks
infra/            # imágenes y proxy
scripts/          # configuración y documentación
docs/html/        # este portal + referencias

A well-placed change

  1. Business rule. Model and validate in the domain; do not introduce Spring or JPA there.
  2. Use case. Define the operation and its transaction boundaries. If it touches files, design compensation and retry.
  3. Adapters. Connect HTTP, SQL or disk through existing or explicit ports. Keep the same process and schema.
  4. Contract and verification. Update OpenAPI when a public API changes, add Spanish Javadoc/JSDoc and run the appropriate checks.
Preserve Lottie_v1 intact, along with the editor's JSON v1 format. Do not commit .env, backups or browser sessions.
What to check Command Scope
Production frontend pnpm build Vite build.
Editor engine pnpm test Document and transformation unit tests.
Editor in the browser pnpm --filter @modella/frontend test:e2e Chromium with test transport.
Panel and access pnpm --filter @modella/frontend test:platform Flows with a mocked API.
Java domain and use cases ./mvnw test Unit tests and architecture rules.
Java formatting ./mvnw spotless:check Backend conventions.
SQL / HTTP integration ./mvnw verify -Pintegration Ephemeral MySQL through Testcontainers.
This portal pnpm test:docs Static portal links and behaviour.
Regenerate references pnpm docs:build Javadoc, JSDoc, diagrams and local sources.
Tests never target an existing database

Use the Testcontainers integration profile to validate persistence. Do not export credentials from a user's database to run tests. Docker must be available to create ephemeral MySQL.

FROM OVERVIEW TO DETAIL

Open the contract you need.

These references are included in local subfolders and can be read offline.

Documentation that evolves with the code.

From the root, run pnpm docs:build after changing contracts or comments. SVGs are generated from scripts/docs-diagrams.mjs; update relationships when the model changes. This guide is a snapshot, not a deployment monitor.

Search the guide

Local search across this guide's sections. Generated references have their own index.

Diagram

100 %

Scroll to explore the enlarged diagram. Escape closes this view.

CV & portfolio · ES / EN
EspañolEnglish