|
| 1 | +# HRM App File Structure Guide |
| 2 | + |
| 3 | +This document provides a high-level overview of the file and directory structure for the Heart Rate Monitor (HRM) application. Its purpose is to help developers, including AI assistants, quickly understand the codebase layout, locate relevant files, and adhere to established organizational conventions. |
| 4 | + |
| 5 | +## Top-Level Directories |
| 6 | + |
| 7 | +The project is organized into the following primary directories: |
| 8 | + |
| 9 | +- **`/app`**: Contains the core Next.js application, including pages, layouts, and API routes. All frontend-facing code resides here. |
| 10 | + |
| 11 | +- **`/components`**: Houses reusable React components that are used across the application. This includes both small, atomic components and larger, composite ones. |
| 12 | + |
| 13 | +- **`/constants`**: Stores application-wide constant values, such as default settings, magic numbers, or string literals that are used in multiple places. |
| 14 | + |
| 15 | +- **`/context`**: Includes React Context providers that manage global state for features like WebSockets, user settings, and error handling. |
| 16 | + |
| 17 | +- **`/docs`**: Contains project documentation, including this file, the component inventory, and other guides to help developers understand the codebase. |
| 18 | + |
| 19 | +- **`/hooks`**: Home to custom React hooks that encapsulate reusable logic, such as interacting with browser APIs (e.g., Bluetooth, `localStorage`), managing side effects, or handling complex state. |
| 20 | + |
| 21 | +- **`/lib`**: A directory for libraries and configurations that are foundational to the application. This includes the MUI theme, validation schemas, and NextAuth configuration. |
| 22 | + |
| 23 | +- **`/logs`**: Stores log files generated by the application, such as server logs or Spotify token persistence data. This directory is excluded from version control. |
| 24 | + |
| 25 | +- **`/public`**: Contains static assets that are served directly by the web server, such as images, fonts, and web workers. |
| 26 | + |
| 27 | +- **`/scripts`**: A collection of utility scripts for development and deployment tasks, such as database seeding, environment setup, and running tests. |
| 28 | + |
| 29 | +- **`/services`**: Holds the backend business logic for the application. This includes services for managing the Tabata timer, polling the Spotify API, and handling real-time data. |
| 30 | + |
| 31 | +- **`/tests`**: Contains all tests for the application, subdivided into `unit` (Jest) and `playwright` (E2E and visual regression) directories. |
| 32 | + |
| 33 | +- **`/types`**: Home to shared TypeScript type definitions and interfaces that are used across both the frontend and backend. |
| 34 | + |
| 35 | +- **`/utils`**: A collection of helper functions and utility modules that provide common, reusable functionality, such as date formatting, URL manipulation, and logging. |
| 36 | + |
| 37 | +## Key Files |
| 38 | + |
| 39 | +- **`server.ts`**: The entry point for the custom Express server that manages the WebSocket connections and handles some API routes. |
| 40 | + |
| 41 | +- **`next.config.js`**: The configuration file for the Next.js framework. |
| 42 | + |
| 43 | +- **`docker-compose.yml`**: Defines the services, networks, and volumes for the Docker-based development environment. |
| 44 | + |
| 45 | +- **`ecosystem.config.cjs`**: The configuration file for the PM2 process manager, used for running the application in production. |
| 46 | + |
| 47 | +- **`playwright.config.ts`**: The configuration file for the Playwright test runner. |
| 48 | + |
| 49 | +- **`jest.config.cjs`**: The configuration file for the Jest test runner. |
0 commit comments