Implement modular architecture with core services and Nostr integration
- Introduce a modular application structure with a new app configuration file to manage module settings and features. - Implement a dependency injection container for service management across modules. - Create a plugin manager to handle module registration, installation, and lifecycle management. - Develop a global event bus for inter-module communication, enhancing loose coupling between components. - Add core modules including base functionalities, Nostr feed, and PWA services, with support for dynamic loading and configuration. - Establish a Nostr client hub for managing WebSocket connections and event handling. - Enhance user experience with a responsive Nostr feed component, integrating admin announcements and community posts. - Refactor existing components to align with the new modular architecture, improving maintainability and scalability.
This commit is contained in:
parent
2d8215a35e
commit
519a9003d4
16 changed files with 2520 additions and 14 deletions
65
src/modules/base/index.ts
Normal file
65
src/modules/base/index.ts
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import type { App } from 'vue'
|
||||
import type { ModulePlugin } from '@/core/types'
|
||||
import { container, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import { relayHub } from './nostr/relay-hub'
|
||||
import { nostrclientHub } from './nostr/nostrclient-hub'
|
||||
|
||||
// Import auth services
|
||||
import { auth } from './auth/auth-service'
|
||||
|
||||
// Import PWA services
|
||||
import { pwaService } from './pwa/pwa-service'
|
||||
|
||||
/**
|
||||
* Base Module Plugin
|
||||
* Provides core infrastructure: Nostr, Auth, PWA, and UI components
|
||||
*/
|
||||
export const baseModule: ModulePlugin = {
|
||||
name: 'base',
|
||||
version: '1.0.0',
|
||||
|
||||
async install(_app: App, options?: any) {
|
||||
console.log('🔧 Installing base module...')
|
||||
|
||||
// Register core Nostr services
|
||||
container.provide(SERVICE_TOKENS.RELAY_HUB, relayHub)
|
||||
container.provide(SERVICE_TOKENS.NOSTR_CLIENT_HUB, nostrclientHub)
|
||||
|
||||
// Register auth service
|
||||
container.provide(SERVICE_TOKENS.AUTH_SERVICE, auth)
|
||||
|
||||
// Register PWA service
|
||||
container.provide('pwaService', pwaService)
|
||||
|
||||
// Initialize core services
|
||||
await relayHub.initialize(options?.nostr?.relays || [])
|
||||
await auth.initialize()
|
||||
|
||||
console.log('✅ Base module installed successfully')
|
||||
},
|
||||
|
||||
async uninstall() {
|
||||
console.log('🗑️ Uninstalling base module...')
|
||||
|
||||
// Cleanup Nostr connections
|
||||
relayHub.disconnect()
|
||||
nostrclientHub.disconnect?.()
|
||||
|
||||
console.log('✅ Base module uninstalled')
|
||||
},
|
||||
|
||||
services: {
|
||||
relayHub,
|
||||
nostrclientHub,
|
||||
auth,
|
||||
pwaService
|
||||
},
|
||||
|
||||
// No routes - base module is pure infrastructure
|
||||
routes: [],
|
||||
|
||||
// No UI components at module level - they'll be imported as needed
|
||||
components: {}
|
||||
}
|
||||
|
||||
export default baseModule
|
||||
Loading…
Add table
Add a link
Reference in a new issue