package main

import (
	fxzerolog "github.com/efectn/fx-zerolog"
	"go-humas-be/app/database"
	"go-humas-be/app/middleware"
	"go-humas-be/app/module/article_categories"
	"go-humas-be/app/module/article_category_details"
	"go-humas-be/app/module/article_files"
	"go-humas-be/app/module/articles"
	"go-humas-be/app/module/cities"
	"go-humas-be/app/module/districts"
	"go-humas-be/app/module/magazine_files"
	"go-humas-be/app/module/magazines"
	"go-humas-be/app/module/master_menus"
	"go-humas-be/app/module/master_modules"
	"go-humas-be/app/module/ppid_data_approval_histories"
	"go-humas-be/app/module/ppid_data_categories"
	"go-humas-be/app/module/ppid_data_files"
	"go-humas-be/app/module/ppid_datas"
	"go-humas-be/app/module/provinces"
	"go-humas-be/app/module/user_levels"
	"go-humas-be/app/module/user_role_accesses"
	"go-humas-be/app/module/user_role_level_details"
	"go-humas-be/app/module/user_roles"
	"go-humas-be/app/module/users"
	"go-humas-be/app/router"
	"go-humas-be/config/config"
	"go-humas-be/config/logger"
	"go-humas-be/config/webserver"
	"go.uber.org/fx"
)

func main() {

	fx.New(
		/* provide patterns */
		// config
		fx.Provide(config.NewConfig),
		// logging
		fx.Provide(logger.NewLogger),
		// fiber
		fx.Provide(webserver.NewFiber),
		// database
		fx.Provide(database.NewDatabase),
		// middleware
		fx.Provide(middleware.NewMiddleware),
		// data storage
		fx.Provide(config.NewMinio),
		// user management
		fx.Provide(config.NewKeycloakConfig),
		// router
		fx.Provide(router.NewRouter),

		// provide modules
		article_categories.NewArticleCategoriesModule,
		article_category_details.NewArticleCategoryDetailsModule,
		article_files.NewArticleFilesModule,
		articles.NewArticlesModule,
		cities.NewCitiesModule,
		districts.NewDistrictsModule,
		magazines.NewMagazinesModule,
		magazine_files.NewMagazineFilesModule,
		master_menus.NewMasterMenusModule,
		master_modules.NewMasterModulesModule,
		ppid_data_files.NewPpidDataFilesModule,
		ppid_data_categories.NewPpidDataCategoriesModule,
		ppid_data_approval_histories.NewPpidDataApprovalHistoriesModule,
		ppid_datas.NewPpidDatasModule,
		provinces.NewProvincesModule,
		user_levels.NewUserLevelsModule,
		user_roles.NewUserRolesModule,
		user_role_accesses.NewUserRoleAccessesModule,
		users.NewUsersModule,
		user_role_level_details.NewUserRoleLevelDetailsModule,

		// start aplication
		fx.Invoke(webserver.Start),

		// define logger
		fx.WithLogger(fxzerolog.Init()),
	).Run()
}
