package main

import (
	"narasi-ahli-be/app/database"
	"narasi-ahli-be/app/middleware"
	"narasi-ahli-be/app/module/activity_logs"
	"narasi-ahli-be/app/module/advertisement"
	"narasi-ahli-be/app/module/agent"
	"narasi-ahli-be/app/module/ai_chat"
	"narasi-ahli-be/app/module/ai_chat_files"
	"narasi-ahli-be/app/module/article_approvals"
	"narasi-ahli-be/app/module/article_categories"
	"narasi-ahli-be/app/module/article_category_details"
	"narasi-ahli-be/app/module/article_comments"
	"narasi-ahli-be/app/module/article_files"
	"narasi-ahli-be/app/module/articles"
	"narasi-ahli-be/app/module/chat"
	"narasi-ahli-be/app/module/cities"
	"narasi-ahli-be/app/module/custom_static_pages"
	"narasi-ahli-be/app/module/districts"
	"narasi-ahli-be/app/module/ebooks"
	"narasi-ahli-be/app/module/education_history"
	"narasi-ahli-be/app/module/feedbacks"
	"narasi-ahli-be/app/module/knowledge_base"
	"narasi-ahli-be/app/module/magazine_files"
	"narasi-ahli-be/app/module/magazines"
	"narasi-ahli-be/app/module/master_menus"
	"narasi-ahli-be/app/module/master_modules"
	"narasi-ahli-be/app/module/notifications"
	"narasi-ahli-be/app/module/provinces"
	"narasi-ahli-be/app/module/research_journals"
	"narasi-ahli-be/app/module/subscription"
	"narasi-ahli-be/app/module/user_agent"
	"narasi-ahli-be/app/module/user_levels"
	"narasi-ahli-be/app/module/user_role_accesses"
	"narasi-ahli-be/app/module/user_role_level_details"
	"narasi-ahli-be/app/module/user_roles"
	"narasi-ahli-be/app/module/users"
	"narasi-ahli-be/app/module/work_history"
	"narasi-ahli-be/app/router"
	"narasi-ahli-be/config/config"
	"narasi-ahli-be/config/logger"
	"narasi-ahli-be/config/webserver"
	"time"

	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),

		// provide modules
		activity_logs.NewActivityLogsModule,
		advertisement.NewAdvertisementModule,
		ai_chat.NewAIChatModule,
		knowledge_base.NewKnowledgeBaseModule,
		article_categories.NewArticleCategoriesModule,
		article_category_details.NewArticleCategoryDetailsModule,
		article_files.NewArticleFilesModule,
		article_approvals.NewArticleApprovalsModule,
		articles.NewArticlesModule,
		article_comments.NewArticleCommentsModule,
		chat.NewChatModule,
		cities.NewCitiesModule,
		custom_static_pages.NewCustomStaticPagesModule,
		districts.NewDistrictsModule,
		ebooks.NewEbooksModule,
		feedbacks.NewFeedbacksModule,
		magazines.NewMagazinesModule,
		magazine_files.NewMagazineFilesModule,
		master_menus.NewMasterMenusModule,
		master_modules.NewMasterModulesModule,
		provinces.NewProvincesModule,
		subscription.NewSubscriptionModule,
		user_levels.NewUserLevelsModule,
		user_roles.NewUserRolesModule,
		user_role_accesses.NewUserRoleAccessesModule,
		users.NewUsersModule,
		user_role_level_details.NewUserRoleLevelDetailsModule,
		education_history.NewEducationHistoryModule,
		work_history.NewWorkHistoryModule,
		research_journals.NewResearchJournalsModule,
		ai_chat_files.NewAiChatFilesModule,
		notifications.NewNotificationsModule,
		agent.NewAgentModule,
		user_agent.NewUserAgentModule,



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

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

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

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