---
paths: src/modules/**/stores/**/*.js
---

# Frontend Store Rules

## Factory Pattern (MANDATORY)
All stores MUST use shared factories:

```javascript
// Correct - use factory
import { createAuthStore } from '@shared/frontend/stores/auth';
export const useAuthStore = createAuthStore(apiService);

// Correct - use factory
import { createCompaniesStore } from '@shared/frontend/stores/companies';
export const useCompaniesStore = createCompaniesStore(apiService, useAuthStore);

// WRONG - custom implementation
export const useCompaniesStore = defineStore('companies', () => { ... });
```

## Available Factories
- `createAuthStore(apiService)` - Authentication state
- `createCompaniesStore(apiService, useAuthStore)` - Company selection
- `createAccountingPeriodStore(apiService, useAuthStore, useCompanyStore)` - Period selection

## LocalStorage Keys (RESERVED)
- `access_token`, `refresh_token`, `user` - Auth
- `selected_company_id` - Company selection
- `selected_period_id` - Period selection
