# Source Code Structure

This directory contains the organized source code for the Gooner Training Academy application, structured by feature and responsibility.

## 📁 Directory Organization

### `/core` - Core Game Engine
- **`game.js`** - Main game logic, state management, and flow control
- **`gameModeManager.js`** - Game mode selection and scenario management
- **`main.js`** - Electron main process (desktop application entry point)
- **`preload.js`** - Electron preload script for secure IPC communication

### `/features` - Feature Modules
Organized by functional area, each feature is self-contained:

#### `/features/webcam` - Photography System
- **`webcamManager.js`** - Camera access, photo capture, progress tracking, and photo galleries

#### `/features/tasks` - Task Management
- **`interactiveTaskManager.js`** - Task execution, photography integration, and scenario handling


#### `/features/audio` - Audio System
- **`audioManager.js`** - Background music, sound effects, and audio controls

#### `/features/images` - Image Management
- **`popupImageManager.js`** - Consequence image popups and display management
- **`image-discovery-fix.js`** - Image loading and scanning utilities

#### `/features/ui` - User Interface
- **`flashMessageManager.js`** - Motivational flash messages and UI feedback

### `/data` - Game Data & Configuration
- **`gameData.js`** - Task definitions, game content, and configuration data

### `/styles` - CSS Stylesheets
- **`styles.css`** - Main application styles
- **`styles-dark-edgy.css`** - Dark theme variant
- **`styles-gaming.css`** - Gaming theme variant
- **`styles-original-backup.css`** - Original styles backup

### `/utils` - Utility Functions
- **`desktop-file-manager.js`** - File system operations and desktop integration

## 🎯 Design Principles

### Feature-Based Organization
- Each feature directory is self-contained
- Clear separation of concerns
- Easy to locate and modify specific functionality

### Core vs Features
- **Core**: Essential game engine and platform code
- **Features**: Modular functionality that can be developed independently

### Data Separation
- Game content separated from logic
- Styles organized by theme
- Configuration centralized

## 🔄 Dependencies

### Inter-Feature Communication
Features communicate through:
- Global event system
- Shared game state (managed by core)
- Well-defined APIs

### Loading Order
Scripts are loaded in dependency order in `index.html`:
1. Data layer (`gameData.js`)
2. UI components (`flashMessageManager.js`, etc.)
3. Feature modules (tasks, audio, images, webcam)
4. Core game engine (`game.js`)

## 🚀 Benefits

- **Maintainability**: Easy to find and modify specific features
- **Scalability**: New features can be added without affecting existing code
- **Testing**: Features can be tested in isolation
- **Collaboration**: Team members can work on different features simultaneously
- **Debugging**: Issues are easier to locate and fix

## 📝 Adding New Features

1. Create a new directory under `/features/[feature-name]`
2. Add your feature files to the directory
3. Update `index.html` to include your scripts in the correct order
4. Document your feature in this README
5. Ensure proper error handling and cleanup

## 🔧 Build Process

The build process includes all `src/` files thanks to the updated `package.json` configuration. No additional build steps are required for the new structure.