# Entry Points Documentation

## Overview

This document describes the entry points (main functions) for the Veza Backend API.

## Primary Entry Point

### `cmd/api/main.go`

**Status**: ✅ **ACTIVE** - Use this entry point for production

**Description**: Main entry point for the Veza Backend API. This is the production-ready entry point that includes:
- Full configuration loading
- Database initialization and migrations
- All services initialization
- Complete API router setup
- Health checks and metrics
- Graceful shutdown

**Usage**:
```bash
go run cmd/api/main.go
# or
go build -o veza-api cmd/api/main.go
./veza-api
```

**Environment Variables**: See `BACKEND_CONFIG.md` for full configuration options.

## Legacy Entry Points

### `cmd/modern-server/main.go`

**Status**: ⚠️ **DEPRECATED** - Do not use

**Description**: Legacy entry point from an earlier architecture migration. Contains incomplete implementations and TODOs.

**Why Deprecated**:
- Contains commented-out code and TODOs
- Incomplete service initialization
- Not actively maintained
- Same functionality available in `cmd/api/main.go`

**Migration**: Use `cmd/api/main.go` instead.

**Note**: This file may be removed in a future version. Do not use for new deployments.

## Other Entry Points

### `cmd/migrate_tool/main.go`

**Status**: ✅ **ACTIVE** - Database migration tool

**Description**: Standalone tool for running database migrations.

**Usage**:
```bash
go run cmd/migrate_tool/main.go
```

### `cmd/generate-config-docs/main.go`

**Status**: ✅ **ACTIVE** - Documentation generator

**Description**: Tool for generating configuration documentation.

**Usage**:
```bash
go run cmd/generate-config-docs/main.go
```

### `cmd/tools/hash_gen/main.go`

**Status**: ✅ **ACTIVE** - Utility tool

**Description**: Utility for generating password hashes.

**Usage**:
```bash
go run cmd/tools/hash_gen/main.go
```

## Recommendations

1. **For Production**: Always use `cmd/api/main.go`
2. **For Development**: Use `cmd/api/main.go`
3. **For Migrations**: Use `cmd/migrate_tool/main.go`
4. **Do Not Use**: `cmd/modern-server/main.go` (deprecated)

## Docker

The Dockerfile uses `cmd/api/main.go` as the entry point:

```dockerfile
RUN go build -o veza-api ./cmd/api/main.go
```

---

**Last Updated**: 2025-01-27  
**Maintained By**: Veza Backend Team
