
Summary
Key points of this document
- Repository split or monorepo? There are three decision axes.
- We will show the actual configuration.
- We maintain type sharing and boundary discipline with minimal rules.
Overview
The flares.jp website and LMS manage the React Router 7 frontend and Laravel 12 API in a single monorepo using pnpm workspace. We will organize the reasons for consolidating into one repository, the decision criteria, the actual configuration, and the advantages and caveats observed during operation.
Repository split or monorepo? There are three decision axes.
In discussions about repository strategy, it's often simplified to "polyrepo for microservices, monorepo for tight coupling," but the actual decision axes are a bit more specific. We made our decision based on the following three points.
The first is the simultaneity of changes. When adding features to the LMS, API endpoint additions and frontend screen implementations almost always occur as a set. In a polyrepo, this change would be split into two pull requests, requiring coordination of review and merge order. With a monorepo, you can review whether "API and UI changes are consistent" in a single PR.
The second is team size. If the team is divided into service units with dozens of members, repository boundaries should align with team boundaries. However, in a small team structure that oversees the entire scope, the management cost of splitting repositories outweighs the benefits.
The third is compatibility with AI agents. When delegating tasks to AI agents like Claude Code, the context an agent can refer to is basically limited to one repository. If API specifications and frontend implementations are in the same repository, the agent can complete cross-cutting tasks like "if the API response type changes, fix the corresponding frontend component" in a single session.
We will show the actual configuration.
The flares.jp2026 repository places the Laravel 12 + PHP 8.2 backend in apps/api, the React Router 7 + Vite 7 frontend in sites/flares.jp, and docker-compose.yml, pnpm-workspace.yaml, and AI agent settings in the root.
The pnpm workspace configuration is minimal. We declare apps/* in pnpm-workspace.yaml and define only global scripts in the root package.json. The Laravel side is managed by Composer and thus outside pnpm's management, but we also place a package.json in apps/api so that development server startup and test execution can be uniformly called via pnpm scripts.
The consistency of "development starts with pnpm dev in any app" is important not only for humans but also for AI agents. This is because when an agent is instructed to "run tests," it can find the correct command without hesitation.
We maintain type sharing and boundary discipline with minimal rules.
The biggest temptation of a monorepo is that "anything can be shared." We limit sharing to two things: type definitions and API clients.
API response types are defined as TypeScript interfaces and used in frontend loader functions. The consistency between Laravel's API resources and type definitions is ensured by Playwright's E2E tests and API response schema validation. The important decision here is not to build an automatic type generation pipeline between PHP and TypeScript from the start. At the stage where the number of endpoints is small, the maintenance cost of a generation pipeline outweighs the cost of manual corrections. We consider around 50 endpoints to be a guideline for introduction.
The fewer the rules, the more they are followed.
- Do not directly import code from
apps/apiintosites/flares.jp. - Extract shared items into
packagesdirectly under the root (only when necessary).
The development environment is set up as "API in container, frontend on host."
The development environment is unified with Docker Compose. We start MySQL, the Laravel application container, and Mailpit for email verification if needed, while the frontend Vite development server runs directly on the host.
The reason for not putting the frontend into a container is the speed of HMR and the stability of file watching. Docker on macOS has overhead for filesystem bridging, and frontend development including node_modules inside a container noticeably degrades perceived performance.
Maintaining a state where new members (or new AI agent sessions) can start development with just two commands, docker compose up and pnpm dev, is more important than the choice of configuration.
Even with one repository, deployments are independent.
Frontend changes do not need to trigger an API redeployment. In CI, we use path filters: changes to sites/flares.jp only run frontend builds and tests, changes to apps/api only run Laravel tests. Changes spanning both will run both.
This setup largely avoids the typical complaint that "monorepo = slow CI."
We will also share caveats observed during operation.
It's not all good. Measures are needed for git log readability, update management of two package managers, and repository bloat.
In particular, neglecting to exclude node_modules and build artifacts can become noise when AI agents read the context. We recommend explicitly documenting exclusion settings for agents, not just in .gitignore.
- If commit message conventions (explicitly stating
web/apiin the scope) are not followed, it becomes difficult to track history. - Manage the update cycles of pnpm and Composer, and ensure automation tools like Renovate support both.
- Explicitly document "directories that should not be read" for agents.
Repository strategy is chosen based on change patterns and team structure.
The decision to consolidate frontend and API into one repository is rational if three conditions are met: "high simultaneity of changes," "small team overseeing the entire scope," and "desire to delegate cross-cutting tasks to AI agents."
Conversely, in organizations where teams are divided by service units, or in products where frontend and API release cycles differ significantly, a polyrepo would likely result in less friction. Repository strategy is not a trend; it should be chosen to match change patterns and team structure.


