How yata-repos/yata works
Project Type & Purpose
• This is a cross-platform full-stack application (“YATA”) written in Flutter/Dart, targeting mobile (Android, iOS), desktop (Windows, Linux, macOS) and web.
• It uses a serverless backend (Supabase) for database, authentication, real-time subscriptions, and storage.
• State is managed with Riverpod, navigation via go_router, and local offline support via a cache/offline-queue layer.
File-Structure & Architecture Overview
• Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” directories host platform wrappers around a single codebase in “lib”
• “lib/app” contains entrypoint (main.dart), router, DI wiring
• “lib/features/*” follows feature-module decomposition (auth, inventory, menu, order, analytics, export, settings) with clear subfolders: DTOs, models, presentation (pages/controllers/providers/widgets), repositories, services
• “lib/core” contains cross-cutting abstractions: contracts, constants, base classes, logging interfaces, realtime interfaces, validators
• “lib/infra” holds adapters/implementations: Supabase client, cache manager (memory/TTL), offline-queue, logging adapters, realtime manager
• “lib/shared” implements reusable UI components, theming, utilities
• Tests mirror the “core”, “features”, “infra”, “shared” hierarchy
• CI/CD automation in “.github/workflows” triggers multi-platform builds (AppImage, ZIP, APK) on version tags
• Configuration via .env for Supabase credentials, EnvValidator in core
Main Architectural Layers & Components
a. Presentation Layer (Flutter UI)
• Widgets/pages (“lib/features/*/presentation/pages”)
• Controllers & Providers (Riverpod) manage UI state
• Routing (go_router) with guards (auth_guard)
b. Domain & Service Layer
• Feature services (lib/features/*/services) implement business use-cases
• Use DTO ↔ Model mappers
c. Data Layer (Repository Pattern)
• Contracts defined in “lib/core/contracts”
• Repositories implement contracts in “lib/features/*/repositories” and “lib/infra/repositories”
d. Infrastructure Layer
• Supabase adapter (lib/infra/supabase/supabase_client.dart)
• Local cache & offline queue (lib/infra/local/cache and lib/infra/local/offline_queue)
• Realtime manager (lib/infra/realtime)
• Logging adapters & sinks (lib/infra/logging)
e. External Services
• Supabase (Auth, Postgres, Realtime subscriptions)
• Optional external analytics or error-reporting (via infra/logging)
Data Flow & Interactions
• UI event → Controller/Provider → Service → Repository contract → Infra Adapter → Supabase
• Read path: Supabase → Infra Adapter → Repository → Service → Provider → UI
• Write path: UI → Provider → Service → Repository → Offline Queue/Cache → Supabase
• Real-time updates via Supabase Realtime → RealtimeManager → Stream management mixins → Providers → UI
• Logging flows: Application code → LoggerBinding → Infra logging sinks (console, file, analytics)
Architectural Patterns & Principles
• Layered architecture (Presentation / Domain / Data / Infra)
• Feature-based modularization (each feature is self-contained)
• Dependency inversion: UI and services depend on abstract contracts, provided by wiring modules (override_dev, override_prod)
• Repository pattern for data access
• DI via Riverpod and custom provider wiring
• Separation of concerns: UI vs business logic vs data access vs infra