# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working in this repository.

## Repository layout

This repo is a multi-app workspace with the React frontend as the main active surface:

- `infogenie-frontend/` — React 18 SPA built with Create React App. This is the primary app.
- `infogenie-backend-java/` — Spring Boot 3.5 / Java 17 backend skeleton.
- `InfoGenie-go-backend/` — legacy/alternate backend directory; currently only contains a README.

The frontend mixes two layers:

- A React shell for navigation, auth, shared layout, and embedded views.
- A large set of static HTML/JS mini-apps under `public/` and the corresponding built copies under `build/`.

## Frontend architecture

Key React entry points:

- `src/index.js` bootstraps the app and explicitly unregisters service workers / clears caches to avoid stale assets.
- `src/App.js` owns the top-level layout, router, global toast container, particle effect, and auth provider.
- `src/contexts/UserContext.js` is the session source of truth. It hydrates from `localStorage`, calls the auth service, and exposes login/logout helpers.
- `src/utils/api.js` is the shared Axios layer. It injects the bearer token, handles 401 redirects, and defines the separate auth-center client.
- `src/config/env.js` resolves runtime API endpoints from `REACT_APP_*` env vars or the current origin.

The app is route-driven, with major pages for:

- home entry / section selection
- login + auth callback
- 60s API browser and item detail routes
- small games
- toolbox
- AI app launcher
- user profile and admin

### Config-driven content

Most catalog-like UI is data-driven rather than hard-coded in pages:

- `src/config/Api60sConfig.js` defines the 60s API categories, toolbox catalogs, and static page path mappings.
- `src/config/StaticPageConfig.js` defines AI app and small-game launch metadata.
- `src/utils/site60sVisibility.js` fetches the backend site visibility list and filters the 60s API catalog before rendering.

This means many UI changes are done by editing config objects, not component logic.

### Static page embedding pattern

Several pages open a full-screen embedded static page instead of rendering everything in React:

- AI apps use `FullscreenEmbed` with token injection.
- Toolbox items also launch through `FullscreenEmbed`.
- 60s API detail pages map `itemId` to a static HTML page path.

When changing any mini-app, check both the React catalog entry and the matching file path under `public/`.

## Backend architecture

`infogenie-backend-java/` is currently a minimal Spring Boot bootstrap:

- `src/main/java/.../InfogenieBackendJavaApplication.java` contains only the application entry point.
- `src/test/java/.../InfogenieBackendJavaApplicationTests.java` contains the default context load test.
- `src/main/resources/application.yaml` only sets the application name right now.

There is no REST controller layer in this Java module yet.

## Common commands

### Frontend (`infogenie-frontend/`)

```bash
npm install
npm start
npm run dev
npm run build
npm test
```

Single test file or pattern:

```bash
npm test -- --runInBand --watch=false src/path/to/test-file.test.js
npm test -- --runInBand --watch=false --testNamePattern="pattern"
```

There is no separate lint script in `package.json`; the project relies on CRA's built-in ESLint checks during `start`, `test`, and `build`.

### Java backend (`infogenie-backend-java/`)

```bash
mvn test
mvn spring-boot:run
mvn -Dtest=InfogenieBackendJavaApplicationTests test
```

## Environment variables

Frontend runtime config comes from:

- `REACT_APP_API_URL`
- `REACT_APP_AUTH_URL`
- `REACT_APP_AUTH_API_URL`
- `REACT_APP_DEBUG`

If these are unset, the frontend falls back to the current origin for the main API and built-in auth defaults for auth URLs.

## Practical notes

- The frontend auth flow depends on `localStorage` keys such as `token`, `user`, and `expiresAt`.
- 401 responses from the shared Axios client clear the session and redirect to `/login`.
- The 60s API list is filtered by backend visibility data, so a missing/failed visibility fetch intentionally fails open and shows all items.
- The home page is just a launcher for the main product areas; the detailed behavior lives in the section pages and config files.
