Merged in feature/aws-config-fix3 (pull request #184)

Make AWS variables optional

* comment

* aws vars optional
This commit is contained in:
Jay Brown
2025-09-17 18:12:51 +00:00
parent 6c209e5a81
commit 8a13b6d3b1
4 changed files with 101 additions and 20 deletions
+59 -8
View File
@@ -1,5 +1,6 @@
# Query Orchestration
AWS ambient version
This repository contains the DoczyAI code.
Using the following project as a baseline: `https://github.com/golang-standards/project-layout`.
@@ -28,12 +29,14 @@ For regular usage, please use `task` scripts in order run the most appropriate c
## Available Task Commands
### Core Development Workflow
- **`task fullsuite:ci`** - Complete CI workflow: generate, build, lint, test with coverage
- **`task fullsuite`** - Full development suite (similar to CI but for local development)
- **`task fullsuite:graph`** - Generate dependency graph visualization
- **`task precommit`** - Pre-commit checks for CI/CD readiness
### Code Generation
- **`task generate`** - Generate all code (DB queries via SQLC, OpenAPI clients/servers, mocks, docs)
- **`task go:generate`** - Generate Go-specific code
- **`task openapi:generate`** - Generate OpenAPI clients and servers from specs
@@ -43,38 +46,46 @@ For regular usage, please use `task` scripts in order run the most appropriate c
- **`task test:mocks:generate`** - Generate test mocks
### Build Commands
- **`task build`** - Build the project
- **`task docker:build`** - Build Docker images
- **`task docker:build:debug`** - Build Docker images with debug support
### Docker Compose Management
#### Build Commands
- **`task compose:build`** - Build Docker images using local compose file
- **`task compose:build:test`** - Build Docker images using test compose file
- **`task compose:build:generate`** - Build Docker images using generate compose file
#### Start/Up Commands
- **`task compose:up`** - Full local development startup with AWS resource initialization
- **`task compose:up:test`** - Start test environment containers
- **`task compose:up:generate`** - Start containers for code generation
- **`task compose:up:aws`** - Start AWS-specific environment
#### Stop/Down Commands
- **`task compose:down`** - Stop and remove local containers
- **`task compose:down:test`** - Stop and remove test containers
- **`task compose:down:aws`** - Stop and remove AWS containers
#### Cleanup Commands
- **`task compose:clean`** - Stop containers and remove volumes (local)
- **`task compose:clean:test`** - Stop containers and remove volumes (test)
- **`task compose:clean:aws`** - Stop containers and remove volumes (AWS)
#### Other Compose Commands
- **`task compose:refresh`** - Full restart: rebuild everything and start fresh
- **`task compose:rebuild`** - Force complete rebuild of all containers (use when build cache causes issues)
- **`task compose:lint`** - Validate syntax of all compose files
### Testing Commands
- **`task test:functional`** - Run functional tests with 80% coverage threshold
- **`task test:functional:full`** - Run all tests and reset coverage tracking
- **`task test:unit:short`** - Quick unit tests
@@ -89,6 +100,7 @@ For regular usage, please use `task` scripts in order run the most appropriate c
- **`task test:wait`** - Wait for test dependencies
### Linting Commands
- **`task lint`** - Run all linting (Go, YAML, JSON, Docker, OpenAPI)
- **`task go:lint`** - Run Go-specific linting
- **`task go:lint -- --fix`** - Fix automatically fixable Go linting issues
@@ -99,14 +111,17 @@ For regular usage, please use `task` scripts in order run the most appropriate c
- **`task db:lint`** - Lint database-related files
### Database Commands
- **`task db:mig:create`** - Create new database migration
- **`task db:generate`** - Generate Go code from SQL queries
### AWS Commands
- **`task aws:login`** - Login to AWS services
- **`task aws:textract:credentials`** - Set up AWS Textract credentials
### Utility Commands
- **`task deps:tidy`** - Tidy Go module dependencies
## Environment Variables
@@ -124,20 +139,23 @@ When using environment variables, there is a hierarchy that will be respected. (
The following environment variables are required for the application to function properly:
#### Core Application
```bash
LOG_LEVEL=INFO # Logging level: DEBUG|INFO|WARN|ERROR
```
#### Database (Required)
```bash
PGHOST=localhost # Database host
PGPORT=5432 # Database port
PGPORT=5432 # Database port
PGDATABASE=query_orchestration # Database name
PGUSER=postgres # Database username
PGPASSWORD=your_password # Database password
```
#### AWS Configuration (Required)
```bash
AWS_REGION=us-east-1 # AWS region
AWS_ACCESS_KEY_ID=your_access_key # AWS access key ID
@@ -146,11 +164,13 @@ AWS_SESSION_TOKEN=your_session_token # AWS session token (if using temporary c
```
#### S3 Storage (Required)
```bash
BUCKET=your-s3-bucket-name # S3 bucket for document storage
```
#### SQS Queue URLs (All Required)
```bash
QUEUE_URL=https://sqs.region.amazonaws.com/account/queue-name # Main query processing queue
DOCUMENT_INIT_URL=https://sqs.region.amazonaws.com/account/doc-init # Document initialization queue
@@ -164,6 +184,7 @@ QUERY_VERSION_SYNC_URL=https://sqs.region.amazonaws.com/account/query-version-sy
```
#### Authentication (Required for Production)
```bash
COGNITO_USER_POOL_ID=us-east-1_xxxxxxx # AWS Cognito User Pool ID
COGNITO_CLIENT_ID=your_client_id # AWS Cognito App Client ID
@@ -172,14 +193,16 @@ COGNITO_DOMAIN=your-cognito-domain # AWS Cognito domain name
```
#### Authorization (Required for RBAC)
```bash
PERMIT_IO_API_KEY=permit_key_xxxxxxx # Permit.io API key for RBAC
PERMIT_IO_PDP_URL=http://localhost:7766 # Permit.io Policy Decision Point URL - can use cloud version optionally
PERMIT_IO_PDP_URL=http://localhost:7766 # Permit.io Policy Decision Point URL - can use cloud version optionally
```
### Optional Environment Variables
#### Development & Testing
```bash
DEBUG=true # Enable debug mode (development only)
DISABLE_AUTH=true # Bypass authentication (development/testing only)
@@ -187,18 +210,21 @@ DB_NOSSL=true # Disable SSL for database connections (de
```
#### AWS LocalStack (Development)
```bash
AWS_ENDPOINT_URL=http://localhost:4566 # Override AWS endpoints for LocalStack
AWS_S3_USE_PATH_STYLE=true # Use path-style S3 URLs for LocalStack
```
#### Server Configuration
```bash
PORT=8080 # HTTP server port (default: 8080)
HTTP_HOST=0.0.0.0 # HTTP server host (default: 0.0.0.0)
```
#### Observability
```bash
ENABLE_OTEL=false # Enable OpenTelemetry (default: false)
```
@@ -273,8 +299,8 @@ This will:
1. Add a file named `<api_name>.yml`. The api name is important, as it will be used as a reference throughout the codebase. The api name must be in the format `<functionality>API`. E.g. queryAPI, ClientAPI
2. Run `task openapi:generate`. This will generate the following:
a. A location to implement the server-side functions in `./api/<api_name>/`, as well as generated functions, models and swagger docs.
b. A location with the client-side code in `./pkg/<api_name>/`
a. A location to implement the server-side functions in `./api/<api_name>/`, as well as generated functions, models and swagger docs.
b. A location with the client-side code in `./pkg/<api_name>/`
3. Implement the controllers in `./api/<api_name>/`
4. Create a command in `./cmd/<api_name>/main.go` which creates a new instance from `./internal/api`
@@ -295,6 +321,7 @@ The project includes two build tasks for different use cases:
- `task docker:build:debug` - Build the debug image with Delve
The debug image is built using `build/Dockerfile.debug`, which:
- Installs Delve debugger with static linking for Alpine compatibility
- Builds Go binaries with debug symbols (`-gcflags="all=-N -l"`)
- Exposes port 2345 for debugger connections
@@ -305,17 +332,28 @@ To enable debugging for a service in `deployments/compose.local.yaml`, modify th
```yaml
query_api:
image: queryorchestration:debug # Use debug image instead of latest
command: ["/dlv", "exec", "./queryAPI", "--listen=:2345", "--headless", "--api-version=2", "--accept-multiclient", "--continue"]
image: queryorchestration:debug # Use debug image instead of latest
command:
[
"/dlv",
"exec",
"./queryAPI",
"--listen=:2345",
"--headless",
"--api-version=2",
"--accept-multiclient",
"--continue",
]
ports:
- "8080:8080" # Application port
- "2345:2345" # Debugger port
- "8080:8080" # Application port
- "2345:2345" # Debugger port
expose:
- 8080
- 2345
```
Key changes from production configuration:
1. **Image**: Use `queryorchestration:debug` instead of `queryorchestration:latest`
2. **Command**: Replace direct binary execution with Delve wrapper
3. **Ports**: Expose port 2345 for debugger connections
@@ -328,6 +366,7 @@ Key changes from production configuration:
### Connecting a Debugger
#### GoLand/IntelliJ IDEA
1. Go to **Run → Edit Configurations...**
2. Click **"+"** → **"Go Remote"**
3. Configure:
@@ -339,7 +378,9 @@ Key changes from production configuration:
6. Set breakpoints in your code and make HTTP requests to trigger them
#### VS Code
1. Add to `.vscode/launch.json`:
```json
{
"name": "Connect to Docker",
@@ -351,6 +392,7 @@ Key changes from production configuration:
"host": "localhost"
}
```
2. Set breakpoints and start debugging
The debugger will connect to the running container and pause execution when breakpoints are hit, allowing you to inspect variables, step through code, and debug issues in the containerized environment.
@@ -362,11 +404,13 @@ The system uses a structured naming convention for S3 objects that embeds metada
### Object Key Structure
S3 object keys follow this format:
```
{client_id}/{location}/{date}/{part}/{filename}
```
#### Example
```
test_client_1757026403/import/20250904/0/2025-09-04T225324Z~test_client_1757026403~import~56df8aa9-873c-48ea-a0e4-bc4f6b8ad69e~019916ef-46ab-73f7-b97b-5709df5c3985
```
@@ -374,13 +418,16 @@ test_client_1757026403/import/20250904/0/2025-09-04T225324Z~test_client_17570264
### Components
#### Directory Path (Prefix)
- **Client ID**: Unique identifier for the client (e.g., `test_client_1757026403`)
- **Location**: Processing stage - `import`, `text`, or `export`
- **Date**: Date in `YYYYMMDD` format (e.g., `20250904`)
- **Part**: Partition number for storage distribution (e.g., `0`)
#### Filename
The filename uses tilde (`~`) as a delimiter and contains:
- **Timestamp**: Full ISO timestamp (e.g., `2025-09-04T225324Z`)
- **Client ID**: Repeated for self-contained metadata
- **Location**: Repeated for self-contained metadata
@@ -389,15 +436,19 @@ The filename uses tilde (`~`) as a delimiter and contains:
- **File Extension**: Optional file type extension (e.g., `.pdf`)
### Location Types
- **import**: Initial document upload location
- **text**: Text extraction results storage
- **export**: Export results storage
### Partitioning Strategy
The part number (`0-n`) is used to distribute files across multiple directories, preventing performance issues with too many objects in a single S3 prefix. Export location does not use partitioning.
### Metadata Encoding
The filename contains all necessary metadata for document recovery and processing:
- Self-contained recovery capability from filename alone
- Support for both path-based and filename-based queries
- Human-readable format for debugging and troubleshooting