How mo574216/pm-eland-system works
Purpose and Delivery Shape
A metadata-driven enterprise architecture and project-knowledge platform: administrators define entity types, attributes, hierarchies, relationships, forms, and workflows as data rather than domain-specific code. The implemented baseline currently centers on identity, authentication, authorization, health, and a Persian-first application shell. Normative product design is in ai_context/; shared integration contracts are in contracts/openapi.yaml, contracts/permissions.yaml, and contracts/error-codes.yaml.
Runtime Entry Points
The backend is an async Python/FastAPI service entered through backend/app/main.py; its versioned HTTP API is assembled at backend/app/api/v1/router.py, with live/readiness probes in backend/app/api/health.py. The frontend is a React/TypeScript Vite SPA bootstrapped by frontend/src/main.tsx, rooted at frontend/src/app/App.tsx, and routed by frontend/src/app/router.tsx.
Backend Application Boundary
FastAPI routes are thin transport handlers: authentication and user endpoints in backend/app/api/v1/auth.py and backend/app/api/v1/users.py rely on request dependencies for bearer authentication and permission enforcement in backend/app/api/dependencies/authentication.py and backend/app/api/dependencies/authorization.py. API envelopes and centralized error handling establish the HTTP/error-code boundary in backend/app/api/envelopes.py and backend/app/api/error_handlers.py.
Identity and Authorization Flow
Identity state is modeled in backend/app/models/identity.py, accessed through backend/app/repositories/auth.py, and coordinated by backend/app/services/auth.py. Authentication implements bearer access tokens with rotating refresh sessions, while backend/app/services/authorization.py evaluates authorization policy. This layering isolates HTTP concerns from persistence and security logic. Security primitives, permission definitions, and request context reside in backend/app/core/security.py, backend/app/core/permissions.py, and backend/app/core/request_context.py.
Persistence and Schema Evolution
The service uses async SQLAlchemy database/session infrastructure in backend/app/core/database.py, consistent with the async-session ADR. PostgreSQL is the material datastore; Alembic migrations create extensions, identity schema, auth sessions, and audit-related identity evolution under backend/alembic/versions/0001_enable_postgresql_extensions.py, backend/alembic/versions/0002_identity_schema.py, and backend/alembic/versions/0004_identity_management_and_audit.py. Future metadata-defined domain capabilities should extend this generic platform model rather than introduce per-domain tables.
Frontend Composition and API Flow
The SPA configures global providers, query caching, RTL rendering, and theme in frontend/src/app/providers.tsx, frontend/src/app/queryClient.ts, and frontend/src/app/rtlCache.ts. frontend/src/api/client.ts is the backend integration boundary. Feature modules currently provide login and workspace-list surfaces at frontend/src/modules/auth/LoginPage.tsx and frontend/src/modules/workspaces/WorkspaceListPage.tsx; shared authenticated navigation/layout is frontend/src/layouts/AppShell.tsx.
Localization and Platform Infrastructure
The product is Persian-first/RTL for end users, with frontend translations in frontend/src/i18n/fa.ts and backend localization/text handling in backend/app/core/localization.py and backend/app/core/persian_text.py; identifiers, APIs, logs, and contracts remain English. Local development packages backend, frontend, PostgreSQL-adjacent service dependencies, and planned Redis/MinIO-compatible integrations via infrastructure/compose/docker-compose.dev.yml and container definitions in infrastructure/docker/backend.Dockerfile and infrastructure/docker/frontend.Dockerfile.
Main entry points: router.py Versioned API · docker-compose.dev.yml Development compose · LoginPage.tsx Login and workspaces · auth.py Auth and user routes
Components 22
React SPA
Persian-first client application.
- SPA bootstrap
frontend/src/main.tsx - App and router
frontend/src/app/router.tsx - Global providers
frontend/src/app/providers.tsx - Login and workspaces
frontend/src/modules/auth/LoginPage.tsx - Authenticated shell
frontend/src/layouts/AppShell.tsx - API client
frontend/src/api/client.ts - Persian UI text
frontend/src/i18n/fa.ts
FastAPI Service
Async identity and authorization baseline.
- FastAPI application
backend/app/main.py - Versioned API
backend/app/api/v1/router.py - Auth and user routes
backend/app/api/v1/auth.py - API error boundary · Standardizes HTTP responses and error codes.
backend/app/api/error_handlers.py - Access dependencies
backend/app/api/dependencies/authentication.py - Identity services · Issues rotating refresh sessions and evaluates policy.
backend/app/services/auth.py - Identity repository
backend/app/repositories/auth.py - Security and context
backend/app/core/security.py - Health probes
backend/app/api/health.py
Persistence
PostgreSQL-backed identity state and schema evolution.
- Identity model
backend/app/models/identity.py - PostgreSQL
backend/app/core/database.py - Identity migrations · Creates extensions, identity schema, sessions, and audit evolution.
backend/alembic/versions/0004_identity_management_and_audit.py
Product Contracts
Normative design and shared integration definitions.
- OpenAPI contract
contracts/openapi.yaml - Metadata platform design · Defines metadata-driven future domain capabilities.
Local Infrastructure
Containerized development environment.
- Development compose · Packages backend, frontend, PostgreSQL-adjacent dependencies, Redis, and MinIO plans.
infrastructure/compose/docker-compose.dev.yml
Connections 24
- SPA bootstrap → App and router: starts
- SPA bootstrap → Global providers: installs
- App and router → Login and workspaces: routes to
- Login and workspaces → Authenticated shell: uses after sign-in
- Global providers → Persian UI text: renders RTL text
- Login and workspaces → API client: calls
- API client → Versioned API: versioned HTTP
- FastAPI application → Versioned API: mounts
- FastAPI application → Health probes: exposes
- Versioned API → Auth and user routes: dispatches
- Auth and user routes → Access dependencies: enforces
- Auth and user routes → Identity services: delegates
- Versioned API → API error boundary: uses
- Access dependencies → Security and context: validates tokens
- Access dependencies → Identity services: checks policy
- Identity services → Identity repository: coordinates
- Identity repository → Identity model: loads and persists
- Identity model → PostgreSQL: stored in
- Identity migrations → PostgreSQL: evolves schema
- OpenAPI contract → Versioned API: defines API
- Metadata platform design → Identity model: guides platform extension
- Development compose → FastAPI application: runs backend
- Development compose → SPA bootstrap: runs frontend
- Development compose → PostgreSQL: provisions dependencies