NASIJ is a wool traceability and operations platform built as a multi-surface product:
- a Flutter mobile app for field users and suppliers
- a FastAPI backend for mobile and dashboard workflows
- a React/Vite dashboard for operations and monitoring
- a separate set of AI microservices and data/warehouse assets used for experimentation and supporting workflows
This repository is therefore a monorepo, not a single app.
AUP-Viltrumites/
βββ nasij/ # Flutter mobile app + mobile-facing FastAPI backend
β βββ lib/ # Flutter UI, cubits, offline storage, services
β βββ backend/ # FastAPI API for mobile flows
β βββ assets/ # Mobile env and app assets
βββ nasij-web/
β βββ nfn-dashboard/ # React/Vite web dashboard
β βββ nfn-backend/ # FastAPI backend for dashboard/control-tower workflows
βββ backend/ # Standalone AI/ML microservices
βββ warehouse/ # SQL + ETL + warehouse demo assets
βββ scripts/ # Utility scripts
The stack below is confirmed from the codebase and dependency manifests currently in the repo.
Location: nasij/
- Framework: Flutter
- Language: Dart
- State management:
flutter_bloc+equatable - Local persistence: Hive / Hive Flutter
- Connectivity handling:
connectivity_plus - Background work:
workmanager - HTTP client:
http - Config loading:
flutter_dotenv - Maps and geo:
flutter_map,latlong2,geolocator - QR / camera tooling:
qr_flutter,camera,google_mlkit_barcode_scanning - Localization: Flutter localizations + app-localized string files in
lib/l10n
Location: nasij/backend/
- Framework: FastAPI
- Language: Python
- ASGI server: Uvicorn
- Validation/config: Pydantic +
pydantic-settings - Data/auth backend: Supabase
- Testing:
pytest,pytest-asyncio,httpx - Additional ML/data libs present in requirements: NumPy, Pandas, Pillow, Joblib, scikit-learn
Location: nasij-web/nfn-dashboard/
- Framework: React
- Bundler/dev server: Vite
- Routing:
react-router-dom - UI libraries: MUI (
@mui/material, Emotion), Lucide icons - Charts:
recharts - Maps:
leaflet,react-leaflet - QR rendering:
qrcode.react - Styling support: Tailwind CSS v4 and custom CSS/theme files
- Backend connection: Supabase JS client
Location: nasij-web/nfn-backend/
- Framework: FastAPI
- Language: Python
- Data/auth backend: Supabase
- API style: router-based modular REST endpoints
Location: backend/
- Framework: FastAPI microservices
- Focus: traceability alerts, photo verification, translation, matching, forecasting, sheep/wool classification, and related ML experiments
- Tooling: scikit-learn, joblib, image-processing utilities, model artifacts
Location: warehouse/
- SQL schema and marts
- ETL/sync scripts in Python
- Local demo and setup blueprints
The mobile app is the operational client for field users. From the codebase, it currently includes:
- role-based flows for supplier and worker modes
- localized UI in English, French, and Arabic
- offline session and queue storage with Hive
- background sync support
- supplier declaration and operations screens
- profile, connectivity, and sync visibility
- QR and map-related user flows
Entry point:
nasij/lib/main.dart
Key implementation areas:
nasij/lib/cubitsnasij/lib/screensnasij/lib/servicesnasij/lib/data
The mobile backend exposes a consolidated FastAPI app with modular routers for:
- auth
- batches
- alerts
- sync
- suppliers
- dashboard
- users
- AI endpoints
Key file:
nasij/backend/app/main.py
This backend uses Supabase for authentication and persistence and includes health endpoints and a lightweight Supabase keepalive task.
The dashboard is the browser-facing operations interface. It is implemented as a React/Vite app with analytics, mapping, and operational views such as:
- home/dashboard views
- alerts
- certification
- map
- pipeline
- user management
- login/session handling
Relevant paths:
nasij-web/nfn-dashboard/src/pagesnasij-web/nfn-dashboard/src/hooksnasij-web/nfn-dashboard/src/layout
The dashboard backend is another FastAPI service with routers for:
- auth
- batches
- alerts
- dashboard
- sync
- users
This suggests the repo currently supports two backend entry points:
nasij/backendfor mobile-facing and extended workflowsnasij-web/nfn-backendfor dashboard/control-tower workflows
That split is also reflected in project planning notes.
This repo follows a pragmatic, modular, product-oriented approach rather than a strict single-pattern architecture.
The code is grouped by application surface and responsibility:
- mobile app code in
nasij - mobile API code in
nasij/backend - dashboard frontend and backend in
nasij-web - AI services in
backend - warehouse/data work in
warehouse
This makes it easier to evolve product surfaces independently while keeping related assets in one repository.
Both FastAPI backends are organized around routers and schemas instead of one large application file.
Examples:
auth.pybatches.pyalerts.pysync.pysuppliers.pyusers.pydashboard.py
This approach keeps business concerns separated and makes endpoints easier to test and extend.
The mobile app is clearly designed around unreliable connectivity.
The implementation uses:
- Hive for local persistence
- a sync queue / outbox pattern
- connectivity state tracking
- background sync helpers
- UI fallbacks for offline reads and deferred writes
This is one of the clearest architectural themes in the codebase.
On the Flutter side, app behavior is coordinated through Cubits rather than putting logic directly into widgets.
That gives the project:
- clearer UI state transitions
- easier session/auth handling
- more isolated sync and connectivity logic
- better maintainability than embedding business logic in screens
Supabase is used as the main hosted platform layer for:
- authentication
- PostgreSQL persistence
- operational data access
- schema/migration workflows
The project relies on backend-mediated access for sensitive actions instead of pushing privileged logic into the mobile client.
The repo shows a practical mix of:
- production-facing app code
- planning documentation
- migration SQL
- seeded/demo data
- AI experiments and detached services
So the engineering style here is not "greenfield perfect purity"; it is iterative delivery with working product code, supporting experiments, and documented expansion plans living together.
- Offline-first mobile behavior is a primary requirement.
- Supplier onboarding and approval workflows are important business flows.
- Localization is treated as a first-class concern.
- Backend ownership and authorization are emphasized for operational actions.
- The dashboard and mobile experiences are related but not identical products.
- AI services are kept modular and detachable from the core transactional apps.
The repository uses environment files in multiple places, with separate responsibility by surface:
nasij/assets/.envPurpose: mobile-facing runtime values such asMOBILE_API_BASE_URLnasij/backend/.envPurpose: backend secrets/config such asSUPABASE_URL, anon key, service role key, port, and CORSnasij-web/nfn-dashboard/.env.examplePurpose: dashboard frontend environment template
Recommended practice for this repo:
- keep mobile env files free of backend secrets
- keep backend secrets only in backend env files
- treat Supabase service-role keys as backend-only secrets
- restart the mobile app fully after env changes because Flutter asset env loading happens at startup
Typical work happens in:
nasij/lib/screensfor UInasij/lib/cubitsfor statenasij/lib/servicesfor API/service integrationnasij/lib/datafor offline storage and sync
Typical work happens in:
nasij/backend/app/routersnasij/backend/app/schemas.pynasij/backend/app/deps.pynasij/backend/migrationsnasij/backend/tests
Typical work happens in:
nasij-web/nfn-dashboard/src/pagesnasij-web/nfn-dashboard/src/hooksnasij-web/nfn-dashboard/src/componentsnasij-web/nfn-dashboard/src/lib
Typical work happens in:
- individual service folders under
backend/ - training scripts
- artifact generation
- service-specific app entry points
Because this is a monorepo, there is no single universal startup command for every surface. Use the relevant app or service directory.
From nasij/:
flutter pub get
flutter runFrom nasij/backend/:
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8001Health checks:
GET /health
GET /api/healthFrom nasij-web/nfn-dashboard/:
npm install
npm run devFrom nasij-web/nfn-backend/:
uvicorn app.main:app --reloadFrom backend/:
python run_all.pyThe codebase is ambitious and broad. A few practical truths are worth calling out:
- there are multiple active backends, so clear API ownership matters
- some older docs in subfolders are stale or template-level
- the repo contains both production workflow code and experiment/prototype material
- planning documents are unusually important here because they explain intended system boundaries
That is not necessarily a problem, but it does mean contributors should confirm which surface they are changing before they start coding.
When extending this project, the safest approach is:
- Confirm which surface owns the feature: mobile app, mobile backend, dashboard, dashboard backend, AI service, or warehouse.
- Keep env/config changes scoped to the correct subproject.
- Put business rules in backend routes/services rather than only in UI logic.
- Preserve offline-first behavior for mobile changes.
- Add or update localization keys for user-facing text.
- Prefer extending existing routers/cubits/services over introducing duplicate flows.
- Mobile app
- Mobile backend
- Dashboard frontend
- Dashboard backend
- AI services
- Warehouse
- Implementation plan
This project uses:
- Flutter + Bloc + Hive for the mobile client
- FastAPI + Supabase for transactional backend services
- React + Vite + MUI + Leaflet + Recharts for the dashboard
- separate Python AI microservices for model-backed capabilities
- SQL and ETL assets for data/warehouse support
The overall code approach is modular, offline-first on mobile, router-driven on the backend, and pragmatic in delivery. It is designed to support operational workflows in low-connectivity environments while keeping analytics, admin tooling, and ML capabilities in adjacent but separable modules.