Context: You are responsible for the
apps/portal-app. You prioritize type safety, modular feature-based architecture, and efficient state management.
- Framework: React + Vite (SPA).
- Primary Language: Strict TypeScript.
- Entry Point: Always check
src/main.tsxandsrc/App.tsxfor core providers.
Follow these rules strictly when generating code:
- Location:
src/features/ - Rule: Group components, hooks, and types by feature (e.g.,
src/features/auth/). Avoid flatcomponents/folders for business logic.
-
App-Specific Logic: Place in
src/lib/. -
Cross-App Shared Logic: Place in the monorepo root
./libs/typescript/.- Note: If suggesting a utility that could benefit other apps, always propose moving it to the root lib.
- Location:
src/store/ - Preference: [Insert Store Name, e.g., Zustand or Redux] is used for global state. Use local
useStatefor UI-only state.
- Location:
src/routes
- Requirement: - Use .env based on .env.example for auth and other environment settings. Any new variable in
.env(based on.env.example) must be mirrored insrc/vite-env.d.ts. - Validation: Prefer using a validation schema (like Zod) for
process.envto prevent runtime crashes.
Adhere strictly to these libraries; do not introduce alternatives.
-
Styling: Tailwind CSS. Use utility classes for layout. Avoid inline styles or CSS modules.
-
icons: Use
@mui/icons-material v7+orlucide-react -
Component Library: Material UI (MUI) v7+.
- Use MUI components for complex inputs, tables, and modals.
- Customize MUI components using the
sxprop or Tailwind viaslotProps.
-
Routing: React Router v7+. Use Data APIs (createBrowserRouter) where applicable.
-
State Management: Redux Toolkit (RTK).
- Use
createSlicefor logic. - Use
createApi(RTK Query) for all backend data fetching. - Access state via typed hooks:
useAppSelectoranduseAppDispatch.
- Use
-
Auth: Keycloak via
keycloak-js. -
Backend: .NET 10 Web API (located in
/services/portal/src/Offgrid.Portal.Api).
- Docker: Local development uses
compose.yamland a multi-stageDockerfile. - Networking: In Docker, the React app communicates with the .NET service via the internal container name (e.g.,
http://portal-api:7001).
Consult these files for deeper context before making architectural changes:
- Architecture:
./docs/portal/design/version-1/README.md - API Docs:
./services/portal/README.md - Project Docs:
./apps/portal-app/README.md
- Imports: Always use absolute paths if configured (e.g.,
@/features/...) rather than relative paths (../../). - Styling: Tailwind and Material UI (MUI) v7+
- Feedback: If a requested feature contradicts the
./docs/portal/design docs, flag the discrepancy. - When generating API calls, assume the .NET 10 backend follows REST standards.
- Always check
src/vite-env.d.tsbefore suggestingprocess.envusage.