# AI Tax Agent - Setup Guide

This guide describes how to set up the AI Tax Agent infrastructure from scratch.

## Prerequisites

- Docker Desktop (latest version)
- Make
- Python 3.11+
- **Host Networking**: Add the following to your `/etc/hosts` file:
  ```text
  127.0.0.1 local.lan traefik.local.lan auth.local.lan api.local.lan minio.local.lan vault.local.lan grafana.local.lan
  ```

## Quick Start (Fresh Install)

To start the entire system from a clean slate:

1.  **Clean up existing resources** (WARNING: This deletes all data):

    ```bash
    make clean-data
    ```

2.  **Bootstrap the environment**:
    This generates secure secrets and creates necessary directories.

    ```bash
    make bootstrap
    ```

3.  **Deploy Infrastructure**:
    This starts all core services (Databases, Authentik, Vault, MinIO, etc.).

    ```bash
    make deploy-infra
    ```

    _Wait for about 30-60 seconds for services to initialize._

4.  **Deploy Application Services**:
    This starts the AI Tax Agent microservices.
    ```bash
    make deploy-services
    ```

## Verification

Once everything is up, you can access the following services:

- **Authentik (SSO)**: [https://auth.local.lan](https://auth.local.lan)
  - Username: `admin@local.lan`
  - Password: See `infra/environments/local/.env` (look for `AUTHENTIK_BOOTSTRAP_PASSWORD` or `admin123` default)
- **Traefik Dashboard**: [https://traefik.local.lan/dashboard/](https://traefik.local.lan/dashboard/)
- **Grafana**: [https://grafana.local.lan](https://grafana.local.lan)
- **MinIO Console**: [https://minio.local.lan](https://minio.local.lan)
- **Vault**: [https://vault.local.lan](https://vault.local.lan)
- **API Health**: [https://api.local.lan/ingestion/health](https://api.local.lan/ingestion/health)

## Troubleshooting

If services fail to start or connect:

- Check logs: `make logs`
- Check status: `make status`
- Restart Authentik (if SSO issues): `make restart-authentik`
