# Postaci - Swiss Postal Delivery Application

Postaci is a web application for managing postal deliveries in Switzerland, featuring OCR address scanning, address validation, and route optimization.

## Features

- OCR-based address scanning using Tesseract.js
- Swiss address validation with canton detection
- Route optimization for multiple delivery addresses
- Interactive map interface using Leaflet
- User authentication with NextAuth.js
- Prisma ORM for database operations

## Technology Stack

- **Frontend**: React, Next.js 15, TailwindCSS
- **Backend**: Next.js API routes, Express.js (validation service)
- **Database**: PostgreSQL with Prisma ORM
- **Authentication**: NextAuth.js
- **Maps**: Leaflet, React-Leaflet
- **OCR**: Tesseract.js

## Project Structure

- `app/` - Next.js application routes and components
- `components/` - Reusable React components 
- `lib/` - Utility functions and API helpers
- `prisma/` - Database schema and migrations
- `providers/` - React context providers
- `public/` - Static assets
- `validation-service/` - Address validation microservice

## Setup & Development

### Prerequisites

- Node.js 18+ and npm
- PostgreSQL (for production)

### Installation

1. Clone the repository:
   ```bash
   git clone https://gitea.oezdag.io/m3mo/POSTERAPP_V1.git
   cd POSTERAPP_V1
   ```

2. Install dependencies:
   ```bash
   npm install
   cd validation-service && npm install
   ```

3. Configure environment variables:
   ```bash
   cp .env.example .env.local
   ```

4. Start the development environment:
   ```bash
   ./start-dev.sh
   ```

This will start both the Next.js application and the address validation service.

## Database Setup

1. Initialize Prisma:
   ```bash
   npx prisma generate
   npx prisma db push
   ```

## Testing

The address validation service can be tested independently:

```bash
cd validation-service
npm run dev
```

Then use curl to test the endpoints:

```bash
# Validate an address
curl -X POST http://localhost:8000/api/validate-address \
  -H "Content-Type: application/json" \
  -d '{"address": "Luzernstrasse 27, 4552 Derendingen"}'
```

## License

This project is proprietary and confidential.