How expo-starter/expo-local-first-template works
Project Type & Purpose
• The project is a mobile-first (and web-capable) Expo template aimed at local-first app development. It leverages the Expo framework (with React Native) to support cross-platform development, emphasizing local data persistence (via SQLite) and native performance.
• Key features highlighted in the README include integration with Expo v51, React Native, SQLite (along with SQL.js for web), DrizzleORM (including live query support), NativeWind (Tailwind CSS for React Native), and state management with Zustand.
File Structure
• Core Application Code:
• The “app” directory: Contains the main user interface code with routes and layout files organized into tabs, along with a not-found page and pages for creating and handling habits.
• The “components” directory: Divided into “primitives” (low-level, generic building blocks), “ui” (reusable UI components), “habit”, “settings”, and a couple of others. These modules provide a library of pre-built components, laid out with clear separation.
• Data and Database Layer:
• The “db” folder includes DrizzleORM integration files (drizzle configuration, migrations, schema) and a database provider component, signifying a dedicated data access layer using SQLite.
• Shared/Utility Libraries:
• Configuration & Tooling:
• Files like “app.config.ts”, “babel.config.js”, “tsconfig.json”, “drizzle.config.ts”, “tailwind.config.ts”, “vercel.json”, and “biome.json” indicate the project’s build, deployment, and linting configurations.
• The “.github” folder (with actions and workflows) defines CI/CD setups.
• Assets:
• The “assets” directory holds images that are used as banners as seen in the README.
Identifying the Main Components & Their Relationships
• Frontend (UI Layer):
• The primary UI is encapsulated in the “app” directory, with nested routes and layouts dictating navigation. Additional reusable UI pieces live in the “components/ui” and “components/primitives” directories.
• Data Access & Persistence:
• The “db” folder serves as the database layer. Here, the project interfaces with SQLite (native and web using sql.js) through DrizzleORM. This layer is responsible for data migrations, schema management, and live query updates.
• Utility & Library Functions:
• Configuration & CI/CD:
• GitHub Actions (under “.github”) and other configuration files show how the project handles continuous integration, builds (e.g., “pwa-build.yml” for progressive web app builds), and deployment.
Architectural Patterns & Design Principles
• Separation of Concerns:
• The project clearly separates the UI (app and components directories), the data layer (db), and shared utilities (lib). This modular division supports scalability and maintainability.
• Local-First Approach:
• The architecture is built around a local persistence model (using SQLite), with an eye toward potential remote synchronization as suggested by the provided blog article.
• Component Reusability:
• Extensive use of primitives and UI component libraries underscores a reusable, composable component design.
• Build and Deployment Pipelines:
• The CI/CD configuration using GitHub Actions demonstrates adherence to modern DevOps practices.