|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This is the platformOS documentation site, built on the platformOS platform itself. The site uses Liquid templates, GraphQL queries, and JavaScript/CSS for a static documentation experience. The documentation is stored as Liquid files in `app/views/pages/` and organized by topic. |
| 8 | + |
| 9 | +## Key Architecture |
| 10 | + |
| 11 | +### Application Structure |
| 12 | + |
| 13 | +- **app/**: Main platformOS application directory |
| 14 | + - **views/pages/**: 540+ documentation pages in Liquid format, organized by topic (developer-guide, best-practices, api-reference, etc.) |
| 15 | + - **views/layouts/**: Layout templates (application.liquid is the main layout) |
| 16 | + - **views/partials/**: Reusable components organized by feature area |
| 17 | + - **graphql/**: GraphQL query files for data fetching |
| 18 | + - **lib/**: Liquid library files (queries and commands) |
| 19 | + - **model_schemas/**: Data model definitions (YAML) |
| 20 | + - **assets/**: Compiled JS/CSS output (generated by webpack) |
| 21 | + - **config.yml**: platformOS configuration |
| 22 | + |
| 23 | +- **modules/**: platformOS modules with their own structure |
| 24 | + - **core/**: Core module with generators for scaffolding |
| 25 | + - **graphql/**: GraphQL documentation module |
| 26 | + - **openai/**: OpenAI integration module |
| 27 | + |
| 28 | +- **src/**: Source assets (pre-webpack) |
| 29 | + - **app.js**: Main JavaScript entry point (imports features lazily via webpack chunks) |
| 30 | + - **app.css**: Main CSS entry point (Tailwind + custom components) |
| 31 | + - **js/**: JavaScript modules (search, syntax highlighting, feedback, etc.) |
| 32 | + - **css/**: Custom CSS organized by layout/components |
| 33 | + |
| 34 | +### Build System |
| 35 | + |
| 36 | +The project uses Webpack with: |
| 37 | +- **esbuild-loader** for fast JS transpilation |
| 38 | +- **PostCSS + Tailwind CSS** for styling |
| 39 | +- **Mini CSS Extract Plugin** for CSS extraction |
| 40 | +- Code splitting with chunkhash for caching |
| 41 | +- Two entry points: `app` (main site) and `graphql` (GraphQL docs module) |
| 42 | + |
| 43 | +### platformOS Integration |
| 44 | + |
| 45 | +This is a platformOS application, meaning: |
| 46 | +- **pos-cli** is used for deployment and syncing |
| 47 | +- **Liquid templates** are the primary templating language |
| 48 | +- **GraphQL** is used for querying data |
| 49 | +- **Model schemas** (YAML) define data structures |
| 50 | +- Configuration in `.pos` file defines environments (local, staging, production) |
| 51 | + |
| 52 | +## Common Commands |
| 53 | + |
| 54 | +### Development |
| 55 | + |
| 56 | +```bash |
| 57 | +npm ci # Install dependencies (use ci for clean installs) |
| 58 | +npm start # Run webpack watch + pos-cli sync with livereload |
| 59 | +``` |
| 60 | + |
| 61 | +**Important**: `npm start` requires pos-cli to be installed globally and configured with proper credentials in `.pos` file. |
| 62 | + |
| 63 | +### Building |
| 64 | + |
| 65 | +```bash |
| 66 | +npm run build # Build production assets (webpack) and prepare inline CSS/JS |
| 67 | +npm run build:graphql # Generate GraphQL documentation from schema |
| 68 | +``` |
| 69 | + |
| 70 | +The build process: |
| 71 | +1. Cleans old assets (`prebuild`) |
| 72 | +2. Runs webpack in production mode |
| 73 | +3. Copies built assets to partials for inline inclusion (`postbuild`) |
| 74 | + |
| 75 | +### Testing |
| 76 | + |
| 77 | +```bash |
| 78 | +npm test # Run CodeceptJS end-to-end tests |
| 79 | +``` |
| 80 | + |
| 81 | +Tests use Puppeteer and are configured in `codecept.conf.js`. They require `MPKIT_URL` environment variable to be set. |
| 82 | + |
| 83 | +### Deployment |
| 84 | + |
| 85 | +```bash |
| 86 | +npm run deploy # Build assets and deploy to platformOS via pos-cli |
| 87 | +``` |
| 88 | + |
| 89 | +Deployment target depends on pos-cli configuration. Use `-e <environment>` flag with pos-cli for specific environments. |
| 90 | + |
| 91 | +## Development Workflow |
| 92 | + |
| 93 | +### Working with Documentation Pages |
| 94 | + |
| 95 | +Documentation pages are Liquid files in `app/views/pages/`. When creating new documentation: |
| 96 | + |
| 97 | +1. Check if a template exists in `app/views/pages/doc-templates/` that matches your content type |
| 98 | +2. Follow the existing directory structure (by feature area) |
| 99 | +3. Pages are automatically indexed for search via GraphQL queries |
| 100 | +4. Use frontmatter metadata for page configuration (title, converter, etc.) |
| 101 | + |
| 102 | +### Working with Assets |
| 103 | + |
| 104 | +1. **Edit source files** in `src/js/` or `src/css/` (never edit files in `app/assets/` directly) |
| 105 | +2. Run `npm start` for live reloading during development |
| 106 | +3. The build copies compiled assets to `app/views/partials/css/source/` and `app/views/partials/js/source/` for inline inclusion |
| 107 | + |
| 108 | +### Working with GraphQL |
| 109 | + |
| 110 | +- GraphQL queries are stored in `app/graphql/` as `.graphql` files |
| 111 | +- They can be invoked from Liquid templates using GraphQL tags |
| 112 | +- The `build:graphql` script generates documentation from the platformOS GraphQL schema |
| 113 | + |
| 114 | +### Working with Modules |
| 115 | + |
| 116 | +Modules are self-contained feature sets: |
| 117 | +- Each module has its own directory structure (similar to `app/`) |
| 118 | +- Core module includes Yeoman generators for scaffolding |
| 119 | +- Modules are versioned independently |
| 120 | + |
| 121 | +## Style Guide |
| 122 | + |
| 123 | +The project uses: |
| 124 | +- **Tailwind CSS** with custom theme configuration in `tailwind.config.js` |
| 125 | +- Custom platformOS design tokens (pos-blue, pos-darkblue, etc.) |
| 126 | +- **Gotham** font family |
| 127 | +- ESLint for JavaScript (`.eslintrc.json`) |
| 128 | +- Editor config (`.editorconfig`) |
| 129 | + |
| 130 | +## GraphQL Documentation Generation |
| 131 | + |
| 132 | +The GraphQL docs are auto-generated from the platformOS schema: |
| 133 | + |
| 134 | +1. Script fetches the latest schema from the platform |
| 135 | +2. `@platformos/graphql-docs-markdown` converts schema to Liquid pages |
| 136 | +3. Pages are generated in `modules/graphql/public/views/pages/api-reference/graphql/` |
| 137 | +4. Navigation is updated in `app/views/partials/shared/nav/graphql-navigation.liquid` |
| 138 | + |
| 139 | +## Testing Architecture |
| 140 | + |
| 141 | +CodeceptJS tests in `tests/codecept/`: |
| 142 | +- Use Puppeteer for browser automation |
| 143 | +- Test key features: navigation, search, syntax highlighting, metadata, etc. |
| 144 | +- Custom locators via `data-test` attributes |
| 145 | +- Tests retry on failure (max 3 reruns) |
| 146 | +- Screenshots captured on failure |
| 147 | + |
| 148 | +## CI/CD |
| 149 | + |
| 150 | +GitHub Actions workflow (`.github/workflows/`): |
| 151 | +1. Deploy to staging on push to master |
| 152 | +2. Run tests against staging |
| 153 | +3. Deploy to production if tests pass |
| 154 | + |
| 155 | +The workflow uses secrets for MPKIT_URL, MPKIT_EMAIL, and MPKIT_TOKEN. |
| 156 | + |
| 157 | +## Important Files |
| 158 | + |
| 159 | +- **package.json**: Defines all npm scripts and dependencies |
| 160 | +- **.pos**: Environment configuration for pos-cli (contains tokens) |
| 161 | +- **webpack.config.js**: Asset bundling configuration |
| 162 | +- **tailwind.config.js**: Design system configuration |
| 163 | +- **app/config.yml**: platformOS application configuration |
| 164 | +- **codecept.conf.js**: Test suite configuration |
| 165 | + |
| 166 | +## Liquid Conventions |
| 167 | + |
| 168 | +- Use `{%- render -%}` for partials to control whitespace |
| 169 | +- Use `{% include %}` when you need to pass context variables |
| 170 | +- GraphQL queries are executed with `{% graphql %}` tag |
| 171 | +- Forms are rendered with `{% include_form %}` |
| 172 | +- Layouts use `{% yield %}` for content injection |
0 commit comments