> ## Documentation Index
> Fetch the complete documentation index at: https://docs.grouple.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# Backend API Overview

> Node.js API running on AWS ECS + EC2

## Overview

The Grouple backend API is a Node.js/TypeScript server running in Docker containers on AWS ECS, behind an Application Load Balancer.

## Infrastructure

```
Route 53 (api.grouple.pro)
        ↓
Application Load Balancer (grouple-api-lb)
  ├── HTTP → redirects to HTTPS
  └── HTTPS → SSL terminated via ACM Certificate
        ↓
ECS Cluster (grouple-api-cluster)
  └── Auto Scaling Group (EC2 instances)
      └── ECS Tasks (API Containers)
          └── Docker image pulled from ECR (grouple-api)
```

## Server Entry Point

`server/index.ts` — main Express server
`server/node-build.ts` — build script
`server/routes/demo.ts` — route definitions

## Authentication

All API requests require a valid Supabase JWT passed as:

```
Authorization: Bearer <supabase_jwt>
```

The API validates JWT against Supabase Auth before processing requests.

## Environment & Secrets

* Environment variables injected at runtime by **AWS Secrets Manager**
* Supabase URL and service role key
* Amazon Bedrock credentials
* Other third-party service keys

## Deployment

```
GitHub push to main
        ↓
GitHub Actions (github-actions-user IAM)
        ↓
Build Docker image → push to ECR (grouple-api)
        ↓
ECS rolling deployment → new task definitions
        ↓
ALB routes traffic to new containers
```

## Observability

| Tool            | Purpose                                 |
| --------------- | --------------------------------------- |
| CloudWatch Logs | ECS task logs (`/ecs/grouple-api-task`) |
| AWS X-Ray       | Distributed tracing                     |
| ECS Console     | Container health, task status           |
