# House Plan Maker

A web-based apartment and room planning tool with 2D editing, wall projections, and a 3D preview. Design rooms, place electrical fixtures and furniture, and export layouts as PDFs.

## Features

- **Apartment & room management** — organize multi-room apartments with per-room floor type, wall finish, ceiling, and plinth properties.
- **2D editor** — draw walls, place doors/windows, add outlets/switches/cables and furniture on a Konva-powered canvas.
- **Wall projections** — view and edit each wall elevation with accurate opening and electrical placement.
- **3D view** — preview rooms in Three.js / React Three Fiber with materials, textures, and openings.
- **Electrical elements** — outlets (with horizontal/vertical orientation), switches, wall cables, ceiling and wall lights.
- **Furniture** — textured furniture items with projection onto wall elevations.
- **PDF export** — export floor plans and wall projections via jsPDF.
- **i18n** — English and Russian translations out of the box.

## Tech Stack

- **Monorepo**: npm workspaces + Turborepo
- **Client**: React 19, Vite 6, React Router 7, Konva, React Three Fiber / Three.js, i18next
- **Server**: Fastify 5, Prisma 6 (SQLite), Zod validation
- **Shared**: TypeScript types and Zod schemas in `packages/shared`
- **Tooling**: TypeScript, ESLint, Prettier, Vitest

## Repository Layout

```
apps/
  client/     # React + Vite frontend (2D editor, 3D view, PDF export)
  server/     # Fastify API + Prisma (SQLite)
packages/
  shared/     # Shared types and Zod schemas
```

## Getting Started

### Prerequisites

- Node.js 20+
- npm 10+

### Install

```bash
npm install
```

### Database setup

```bash
cd apps/server
npx prisma migrate dev
cd ../..
```

Set `DATABASE_URL` in `apps/server/.env` (defaults to a local SQLite file at `apps/server/prisma/dev.db`).

### Run in development

```bash
npm run dev
```

This starts both client (Vite) and server (tsx watch) via Turborepo. The client is served on the Vite dev port and proxies API calls to the Fastify server.

### Build

```bash
npm run build
```

### Test & lint

```bash
npm test
npm run lint
npm run format
```

## Data Model (summary)

- **Apartment** → has many **Rooms**
- **Room** → has **Walls**, **WallOpenings** (doors/windows), **ElectricalItems**, **FurnitureItems**, **Annotations**
- Stretch-ceiling, plinth, wall color/finish, and floor type are configured per room.

See [apps/server/prisma/schema.prisma](apps/server/prisma/schema.prisma) for the full schema.

## API

The Fastify server exposes REST routes under:

- `/apartments`
- `/rooms`
- `/elements` (walls, openings, electrical, furniture, annotations)

Request/response shapes are validated with Zod schemas from `@house-plan-maker/shared`.

## License

Private / unlicensed. Internal project.
