> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/marcosfabricio3/simple-manager-mobile/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture Overview

> High-level overview of Simple Manager Mobile's architecture and design principles

## Introduction

Simple Manager Mobile is a mobile-first management application built with **Expo** and **React Native**. The application follows **Clean Architecture** principles to ensure maintainability, testability, and scalability.

## Core Technologies

<CardGroup cols={2}>
  <Card title="Expo & React Native" icon="mobile">
    Cross-platform mobile framework for iOS, Android, and Web
  </Card>

  <Card title="TypeScript" icon="code">
    Type-safe development with full IDE support
  </Card>

  <Card title="SQLite" icon="database">
    Local-first data storage via expo-sqlite
  </Card>

  <Card title="Expo Router" icon="route">
    File-based routing for navigation
  </Card>
</CardGroup>

## Architecture Principles

<AccordionGroup>
  <Accordion title="Clean Architecture">
    The application is structured into distinct layers with clear separation of concerns. Each layer has specific responsibilities and dependencies flow inward toward the domain layer.
  </Accordion>

  <Accordion title="Local-First">
    All data is stored locally using SQLite, ensuring the app works offline. The architecture is designed to support future migration to an API backend.
  </Accordion>

  <Accordion title="Soft Delete Pattern">
    Records are never permanently deleted. An `isDeleted` flag marks logical deletion, preserving data integrity and enabling recovery.
  </Accordion>

  <Accordion title="Type Safety">
    TypeScript is used throughout the codebase to catch errors at compile time and provide better developer experience.
  </Accordion>
</AccordionGroup>

## Key Design Decisions

### Database Choice

SQLite via `expo-sqlite` was chosen for local-first data storage. This provides:

* Fast, embedded database
* Cross-platform compatibility
* Zero configuration
* Offline-first capability

### ID Generation

UUIDs are generated using `expo-crypto` to ensure:

* Globally unique identifiers
* No server coordination needed
* Future-proof for distributed systems

### Validation Layer

Validation logic is handled at the **application layer** rather than the database level, providing:

* Business rule enforcement
* Consistent error messages
* Easy to test and modify

### Future-Ready Design

The architecture is designed to support migration to an API backend:

* Repositories abstract data access
* Services contain business logic
* Easy to swap repositories with HTTP adapters

## Main Entity: Record

The application uses a flexible `Record` entity that represents any manageable item:

<CodeGroup>
  ```typescript Record Interface theme={null}
  export interface Record {
    id: string;           // UUID
    title: string;        // Display name
    subtitle?: string;    // Secondary text
    metadata?: string;    // JSON string for flexible data
    type: string;         // Record type (client, task, appointment, note)
    userId?: string;      // Owner reference
    createdAt: string;    // ISO timestamp
    updatedAt: string;    // ISO timestamp
    isDeleted: boolean;   // Soft delete flag
  }
  ```
</CodeGroup>

<Note>
  The `Record` entity is intentionally generic to support multiple use cases (clients, appointments, tasks, notes) without requiring separate tables.
</Note>

## Application State

* **Local State**: React hooks and useState
* **Global State**: Zustand for lightweight state management
* **Database State**: SQLite as source of truth

## Next Steps

<CardGroup cols={2}>
  <Card title="Clean Architecture" icon="layer-group" href="/architecture/clean-architecture">
    Learn about the four architectural layers
  </Card>

  <Card title="Data Flow" icon="arrows-spin" href="/architecture/data-flow">
    Understand how data moves through the system
  </Card>

  <Card title="Folder Structure" icon="folder-tree" href="/architecture/folder-structure">
    Explore the project organization
  </Card>

  <Card title="Development Guide" icon="hammer" href="/development">
    Start building features
  </Card>
</CardGroup>
