# sahil555/image-service architecture

> Architecture diagram of the GitHub repository sahil555/image-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahil555/image-service
- Repository: https://github.com/sahil555/image-service

## Overview

This is a FastAPI image backend. Clients submit images and metadata, then retrieve filtered or individual image records, temporary download URLs, or delete images. The documented upload workflow stores image bytes in S3 and metadata in DynamoDB; the service code shows the orchestration of storage, metadata, and URL generation. The graph also includes Lambda adaptation and shared configuration and utility layers. Some repository/database wiring is documented but its implementation was not sampled, so those links are identified by their README evidence.

Main entry points: [`app/services/image_service.py`](https://github.com/sahil555/image-service/blob/main/app/services/image_service.py) (Image service), [`app/services/storage_service.py`](https://github.com/sahil555/image-service/blob/main/app/services/storage_service.py) (Storage service), [`app/api/routes/images.py`](https://github.com/sahil555/image-service/blob/main/app/api/routes/images.py) (Image routes), [`app/core/exception.py`](https://github.com/sahil555/image-service/blob/main/app/core/exception.py) (Error handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and runtime"]
  node_lambda["Lambda adapter<br/>[lambda_handler.py]"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["Image routes<br/>[images.py]"]
  node_image_schemas["Image schemas<br/>[image.py]"]
end

subgraph group_workflow["Image workflows"]
  node_image_service["Image service<br/>[image_service.py]"]
  node_metadata_model["Image metadata model<br/>[image.py]"]
end

subgraph group_infra["Storage and metadata"]
  node_storage_service["Storage service<br/>[storage_service.py]"]
  node_repository["Image repository"]
  node_ddb_client["DynamoDB client<br/>[ddb.py]"]
  node_s3[("S3 image store")]
  node_dynamodb[("DynamoDB")]
end

subgraph group_shared["Shared support"]
  node_config["AWS configuration<br/>[config.py]"]
  node_exceptions["Error handling<br/>[exception.py]"]
  node_helpers["Timing and dates<br/>[helpers.py]"]
  node_logging["Structured logging<br/>[logging.py]"]
end

node_user(("Image client"))
node_gateway{{"API Gateway"}}

node_user -->|"calls image APIs"| node_routes
node_gateway -->|"delivers events"| node_lambda
node_lambda -->|"adapts requests"| node_fastapi
node_fastapi -->|"registers routes"| node_routes
node_routes -->|"calls workflows"| node_image_service
node_image_service -->|"uploads, signs, deletes"| node_storage_service
node_image_service -->|"reads and saves metadata"| node_repository
node_storage_service -->|"transfers image objects"| node_s3
node_repository -->|"persists metadata"| node_dynamodb
node_ddb_client -->|"opens table"| node_dynamodb
node_storage_service -->|"reads AWS settings"| node_config
node_ddb_client -->|"reads AWS settings"| node_config
node_image_service -->|"formats timestamps"| node_helpers
node_storage_service -->|"times operations"| node_helpers
node_routes -->|"handles service errors"| node_exceptions
node_fastapi -->|"registers handlers"| node_exceptions
node_image_service -->|"raises workflow errors"| node_exceptions
node_storage_service -->|"raises storage errors"| node_exceptions

click node_lambda "https://github.com/sahil555/image-service/blob/main/app/lambda_handler.py"
click node_fastapi "https://github.com/sahil555/image-service/blob/main/app/main.py"
click node_routes "https://github.com/sahil555/image-service/blob/main/app/api/routes/images.py"
click node_image_service "https://github.com/sahil555/image-service/blob/main/app/services/image_service.py"
click node_storage_service "https://github.com/sahil555/image-service/blob/main/app/services/storage_service.py"
click node_repository "https://github.com/sahil555/image-service/blob/main/app/repositories/image_repository.py"
click node_ddb_client "https://github.com/sahil555/image-service/blob/main/app/dbs/ddb.py"
click node_config "https://github.com/sahil555/image-service/blob/main/app/core/config.py"
click node_exceptions "https://github.com/sahil555/image-service/blob/main/app/core/exception.py"
click node_helpers "https://github.com/sahil555/image-service/blob/main/app/utils/helpers.py"
click node_logging "https://github.com/sahil555/image-service/blob/main/app/core/logging.py"
click node_metadata_model "https://github.com/sahil555/image-service/blob/main/app/models/image.py"
click node_image_schemas "https://github.com/sahil555/image-service/blob/main/app/schemas/image.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lambda,node_fastapi,node_routes,node_image_schemas,node_user toneBlue
class node_image_service,node_metadata_model toneAmber
class node_storage_service,node_repository,node_ddb_client,node_s3,node_dynamodb,node_gateway toneMint
class node_config,node_exceptions,node_helpers,node_logging toneRose
```

## Components

### API and runtime

- [Lambda adapter](https://github.com/sahil555/image-service/blob/main/app/lambda_handler.py): `app/lambda_handler.py`
- [FastAPI app](https://github.com/sahil555/image-service/blob/main/app/main.py): `app/main.py`
- [Image routes](https://github.com/sahil555/image-service/blob/main/app/api/routes/images.py): `app/api/routes/images.py`
- [Image schemas](https://github.com/sahil555/image-service/blob/main/app/schemas/image.py): `app/schemas/image.py`

### Image workflows

- [Image service](https://github.com/sahil555/image-service/blob/main/app/services/image_service.py): `app/services/image_service.py`
- [Image metadata model](https://github.com/sahil555/image-service/blob/main/app/models/image.py): `app/models/image.py`

### Storage and metadata

- [Storage service](https://github.com/sahil555/image-service/blob/main/app/services/storage_service.py): `app/services/storage_service.py`
- [Image repository](https://github.com/sahil555/image-service/blob/main/app/repositories/image_repository.py): `app/repositories/image_repository.py`
- [DynamoDB client](https://github.com/sahil555/image-service/blob/main/app/dbs/ddb.py): `app/dbs/ddb.py`
- **S3 image store**
- **DynamoDB**

### Shared support

- [AWS configuration](https://github.com/sahil555/image-service/blob/main/app/core/config.py): `app/core/config.py`
- [Error handling](https://github.com/sahil555/image-service/blob/main/app/core/exception.py): `app/core/exception.py`
- [Timing and dates](https://github.com/sahil555/image-service/blob/main/app/utils/helpers.py): `app/utils/helpers.py`
- [Structured logging](https://github.com/sahil555/image-service/blob/main/app/core/logging.py): `app/core/logging.py`

### Other components

- **Image client**
- **API Gateway**

## Connections

- Image client → Image routes: calls image APIs (evidence: `README.md`)
- API Gateway → Lambda adapter: delivers events (evidence: `README.md`)
- Lambda adapter → FastAPI app: adapts requests (evidence: `README.md`)
- FastAPI app → Image routes: registers routes (evidence: `app/main.py`)
- Image routes → Image service: calls workflows (evidence: `app/api/routes/images.py`)
- Image service → Storage service: uploads, signs, deletes (evidence: `app/services/image_service.py`)
- Image service → Image repository: reads and saves metadata (evidence: `app/services/image_service.py`)
- Storage service → S3 image store: transfers image objects (evidence: `app/services/storage_service.py`)
- Image repository → DynamoDB: persists metadata (evidence: `README.md`)
- DynamoDB client → DynamoDB: opens table (evidence: `app/dbs/ddb.py`)
- Storage service → AWS configuration: reads AWS settings (evidence: `app/services/storage_service.py`)
- DynamoDB client → AWS configuration: reads AWS settings (evidence: `app/dbs/ddb.py`)
- Image service → Timing and dates: formats timestamps (evidence: `app/services/image_service.py`)
- Storage service → Timing and dates: times operations (evidence: `app/services/storage_service.py`)
- Image routes → Error handling: handles service errors (evidence: `app/api/routes/images.py`)
- FastAPI app → Error handling: registers handlers (evidence: `app/main.py`)
- Image service → Error handling: raises workflow errors (evidence: `app/services/image_service.py`)
- Storage service → Error handling: raises storage errors (evidence: `app/services/storage_service.py`)
