import 'package:finnow_app/api/main.dart';
import 'package:finnow_app/auth/model.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';
import 'app.dart';
import 'router.dart';

/// The global GetIt instance, used to get registered singletons.
final getIt = GetIt.instance;

void main() {
  setup();
  runApp(const FinnowApp());
}

/// Initializes some resources before we start the app.
void setup() {
  // Register the FinnowApi so it can be called easily from anywhere.
  getIt.registerSingleton<FinnowApi>(FinnowApi());

  // Register the AuthenticationModel singleton to hold the app's current
  // authentication information.
  getIt.registerSingleton<AuthenticationModel>(AuthenticationModel());
  
  // Register the GoRouter singleton to provide navigation in the app.
  getIt.registerSingleton<GoRouter>(getRouterConfig());
}
