feat: Add shared components, refactor stores, improve data-entry workflow
Shared Components: - Add CompanySelector.vue and PeriodSelector.vue components - Add AppHeader.vue and SlideMenu.vue layout components - Add shared stores factories (companies.js, accountingPeriod.js) - Add shared routes factories (companies.py, calendar.py) - Add shared models (company.py, calendar.py) - Add shared layout styles (header.css, navigation.css) Data Entry App: - Update CLAUDE.md with prod/test server documentation - Improve nomenclature sync service with better error handling - Update receipts router and CRUD operations - Add company/period stores using shared factories - Update App.vue layout with shared components - Fix OCRUploadZone file handling Reports App: - Refactor stores to use shared factories - Update App.vue to use shared layout components Infrastructure: - Replace start-data-entry.sh with separate dev/test scripts - Add .claude/rules for authentication, backend patterns, etc. - Add implementation plan for OCR receipt improvements - Clean up old documentation files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
17
.claude/rules/authentication.md
Normal file
17
.claude/rules/authentication.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Authentication Rules
|
||||
|
||||
## JWT Token Structure (IMMUTABLE)
|
||||
All apps use the same token payload:
|
||||
- `username`, `user_id`, `companies[]`, `permissions[]`, `exp`, `iat`, `type`
|
||||
|
||||
## Backend Rules
|
||||
- Use `AuthenticationMiddleware` from `shared/auth/middleware.py`
|
||||
- Use `get_current_user` dependency from `shared/auth/dependencies.py`
|
||||
- Never implement custom auth logic in routers
|
||||
- Rate limiting: 5 req/5 min for /auth/* paths
|
||||
|
||||
## Frontend Rules
|
||||
- Use `createAuthStore(apiService)` factory from `shared/frontend/stores/auth.js`
|
||||
- Use `LoginView.vue` component from `shared/frontend/components/`
|
||||
- Store tokens in localStorage: `access_token`, `refresh_token`, `user`
|
||||
- Initialize auth on app startup with `initializeAuth()`
|
||||
44
.claude/rules/backend-patterns.md
Normal file
44
.claude/rules/backend-patterns.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
paths: {reports-app,data-entry-app}/backend/**/*.py
|
||||
---
|
||||
|
||||
# Backend Patterns
|
||||
|
||||
## Router Factory Pattern
|
||||
Use shared router factories instead of custom implementations:
|
||||
```python
|
||||
from shared.routes.companies import create_companies_router
|
||||
from shared.routes.calendar import create_calendar_router
|
||||
|
||||
companies_router = create_companies_router(oracle_pool, cache_decorator=cached)
|
||||
app.include_router(companies_router, prefix="/api/companies")
|
||||
```
|
||||
|
||||
## Database Queries
|
||||
- All queries use parameterized Oracle queries (no SQL injection)
|
||||
- Schema lookup: `SELECT SCHEMA FROM CONTAFIN_ORACLE.V_NOM_FIRME`
|
||||
- Company access: Join V_NOM_FIRME with VDEF_UTIL_FIRME
|
||||
|
||||
## Caching (reports-app)
|
||||
- Use `@cached` decorator from `app/cache/decorators`
|
||||
- Place logic in services, not routers
|
||||
- Cache schema lookups (24h TTL)
|
||||
- Cache user data (10-30 min TTL)
|
||||
|
||||
## Error Handling
|
||||
```python
|
||||
try:
|
||||
# Business logic
|
||||
except HTTPException:
|
||||
raise # Re-raise HTTP exceptions
|
||||
except Exception as e:
|
||||
logger.error(...)
|
||||
raise HTTPException(500, "Internal error")
|
||||
```
|
||||
|
||||
## Oracle Pool Pattern
|
||||
```python
|
||||
async with oracle_pool.get_connection() as connection:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(query, params)
|
||||
```
|
||||
19
.claude/rules/company-period.md
Normal file
19
.claude/rules/company-period.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Company & Period Selection Rules
|
||||
|
||||
## Store Factories (MANDATORY)
|
||||
- Companies: Use `createCompaniesStore()` from `shared/frontend/stores/companies.js`
|
||||
- Periods: Use `createAccountingPeriodStore()` from `shared/frontend/stores/accountingPeriod.js`
|
||||
- Never implement custom company/period stores
|
||||
|
||||
## Components
|
||||
- Use `CompanySelector.vue` from `shared/frontend/components/`
|
||||
- Use `PeriodSelector.vue` from `shared/frontend/components/`
|
||||
- Use `AppHeader.vue` layout from `shared/frontend/components/layout/`
|
||||
|
||||
## Backend Endpoints
|
||||
- Use `create_companies_router()` factory from `shared/routes/companies.py`
|
||||
- Use `create_calendar_router()` factory from `shared/routes/calendar.py`
|
||||
|
||||
## Company Access Validation (2-step)
|
||||
1. Check `current_user.companies` (fast, from JWT)
|
||||
2. Validate against Oracle DB (authoritative)
|
||||
26
.claude/rules/css-design-system.md
Normal file
26
.claude/rules/css-design-system.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
paths: {reports-app,data-entry-app}/frontend/**/*.{vue,css}
|
||||
---
|
||||
|
||||
# CSS Design System Rules
|
||||
|
||||
## Documentation (READ FIRST)
|
||||
- **Quick Start**: `docs/ONBOARDING_CSS.md` (5 min read)
|
||||
- **Complete Patterns**: `docs/CSS_PATTERNS.md` (cards, forms, buttons, tables, etc.)
|
||||
- **Design Tokens**: `docs/DESIGN_TOKENS.md` (colors, spacing, typography variables)
|
||||
|
||||
## Core Principles
|
||||
- Use CSS variables from design tokens, NEVER hardcoded values
|
||||
- Check `CSS_PATTERNS.md` BEFORE writing any CSS
|
||||
- Import shared styles from `shared/frontend/styles/`
|
||||
|
||||
## Shared Styles to Import
|
||||
- Login: `@import 'shared/frontend/styles/login.css'`
|
||||
- Header: `@import 'shared/frontend/styles/layout/header.css'`
|
||||
- Navigation: `@import 'shared/frontend/styles/layout/navigation.css'`
|
||||
|
||||
## NEVER
|
||||
- Use `:deep()` for PrimeVue overrides (use `vendor/` files)
|
||||
- Duplicate patterns that exist in CSS_PATTERNS.md
|
||||
- Use hardcoded colors like `#2563eb` (use `var(--color-primary)`)
|
||||
- Create scoped CSS for patterns that already exist in shared files
|
||||
31
.claude/rules/frontend-stores.md
Normal file
31
.claude/rules/frontend-stores.md
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
paths: {reports-app,data-entry-app}/frontend/src/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
|
||||
Reference in New Issue
Block a user