# sparshkashyap/photo-app architecture

> Architecture diagram of the GitHub repository sparshkashyap/photo-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sparshkashyap/photo-app
- Repository: https://github.com/sparshkashyap/photo-app

## Overview

This is a photo-management web application: users sign in, browse and organize photos, then use features such as favorites, trash, and share links. The frontend provides the interface and API client; the Express backend routes requests to domain controllers, which access AWS storage. The README is empty, and source excerpts are partial, so the graph preserves documented route and capability boundaries while omitting uncertain controller-to-service wiring.

Main entry points: [`backend/app.js`](https://github.com/sparshkashyap/photo-app/blob/main/backend/app.js) (Express API), [`frontend/src/services/api.ts`](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/services/api.ts) (API client), [`backend/src/services/authService.js`](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/authService.js) (Auth service), [`backend/src/controllers/shareController.js`](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/shareController.js) (Share controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_auth_ui["Sign-in UI<br/>[login.tsx]"]
  node_auth_state["Auth state<br/>[useAuth.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_gallery_ui["Photo gallery<br/>[dashboard.tsx]"]
  node_photo_views["Photo views<br/>[PhotoGallery.tsx]"]
  node_upload_ui["Photo upload<br/>[UploadPhoto.tsx]"]
  node_folders_ui["Folder views<br/>[FolderTree.tsx]"]
  node_search_ui["Search and filters<br/>[SearchBar.tsx]"]
  node_favorites_ui["Favorites view<br/>[favorites.tsx]"]
  node_trash_ui["Trash view<br/>[trash.tsx]"]
  node_sharing_ui["Shared photo views<br/>[shared.tsx]"]
end

subgraph group_api["API and authentication"]
  node_api_server["Express API<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Auth controller<br/>[authController.js]"]
  node_auth_service["Auth service<br/>[authService.js]"]
  node_google_auth["Google OAuth"]
  node_user_routes["User routes<br/>[userRoutes.js]"]
end

subgraph group_library["Photo library"]
  node_photo_routes["Photo routes<br/>[photoRoutes.js]"]
  node_photo_controller["Photo controller<br/>[photoController.js]"]
  node_folder_routes["Folder routes<br/>[folderRoutes.js]"]
  node_folder_controller["Folder controller"]
  node_favorite_routes["Favorite routes<br/>[favoriteRoutes.js]"]
  node_favorite_controller["Favorite controller"]
  node_search_service["Search service<br/>[searchService.js]"]
end

subgraph group_lifecycle["Photo lifecycle"]
  node_trash_routes["Trash routes<br/>[trashRoutes.js]"]
  node_trash_controller["Trash controller<br/>[trashController.js]"]
  node_share_routes["Share routes<br/>[shareRoutes.js]"]
  node_photo_share_routes["Photo share routes"]
  node_share_controller["Share controller<br/>[shareController.js]"]
  node_share_service["Share service<br/>[shareService.js]"]
  node_cleanup_job["Trash cleanup<br/>[cleanupTrash.js]"]
end

node_person(("Photo user"))
node_dynamo[("DynamoDB")]
node_s3[("Amazon S3")]

node_person -->|"signs in"| node_auth_ui
node_person -->|"manages photos"| node_gallery_ui
node_auth_ui -->|"submits credentials"| node_auth_state
node_auth_state -->|"calls auth API"| node_api_client
node_gallery_ui -->|"shows library"| node_photo_views
node_gallery_ui -->|"requests data"| node_api_client
node_upload_ui -->|"uploads photos"| node_api_client
node_folders_ui -->|"manages folders"| node_api_client
node_search_ui -->|"searches photos"| node_api_client
node_favorites_ui -->|"loads favorites"| node_api_client
node_trash_ui -->|"manages trash"| node_api_client
node_sharing_ui -->|"opens shared photos"| node_api_client
node_api_client -->|"sends requests"| node_api_server
node_api_server -->|"mounts routes"| node_auth_routes
node_api_server -->|"mounts routes"| node_user_routes
node_api_server -->|"mounts routes"| node_photo_routes
node_api_server -->|"mounts routes"| node_folder_routes
node_api_server -->|"mounts routes"| node_favorite_routes
node_api_server -->|"mounts routes"| node_trash_routes
node_api_server -->|"mounts routes"| node_share_routes
node_api_server -->|"mounts routes"| node_photo_share_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes users"| node_dynamo
node_auth_service -.->|"OAuth support"| node_google_auth
node_auth_service -.->|"verifies Google identity"| node_person
node_photo_routes -->|"dispatches"| node_photo_controller
node_photo_controller -->|"reads and writes metadata"| node_dynamo
node_photo_controller -->|"uploads and signs URLs"| node_s3
node_folder_routes -->|"dispatches"| node_folder_controller
node_folder_controller -->|"reads and writes folders"| node_dynamo
node_favorite_routes -->|"dispatches"| node_favorite_controller
node_favorite_controller -->|"updates favorites"| node_dynamo
node_trash_routes -->|"dispatches"| node_trash_controller
node_trash_controller -->|"reads and updates photos"| node_dynamo
node_trash_controller -->|"deletes objects"| node_s3
node_share_routes -->|"dispatches"| node_share_controller
node_photo_share_routes -->|"dispatches"| node_share_controller
node_share_controller -->|"reads and writes shares"| node_dynamo
node_share_controller -->|"signs photo URLs"| node_s3
node_cleanup_job -->|"cleans expired trash"| node_dynamo
node_search_service -.->|"searches photo records"| node_dynamo

click node_auth_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/login.tsx"
click node_auth_state "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/hooks/useAuth.tsx"
click node_api_client "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/services/api.ts"
click node_gallery_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/dashboard.tsx"
click node_photo_views "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/PhotoGallery.tsx"
click node_upload_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/UploadPhoto.tsx"
click node_folders_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/FolderTree.tsx"
click node_search_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/SearchBar.tsx"
click node_favorites_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/favorites.tsx"
click node_trash_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/trash.tsx"
click node_sharing_ui "https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/shared.tsx"
click node_api_server "https://github.com/sparshkashyap/photo-app/blob/main/backend/app.js"
click node_auth_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/authRoutes.js"
click node_auth_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/authController.js"
click node_auth_service "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/authService.js"
click node_google_auth "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/googleAuthService.js"
click node_user_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/userRoutes.js"
click node_photo_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/photoRoutes.js"
click node_photo_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/photoController.js"
click node_folder_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/folderRoutes.js"
click node_folder_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/folderController.js"
click node_favorite_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/favoriteRoutes.js"
click node_favorite_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/favoriteController.js"
click node_search_service "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/searchService.js"
click node_trash_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/trashRoutes.js"
click node_trash_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/trashController.js"
click node_share_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/shareRoutes.js"
click node_photo_share_routes "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/photoShareRoutes.js"
click node_share_controller "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/shareController.js"
click node_share_service "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/shareService.js"
click node_cleanup_job "https://github.com/sparshkashyap/photo-app/blob/main/backend/src/jobs/cleanupTrash.js"

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_auth_ui,node_auth_state,node_api_client,node_gallery_ui,node_photo_views,node_upload_ui,node_folders_ui,node_search_ui,node_favorites_ui,node_trash_ui,node_sharing_ui,node_person toneBlue
class node_api_server,node_auth_routes,node_auth_controller,node_auth_service,node_google_auth,node_user_routes,node_dynamo,node_s3 toneAmber
class node_photo_routes,node_photo_controller,node_folder_routes,node_folder_controller,node_favorite_routes,node_favorite_controller,node_search_service toneMint
class node_trash_routes,node_trash_controller,node_share_routes,node_photo_share_routes,node_share_controller,node_share_service,node_cleanup_job toneRose
```

## Components

### Web application

- [Sign-in UI](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/login.tsx): `frontend/src/routes/login.tsx`
- [Auth state](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/hooks/useAuth.tsx): `frontend/src/hooks/useAuth.tsx`
- [API client](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Photo gallery](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/dashboard.tsx): `frontend/src/routes/dashboard.tsx`
- [Photo views](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/PhotoGallery.tsx): `frontend/src/components/PhotoGallery.tsx`
- [Photo upload](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/UploadPhoto.tsx): `frontend/src/components/UploadPhoto.tsx`
- [Folder views](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/FolderTree.tsx): `frontend/src/components/FolderTree.tsx`
- [Search and filters](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/components/SearchBar.tsx): `frontend/src/components/SearchBar.tsx`
- [Favorites view](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/favorites.tsx): `frontend/src/routes/favorites.tsx`
- [Trash view](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/trash.tsx): `frontend/src/routes/trash.tsx`
- [Shared photo views](https://github.com/sparshkashyap/photo-app/blob/main/frontend/src/routes/shared.tsx): `frontend/src/routes/shared.tsx`

### API and authentication

- [Express API](https://github.com/sparshkashyap/photo-app/blob/main/backend/app.js): `backend/app.js`
- [Auth routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Auth controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Auth service](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/authService.js): `backend/src/services/authService.js`
- [Google OAuth](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/googleAuthService.js): `backend/src/services/googleAuthService.js`
- [User routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/userRoutes.js): `backend/src/routes/userRoutes.js`

### Photo library

- [Photo routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/photoRoutes.js): `backend/src/routes/photoRoutes.js`
- [Photo controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/photoController.js): `backend/src/controllers/photoController.js`
- [Folder routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/folderRoutes.js): `backend/src/routes/folderRoutes.js`
- [Folder controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/folderController.js): `backend/src/controllers/folderController.js`
- [Favorite routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/favoriteRoutes.js): `backend/src/routes/favoriteRoutes.js`
- [Favorite controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/favoriteController.js): `backend/src/controllers/favoriteController.js`
- [Search service](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/searchService.js): `backend/src/services/searchService.js`

### Photo lifecycle

- [Trash routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/trashRoutes.js): `backend/src/routes/trashRoutes.js`
- [Trash controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/trashController.js): `backend/src/controllers/trashController.js`
- [Share routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/shareRoutes.js): `backend/src/routes/shareRoutes.js`
- [Photo share routes](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/routes/photoShareRoutes.js): `backend/src/routes/photoShareRoutes.js`
- [Share controller](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/controllers/shareController.js): `backend/src/controllers/shareController.js`
- [Share service](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/services/shareService.js): `backend/src/services/shareService.js`
- [Trash cleanup](https://github.com/sparshkashyap/photo-app/blob/main/backend/src/jobs/cleanupTrash.js): `backend/src/jobs/cleanupTrash.js`

### Other components

- **Photo user**
- **DynamoDB**
- **Amazon S3**

## Connections

- Photo user → Sign-in UI: signs in
- Photo user → Photo gallery: manages photos
- Sign-in UI → Auth state: submits credentials
- Auth state → API client: calls auth API
- Photo gallery → Photo views: shows library
- Photo gallery → API client: requests data
- Photo upload → API client: uploads photos
- Folder views → API client: manages folders
- Search and filters → API client: searches photos
- Favorites view → API client: loads favorites
- Trash view → API client: manages trash
- Shared photo views → API client: opens shared photos
- API client → Express API: sends requests
- Express API → Auth routes: mounts routes
- Express API → User routes: mounts routes
- Express API → Photo routes: mounts routes
- Express API → Folder routes: mounts routes
- Express API → Favorite routes: mounts routes
- Express API → Trash routes: mounts routes
- Express API → Share routes: mounts routes
- Express API → Photo share routes: mounts routes
- Auth routes → Auth controller: dispatches
- Auth controller → Auth service: calls
- Auth service → DynamoDB: reads and writes users
- Auth service → Google OAuth: OAuth support
- Auth service → Photo user: verifies Google identity
- Photo routes → Photo controller: dispatches
- Photo controller → DynamoDB: reads and writes metadata
- Photo controller → Amazon S3: uploads and signs URLs
- Folder routes → Folder controller: dispatches
- Folder controller → DynamoDB: reads and writes folders
- Favorite routes → Favorite controller: dispatches
- Favorite controller → DynamoDB: updates favorites
- Trash routes → Trash controller: dispatches
- Trash controller → DynamoDB: reads and updates photos
- Trash controller → Amazon S3: deletes objects
- Share routes → Share controller: dispatches
- Photo share routes → Share controller: dispatches
- Share controller → DynamoDB: reads and writes shares
- Share controller → Amazon S3: signs photo URLs
- Trash cleanup → DynamoDB: cleans expired trash
- Search service → DynamoDB: searches photo records
