technical case study

Web App • System

Leituras

An app for organizing online reading, with chapter tracking, status and easy pick-up where you left off.

Product, design and development Active Continuously evolving
PHP JavaScript MySQL Bootstrap Docker
executive summary

Problem

There was no simple, efficient way to follow online reading with real progress tracking and organization.

Solution

A system with lists, statuses and chapter control was built to keep reading continuous.

Result

The app became a solid foundation for further development and everyday use.

Current stage

Active project with ongoing improvements.

context

A system for continuous reading

The project came from the need to follow readings scattered across the internet in an organized way, keeping history, progress and context.

goals and constraints

Goals

  • Track chapters
  • Organize readings into lists
  • Make it easy to resume reading
  • Prepare the structure for expansion

Constraints

  • Evolving project without a fixed scope
  • Local use at first
  • Need to keep things simple
  • Query performance as data grows
solution architecture

Front-end

Card-based interface with dynamic filters, search and status changes. Modular JavaScript updates the UI without a full page reload.

Back-end

PHP architecture with separated responsibilities (services, repositories), handling business rules, persistence and data organization.

Database

Tables for readings, lists and their relationship. Status, chapter and ordering control keep data consistent and fast to retrieve.

security and safeguards

Input validation

Submitted data is processed before being stored to avoid inconsistencies.

Layer separation

Services and repositories keep the interface from accessing the database directly.

Data control

Prevents duplicates and keeps saved readings consistent.

process
01

First idea

The project started as a personal solution for organizing online reading.

02

Base structure

Lists, statuses and chapter control were implemented.

03

Refactoring

Responsibilities were separated and the code structure improved.

04

Current state

A working system with a foundation ready for future expansion.

behind the scenes
src/js/features/leitura-ui.js JavaScript lines 3–41
function initLeiturasUI(leituraDataRaw) {
  const leituraData = Array.isArray(leituraDataRaw) ? leituraDataRaw : [];

  /* ========== Filtro por texto ========== */
  const searchInput = document.getElementById("searchInput");
  if (searchInput) {
    searchInput.oninput = function () {
      const termo = this.value.toLowerCase();

      document.querySelectorAll(".js-leitura-card").forEach(card => {
        const titulo = card.querySelector(".card-title")?.textContent.toLowerCase() || '';
        const descricao = card.querySelector(".card-text")?.textContent.toLowerCase() || '';

        const match = titulo.includes(termo) || descricao.includes(termo);
        card.style.display = match ? "" : "none"; // não força block/flex
      });
    };
  }

  /* ========== Filtro por status ========== */
  const statusFiltroEl = document.getElementById('statusFiltro');
  if (statusFiltroEl) {
    statusFiltroEl.onchange = function () {
      const statusFiltro = this.value;

      document.querySelectorAll(".js-leitura-card").forEach(card => {
        const id = card.querySelector(".statusSelect")?.dataset.id
                || card.dataset.id;
        const leitura = leituraData.find(l => String(l.id) === String(id));

        const mostrar = (
          statusFiltro === "0" ||
          (leitura && String(leitura.status) === String(statusFiltro))
        );

        card.style.display = mostrar ? "" : "none";
      });
    };
  }
Text and status filters applied directly to the cards, without reloading the page.
app/Services/PastaService.php PHP lines 57–81
public function applyPasta(int $id, array $body): void {
    $pastaId = (int)$id;
    if ($pastaId <= 0) throw new Exception('pasta_id inválido');

    $add = $this->sanitizeIds($body['add'] ?? []);
    $remove = $this->sanitizeIds($body['remove'] ?? []);

    if (!$add && !$remove) return;

    // não deixar o mesmo id nos dois
    $addSet = array_flip($add);
    $remove = array_values(array_filter($remove, fn($x) => !isset($addSet[$x])));

    $this->repo->applyPastaChanges($pastaId, $add, $remove);
}

private function sanitizeIds($arr): array {
    if (!is_array($arr)) return [];
    $out = [];
    foreach ($arr as $v) {
        $n = (int)$v;
        if ($n > 0) $out[$n] = true;
    }
    return array_keys($out);
}
The service validates the folder and sanitizes the received IDs before handing the write to the repository.
app/Repositories/PastaRepository.php PHP lines 98–127
public function applyPastaChanges(int $pastaId, array $add, array $remove): void {
    $this->pdo->beginTransaction();
    try {
        if (!empty($add)) {
            $stmt = $this->pdo->prepare(
                "INSERT IGNORE INTO pagina_pasta (pagina_id, pasta_id) VALUES (:pagina_id, :pasta_id)"
            );
            foreach ($add as $paginaId) {
                $stmt->execute([
                    ':pagina_id' => (int)$paginaId,
                    ':pasta_id' => $pastaId
                ]);
            }
        }

        if (!empty($remove)) {
            $in = implode(',', array_fill(0, count($remove), '?'));
            $stmt = $this->pdo->prepare(
                "DELETE FROM pagina_pasta WHERE pasta_id = ? AND pagina_id IN ($in)"
            );
            $params = array_merge([$pastaId], array_map('intval', $remove));
            $stmt->execute($params);
        }

        $this->pdo->commit();
    } catch (Throwable $e) {
        $this->pdo->rollBack();
        throw $e;
    }
}
A transaction with prepared statements adds and removes readings from a list atomically.
impact

Results

The system brought all readings into one place and made picking up where you left off easier, creating a solid base for new features.

Learnings

How important a well-defined architecture is from the start, so the project can grow without rework.