package main

import (
	"time"
	"web-qudo-be/app/database"
	"web-qudo-be/app/middleware"
	"web-qudo-be/app/module/about_us_content_images"
	"web-qudo-be/app/module/about_us_contents"
	"web-qudo-be/app/module/activity_logs"
	"web-qudo-be/app/module/advertisement"
	"web-qudo-be/app/module/approval_workflow_steps"
	"web-qudo-be/app/module/approval_workflows"
	"web-qudo-be/app/module/article_approval_flows"
	"web-qudo-be/app/module/article_approval_step_logs"
	"web-qudo-be/app/module/article_approvals"
	"web-qudo-be/app/module/article_categories"
	"web-qudo-be/app/module/article_category_details"
	"web-qudo-be/app/module/article_comments"
	"web-qudo-be/app/module/article_files"
	"web-qudo-be/app/module/article_nulis_ai"
	"web-qudo-be/app/module/articles"
	"web-qudo-be/app/module/bookmarks"
	"web-qudo-be/app/module/cities"
	"web-qudo-be/app/module/client_approval_settings"
	"web-qudo-be/app/module/clients"
	"web-qudo-be/app/module/cms_media"
	"web-qudo-be/app/module/custom_static_pages"
	"web-qudo-be/app/module/districts"
	"web-qudo-be/app/module/feedbacks"
	hero_content_image "web-qudo-be/app/module/hero_content_images"
	hero_content "web-qudo-be/app/module/hero_contents"
	"web-qudo-be/app/module/magazine_files"
	"web-qudo-be/app/module/magazines"
	"web-qudo-be/app/module/master_menus"
	"web-qudo-be/app/module/master_modules"
	"web-qudo-be/app/module/our_product_content_images"
	"web-qudo-be/app/module/our_product_contents"
	"web-qudo-be/app/module/our_service_content_images"
	"web-qudo-be/app/module/our_service_contents"
	"web-qudo-be/app/module/partner_contents"
	"web-qudo-be/app/module/popup_news_content_images"
	"web-qudo-be/app/module/popup_news_contents"
	"web-qudo-be/app/module/provinces"
	"web-qudo-be/app/module/schedules"
	"web-qudo-be/app/module/subscription"
	"web-qudo-be/app/module/user_levels"
	"web-qudo-be/app/module/user_role_accesses"
	"web-qudo-be/app/module/user_role_level_details"
	"web-qudo-be/app/module/user_roles"
	"web-qudo-be/app/module/users"
	"web-qudo-be/app/router"
	"web-qudo-be/config/config"
	"web-qudo-be/config/logger"
	"web-qudo-be/config/webserver"

	fxzerolog "github.com/efectn/fx-zerolog"
	"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),
		// smtp config
		fx.Provide(config.NewSmtpConfig),

    // // modules
    //     hero_content.NewHeroContentModule,
    //   hero_content_image.NewHeroContentImageModule,


		// provide modules
		about_us_contents.NewAboutUsContentsModule,
		about_us_content_images.NewAboutUsContentImageModule,
		activity_logs.NewActivityLogsModule,
		advertisement.NewAdvertisementModule,
		approval_workflows.NewApprovalWorkflowsModule,
		approval_workflow_steps.NewApprovalWorkflowStepsModule,
		article_approval_flows.NewArticleApprovalFlowsModule,
		article_approval_step_logs.NewArticleApprovalStepLogsModule,
		article_categories.NewArticleCategoriesModule,
		article_category_details.NewArticleCategoryDetailsModule,
		article_files.NewArticleFilesModule,
		article_approvals.NewArticleApprovalsModule,
		articles.NewArticlesModule,
		article_comments.NewArticleCommentsModule,
		article_nulis_ai.NewArticleNulisAIModule,
		bookmarks.NewBookmarksModule,
		cities.NewCitiesModule,
		client_approval_settings.NewClientApprovalSettingsModule,
		clients.NewClientsModule,
		cms_media.NewCmsMediaModule,
		custom_static_pages.NewCustomStaticPagesModule,
		districts.NewDistrictsModule,
		feedbacks.NewFeedbacksModule,
		hero_content.NewHeroContentsModule,
		hero_content_image.NewHeroContentImagesModule,
		magazines.NewMagazinesModule,
		magazine_files.NewMagazineFilesModule,
		master_menus.NewMasterMenusModule,
		master_modules.NewMasterModulesModule,
		our_product_contents.NewOurProductContentsModule,
		our_product_content_images.NewOurProductContentImagesModule,
		our_service_contents.NewOurServiceContentsModule,
		our_service_content_images.NewOurServiceContentImagesModule,
		partner_contents.NewPartnerContentsModule,
		popup_news_contents.NewPopupNewsContentsModule,
		popup_news_content_images.NewPopupNewsContentImagesModule,
		provinces.NewProvincesModule,
		schedules.NewSchedulesModule,
		subscription.NewSubscriptionModule,
		user_levels.NewUserLevelsModule,
		user_roles.NewUserRolesModule,
		user_role_accesses.NewUserRoleAccessesModule,
		users.NewUsersModule,
		user_role_level_details.NewUserRoleLevelDetailsModule,

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

		// start scheduling
		fx.Invoke(webserver.RunScheduling),

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

		fx.StartTimeout(600*time.Second),
	).Run()
}
