# Architecture

## Application Shape

Alya Paros is a local-first Next.js App Router application with public bilingual pages, a booking engine, and a secured administration area.

Primary layers:

- Presentation: route components, design system components, and localized page content.
- Domain: booking rules, pricing, state transitions, availability, holds, payment abstractions, iCal rules, and media rules.
- Data access: Drizzle ORM repositories and transactions.
- Integrations: email, image generation, iCal feeds, storage, and future analytics.
- Security: authentication, authorization, validation, rate limiting, audit logging, and upload controls.

## Rendering Strategy

Stable public marketing/content routes should be statically rendered where their content is not private and not availability-sensitive.

The following must stay dynamic and uncached or carefully revalidated:

- Availability searches.
- Booking quotes.
- Booking creation and confirmation.
- Admin routes.
- Private guest booking-management routes.
- Image generation.
- Contact form submissions.
- iCal sync endpoints.

Cache Components are not enabled yet because the current stable scaffold is Next.js 16.2.10 and the installed adoption workflow requires Next.js 16.3+. The strategy is documented now and can be adopted once stable tooling supports it.

## Internationalization

Routes use locale prefixes:

- `/en/...`
- `/el/...`

The root route resolves to English. Locale-aware content is stored independently for English and Greek. Greek copy should be reviewed by a native speaker before production.

## Image Generation

The OpenAI JavaScript SDK will be used server-side only. The model is `gpt-image-2`. Requests read the key from `process.env.OPENAI_API_KEY`.

Generated images are restricted to non-factual editorial assets, abstract textures, Open Graph concepts, and visual experiments. The system must not generate fake property photographs, fake nearby beaches, fake amenities, or anything that could mislead a guest.

## Storage

Local development stores media under documented local directories:

- `storage/uploads`
- `storage/generated-assets`

A storage provider interface will keep future object storage migration isolated.

## Emails

Mailpit is used locally. Email delivery sits behind a provider interface so SMTP or a transactional provider can be added without changing booking-domain code.

## Admin

The admin app uses server-side authorization for every operation. UI hiding is never treated as access control.
