# ๐Ÿ“ Project Structure ## Current Development Structure ``` rxminder/ โ”œโ”€โ”€ ๐Ÿ“„ README.md # Main project documentation โ”œโ”€โ”€ ๐Ÿ“ฆ package.json # Dependencies and scripts โ”œโ”€โ”€ โš™๏ธ vite.config.ts # Build configuration โ”œโ”€โ”€ ๐Ÿ“ tsconfig.json # TypeScript configuration โ”œโ”€โ”€ ๐ŸŽจ index.html # Generated entry point โ”œโ”€โ”€ ๐ŸŽจ index.html.template # Template for HTML generation โ”œโ”€โ”€ ๐Ÿ”’ .env.example # Environment template โ”œโ”€โ”€ ๐Ÿ“Š metadata.json # Project metadata โ”œโ”€โ”€ ๐Ÿ–ผ๏ธ banner.jpeg # Project banner image โ”œโ”€โ”€ ๐Ÿš€ index.tsx # React application entry point โ”œโ”€โ”€ ๐ŸŽฏ App.tsx # Main React component โ”œโ”€โ”€ ๐Ÿ“‹ types.ts # Global type definitions โ”‚ โ”œโ”€โ”€ ๐Ÿ“ components/ # React components (organized by feature) โ”‚ โ”œโ”€โ”€ ๐Ÿ“ README.md # Component architecture docs โ”‚ โ”œโ”€โ”€ ๐Ÿ“ medication/ # Medication-related components โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ’Š AddMedicationModal.tsx โ”‚ โ”‚ โ”œโ”€โ”€ โœ๏ธ EditMedicationModal.tsx โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“‹ ManageMedicationsModal.tsx โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿท๏ธ DoseCard.tsx โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Feature exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ auth/ # Authentication components โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ” AuthPage.tsx # Login/register interface โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ‘ค AvatarDropdown.tsx # User menu โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”‘ ChangePasswordModal.tsx โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Feature exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ admin/ # Admin interface components โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ‘‘ AdminInterface.tsx # User management โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Feature exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ modals/ # Modal components โ”‚ โ”‚ โ”œโ”€โ”€ โš™๏ธ AccountModal.tsx # User settings โ”‚ โ”‚ โ”œโ”€โ”€ โž• AddReminderModal.tsx # Add reminders โ”‚ โ”‚ โ”œโ”€โ”€ โœ๏ธ EditReminderModal.tsx โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“š HistoryModal.tsx # Medication history โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“‹ ManageRemindersModal.tsx โ”‚ โ”‚ โ”œโ”€โ”€ ๐ŸŽฏ OnboardingModal.tsx # New user setup โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“Š StatsModal.tsx # Analytics dashboard โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Feature exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ ui/ # Reusable UI components โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“Š BarChart.tsx # Data visualization โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”” ReminderCard.tsx # Reminder display โ”‚ โ”‚ โ”œโ”€โ”€ ๐ŸŽจ ThemeSwitcher.tsx # Dark/light theme โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Feature exports โ”‚ โ””โ”€โ”€ ๐Ÿ“ icons/ # Icon components โ”‚ โ””โ”€โ”€ ๐ŸŽจ Icons.tsx # All icon definitions โ”‚ โ”œโ”€โ”€ ๐Ÿ“ services/ # Business logic & APIs โ”‚ โ”œโ”€โ”€ ๐Ÿ—„๏ธ database/ # Unified database service โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“‹ DatabaseService.ts # Main service with strategy pattern โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿงช MockDatabaseStrategy.ts # In-memory implementation โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿญ ProductionDatabaseStrategy.ts # CouchDB implementation โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ types.ts # Database interfaces โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ฆ index.ts # Public exports โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ README.md # Database service documentation โ”‚ โ”œโ”€โ”€ ๐Ÿ“ง logging/ # Centralized logging system โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“Š Logger.ts # Main logger implementation โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ฆ index.ts # Public exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ง email.ts # Email utilities โ”‚ โ”œโ”€โ”€ ๐Ÿ“ง mailgun.service.ts # Email delivery โ”‚ โ”œโ”€โ”€ ๐Ÿ“ง mailgun.config.ts # Email configuration โ”‚ โ”œโ”€โ”€ ๐ŸŒฑ database.seeder.ts # Data seeding โ”‚ โ”œโ”€โ”€ ๐Ÿ” oauth.ts # OAuth integration โ”‚ โ””โ”€โ”€ ๐Ÿ“ auth/ # Authentication services โ”‚ โ”œโ”€โ”€ ๐Ÿ” auth.service.ts # Core auth logic โ”‚ โ”œโ”€โ”€ ๐Ÿ“ auth.types.ts # Auth type definitions โ”‚ โ”œโ”€โ”€ ๐Ÿ“‹ auth.constants.ts # Auth constants โ”‚ โ”œโ”€โ”€ โš ๏ธ auth.error.ts # Error handling โ”‚ โ”œโ”€โ”€ ๐Ÿ›ก๏ธ auth.middleware.ts # Middleware โ”‚ โ”œโ”€โ”€ โœ‰๏ธ emailVerification.service.ts โ”‚ โ”œโ”€โ”€ ๐Ÿ“ templates/ # Email templates โ”‚ โ”‚ โ””โ”€โ”€ โœ‰๏ธ verification.email.ts โ”‚ โ””โ”€โ”€ ๐Ÿ“ __tests__/ # Unit tests โ”‚ โ”œโ”€โ”€ ๐Ÿงช auth.integration.test.ts โ”‚ โ””โ”€โ”€ ๐Ÿงช emailVerification.test.ts โ”‚ โ”œโ”€โ”€ ๐Ÿ“ config/ # Configuration management โ”‚ โ””โ”€โ”€ โš™๏ธ unified.config.ts # Centralized configuration with validation โ”‚ โ”œโ”€โ”€ ๐Ÿ“ contexts/ # React context providers โ”‚ โ””โ”€โ”€ ๐Ÿ‘ค UserContext.tsx # User state management โ”‚ โ”œโ”€โ”€ ๐Ÿ“ hooks/ # Custom React hooks โ”‚ โ”œโ”€โ”€ ๐Ÿ’พ useLocalStorage.ts # Persistent storage โ”‚ โ”œโ”€โ”€ โš™๏ธ useSettings.ts # User preferences โ”‚ โ”œโ”€โ”€ ๐ŸŽจ useTheme.ts # Theme management โ”‚ โ””โ”€โ”€ ๐Ÿ‘ค useUserData.ts # User data management โ”‚ โ”œโ”€โ”€ ๐Ÿ“ utils/ # Utility functions โ”‚ โ””โ”€โ”€ โฐ schedule.ts # Reminder scheduling โ”‚ โ”œโ”€โ”€ ๐Ÿ“ types/ # TypeScript type definitions โ”‚ โ””โ”€โ”€ ๐Ÿ“ index.ts # Global type exports โ”‚ โ”œโ”€โ”€ ๐Ÿ“ scripts/ # Development and build scripts โ”‚ โ”œโ”€โ”€ ๐Ÿ”ง setup.sh # Development setup โ”‚ โ”œโ”€โ”€ ๐ŸŽจ process-html.sh # HTML template processing โ”‚ โ”œโ”€โ”€ ๐Ÿงน setup-pre-commit.sh # Git hooks setup โ”‚ โ””โ”€โ”€ ๐ŸŒฑ seed-production.js # Database seeding โ”‚ โ”œโ”€โ”€ ๐Ÿ“ tests/ # Testing infrastructure โ”‚ โ”œโ”€โ”€ ๐Ÿ“ README.md # Testing documentation โ”‚ โ”œโ”€โ”€ โš™๏ธ setup.ts # Jest configuration โ”‚ โ”œโ”€โ”€ ๐Ÿ“ integration/ # Integration tests โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿงช production.test.js # Production validation โ”‚ โ”œโ”€โ”€ ๐Ÿ“ manual/ # Manual testing scripts โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”ง admin-login-debug.js # Admin debugging โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”ง auth-db-debug.js # Auth debugging โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ”ง debug-email-validation.js # Email debugging โ”‚ โ””โ”€โ”€ ๐Ÿ“ e2e/ # End-to-end tests with Playwright โ”‚ โ”œโ”€โ”€ ๐Ÿ“ README.md # E2E testing documentation โ”‚ โ”œโ”€โ”€ ๐Ÿงช fixtures.ts # Custom test fixtures โ”‚ โ”œโ”€โ”€ ๐Ÿงช helpers.ts # Test utilities and data โ”‚ โ”œโ”€โ”€ ๐Ÿงช auth.spec.ts # Authentication flow tests โ”‚ โ”œโ”€โ”€ ๐Ÿงช medication.spec.ts # Medication management tests โ”‚ โ”œโ”€โ”€ ๐Ÿงช admin.spec.ts # Admin interface tests โ”‚ โ”œโ”€โ”€ ๐Ÿงช ui-navigation.spec.ts # UI and navigation tests โ”‚ โ””โ”€โ”€ ๐Ÿงช reminders.spec.ts # Reminder system tests โ”‚ โ”œโ”€โ”€ ๐Ÿ“ docs/ # Project documentation โ”‚ โ”œโ”€โ”€ ๐Ÿ“‹ README.md # Documentation index โ”‚ โ”œโ”€โ”€ ๐Ÿ“ architecture/ # Design & Architecture โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ—๏ธ PROJECT_STRUCTURE.md # This file โ”‚ โ”‚ โ””โ”€โ”€ ๐ŸŽฏ TEMPLATE_APPROACH.md # Configuration approach โ”‚ โ”œโ”€โ”€ ๐Ÿ“ setup/ # Setup & Configuration โ”‚ โ”‚ โ”œโ”€โ”€ โš™๏ธ COMPLETE_TEMPLATE_CONFIGURATION.md โ”‚ โ”‚ โ”œโ”€โ”€ โœ… SETUP_COMPLETE.md โ”‚ โ”‚ โ”œโ”€โ”€ ๐ŸŒ ENVIRONMENT_VARIABLES.md โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿท๏ธ APP_NAME_CONFIGURATION.md โ”‚ โ”œโ”€โ”€ ๐Ÿ“ development/ # Development Guides โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“– API.md # API documentation โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ—„๏ธ DATABASE.md # Database service docs โ”‚ โ”‚ โ”œโ”€โ”€ โœจ CODE_QUALITY.md # Quality standards โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”’ APPLICATION_SECURITY.md # Security practices โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ”„ SECURITY_CHANGES.md # Security updates โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿช PRE_COMMIT_HOOKS.md # Git hook configuration โ”‚ โ””โ”€โ”€ ๐Ÿ“ implementation/ # Current Status โ”‚ โ””โ”€โ”€ ๐Ÿ“Š IMPLEMENTATION_SUMMARY.md โ”‚ โ”œโ”€โ”€ ๐Ÿ“ coverage/ # Test coverage reports โ”œโ”€โ”€ ๐Ÿ“ dist/ # Production build output โ”œโ”€โ”€ ๐Ÿ“ node_modules/ # Dependencies โ”‚ โ””โ”€โ”€ ๐Ÿ“ Configuration Files # Development configuration โ”œโ”€โ”€ ๐Ÿ”ง .gitignore # Git ignore patterns โ”œโ”€โ”€ ๐ŸŽจ .prettierrc # Code formatting rules โ”œโ”€โ”€ โšก eslint.config.cjs # Linting configuration โ”œโ”€โ”€ ๐Ÿงช jest.config.json # Test configuration โ”œโ”€โ”€ ๐ŸŽญ playwright.config.ts # E2E test configuration โ”œโ”€โ”€ ๐Ÿ“ .markdownlint.json # Markdown linting โ”œโ”€โ”€ ๐Ÿ”’ .secretlintrc.json # Secret detection โ”œโ”€โ”€ โœ๏ธ .editorconfig # Editor consistency โ”œโ”€โ”€ ๐Ÿช .husky/ # Git hooks โ””โ”€โ”€ ๐Ÿ“„ Various other config files ``` ## Key Organizational Principles ### โœ… **Feature-Based Component Organization** Components are organized by functionality rather than by type: ``` components/ โ”œโ”€โ”€ medication/ # All medication-related UI โ”œโ”€โ”€ auth/ # Authentication components โ”œโ”€โ”€ admin/ # Admin interface โ”œโ”€โ”€ modals/ # Modal dialogs โ””โ”€โ”€ ui/ # Reusable UI components ``` **Benefits:** - Related functionality stays together - Easy to find and modify features - Clear boundaries between different parts of the app - Scalable as features grow ### โœ… **Service Layer Architecture** Services provide business logic separate from UI components: ``` services/ โ”œโ”€โ”€ database/ # Data persistence with strategy pattern โ”œโ”€โ”€ logging/ # Centralized logging system โ””โ”€โ”€ auth/ # Authentication and user management ``` **Benefits:** - Clear separation of concerns - Reusable business logic - Easy to test and mock - Strategy pattern allows flexible implementations ### โœ… **Configuration Management** Centralized configuration with environment-based templates: ``` config/ โ””โ”€โ”€ unified.config.ts # Single source of truth # Template approach index.html.template โ†’ index.html # Processed with environment variables .env.example โ†’ .env # User customization ``` **Benefits:** - No hardcoded configuration - Environment-specific settings - Type-safe configuration access - Clear separation of config and code ### โœ… **Testing Strategy** Comprehensive testing at multiple levels: ``` tests/ โ”œโ”€โ”€ integration/ # Service integration tests โ”œโ”€โ”€ manual/ # Debug scripts and manual testing โ””โ”€โ”€ e2e/ # Full application testing # Unit tests alongside code services/auth/__tests__/ # Co-located with services components/__tests__/ # Component-specific tests ``` **Benefits:** - Tests close to the code they test - Multiple testing strategies - Easy to run specific test suites - Clear separation of test types ### โœ… **Documentation Structure** Documentation organized by purpose and audience: ``` docs/ โ”œโ”€โ”€ architecture/ # System design and patterns โ”œโ”€โ”€ setup/ # Configuration and installation โ”œโ”€โ”€ development/ # Developer guides and APIs โ””โ”€โ”€ implementation/ # Current status and features ``` **Benefits:** - Easy navigation by role (developer, ops, etc.) - Clear separation of different doc types - Comprehensive coverage of all aspects - Living documentation that stays current ## ๐ŸŽฏ Development Workflow ### Local Development Setup 1. **Environment Configuration** ```bash cp .env.example .env # Copy template nano .env # Customize settings ``` 2. **Template Processing** ```bash bun run predev # Process HTML templates bun run dev # Start development server ``` 3. **Code Quality** ```bash bun run lint # Check code quality bun run format # Format code bun run type-check # TypeScript validation ``` ### Database Strategy Selection The application automatically selects the appropriate database strategy: - **Development**: Mock database (instant responses, no setup) - **Testing**: Mock database (isolated test data) - **Production**: CouchDB (persistent storage) ### Component Development 1. **Create feature-based components** in appropriate folders 2. **Export from index.ts** for clean imports 3. **Co-locate tests** with components when appropriate 4. **Use TypeScript** for type safety ### Service Development 1. **Implement business logic** in service layer 2. **Use dependency injection** for testability 3. **Follow strategy pattern** for flexibility 4. **Add comprehensive tests** for reliability ## ๐Ÿ“Š Metrics and Standards ### Code Organization - **Feature cohesion**: Related code stays together - **Clear boundaries**: Services, components, utilities clearly separated - **Consistent patterns**: Similar organization across features - **Scalable structure**: Easy to add new features without reorganization ### Development Experience - **Fast setup**: One command to get started - **Quick iteration**: Hot reloading and instant feedback - **Easy testing**: Multiple test strategies available - **Clear debugging**: Structured logging and debug tools ### Maintainability - **Self-documenting**: Clear folder structure and naming - **Consistent patterns**: Similar approaches across the codebase - **Easy refactoring**: Loose coupling between components - **Future-proof**: Architecture supports growth and changes ## ๐Ÿš€ Benefits ๐ŸŽฏ **Discoverability** - Logical structure makes files easy to find ๐Ÿ”ง **Maintainability** - Clear patterns make code easy to modify ๐Ÿงช **Testability** - Well-organized test structure and strategy ๐Ÿ“ˆ **Scalability** - Architecture supports feature growth ๐Ÿ‘ฅ **Team Collaboration** - Consistent patterns across the project ๐Ÿ›ก๏ธ **Reliability** - Strategy pattern provides flexibility and fallbacks โšก **Performance** - Optimized development and build processes ๐Ÿ“š **Documentation** - Comprehensive guides for all aspects This structure provides a solid foundation for continued development and future enhancements while maintaining code quality and developer productivity.