# danieldimitrov5/photo-album architecture

> Architecture diagram of the GitHub repository danieldimitrov5/photo-album, 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/danieldimitrov5/photo-album
- Repository: https://github.com/danieldimitrov5/photo-album

## Overview

Photo Album is an Express web application for browsing and sharing photos, with user accounts, comments, administrative management, contact messages, and upload notifications. The main workflow is a visitor or logged-in user submitting a photo through the photo route; the controller delegates creation to the photo service and emits a Socket.IO event, while visitors browse photo pages and comments. User and comment operations are represented from documented capabilities and the available route/controller structure; their detailed service wiring was not sampled, so uncertain internal links are omitted.

Main entry points: [`src/application.ts`](https://github.com/danieldimitrov5/photo-album/blob/main/src/application.ts) (HTTP and socket app), [`src/controllers/photoController.ts`](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/photoController.ts) (Photo controller), [`src/controllers/indexController.ts`](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/indexController.ts) (Home controller), [`src/controllers/userController.ts`](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/userController.ts) (User controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_application["HTTP and socket app<br/>[application.ts]"]
  node_index_routes["Home routes<br/>[indexRoutes.ts]"]
  node_index_controller["Home controller<br/>[indexController.ts]"]
  node_photo_routes["Photo routes<br/>[photoRoutes.ts]"]
  node_photo_controller["Photo controller<br/>[photoController.ts]"]
  node_user_routes["User routes<br/>[userRoutes.ts]"]
  node_user_controller["User controller<br/>[userController.ts]"]
  node_comment_routes["Comment routes<br/>[commentRoutes.ts]"]
  node_comment_controller["Comment controller"]
  node_auth["Session and access"]
  node_views["Page templates"]
end

subgraph group_domain["Photo and user services"]
  node_photo_service["Photo service<br/>[photoService.ts]"]
  node_user_service["User service<br/>[userService.ts]"]
  node_mail_service["User mail service<br/>[userMailService.ts]"]
  node_comment_service["Comment service<br/>[commentService.ts]"]
end

subgraph group_persistence["Persistence"]
  node_photo_model["Photo model<br/>[photo.ts]"]
  node_user_model["User model<br/>[user.ts]"]
  node_comment_model["Comment model<br/>[comment.ts]"]
  node_message_model["Message model<br/>[message.ts]"]
  node_database[("MySQL database<br/>[sequelizeClient.ts]")]
end

subgraph group_integrations["External integrations"]
  node_mail_provider(("Email service"))
end

node_visitor(("Visitor / user"))
node_socket_clients(("Connected clients"))

node_visitor -->|"sends requests"| node_application
node_application -->|"mounts home"| node_index_routes
node_application -->|"mounts users"| node_user_routes
node_application -->|"mounts photos"| node_photo_routes
node_application -->|"mounts comments"| node_comment_routes
node_application -->|"applies sessions"| node_auth
node_index_routes -->|"dispatches home"| node_index_controller
node_index_controller -->|"loads latest photos"| node_photo_service
node_index_controller -->|"loads latest users"| node_user_service
node_photo_routes -->|"guards actions"| node_auth
node_photo_routes -->|"dispatches photo actions"| node_photo_controller
node_photo_controller -->|"manages photos"| node_photo_service
node_photo_controller -->|"loads comments"| node_comment_service
node_photo_controller -->|"emits upload event"| node_application
node_user_routes -->|"guards account actions"| node_auth
node_user_routes -->|"dispatches user actions"| node_user_controller
node_user_controller -->|"handles user messages"| node_mail_service
node_user_controller -->|"deletes comments"| node_comment_service
node_comment_routes -->|"dispatches comment actions"| node_comment_controller
node_photo_service -->|"reads and writes"| node_photo_model
node_user_service -->|"reads and writes"| node_user_model
node_mail_service -->|"manages accounts"| node_user_model
node_comment_service -->|"reads and writes"| node_comment_model
node_mail_service -->|"stores messages"| node_message_model
node_photo_model -->|"persists through"| node_database
node_user_model -->|"persists through"| node_database
node_comment_model -->|"persists through"| node_database
node_message_model -->|"persists through"| node_database
node_application -->|"broadcasts events"| node_socket_clients
node_mail_service -.->|"sends email"| node_mail_provider
node_photo_controller -->|"renders photo pages"| node_views
node_index_controller -->|"renders home pages"| node_views
node_user_controller -->|"renders user pages"| node_views

click node_application "https://github.com/danieldimitrov5/photo-album/blob/main/src/application.ts"
click node_index_routes "https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/indexRoutes.ts"
click node_index_controller "https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/indexController.ts"
click node_photo_routes "https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/photoRoutes.ts"
click node_photo_controller "https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/photoController.ts"
click node_user_routes "https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/userRoutes.ts"
click node_user_controller "https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/userController.ts"
click node_comment_routes "https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/commentRoutes.ts"
click node_comment_controller "https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/commentController.ts"
click node_auth "https://github.com/danieldimitrov5/photo-album/tree/main/src/middlewares/auth"
click node_views "https://github.com/danieldimitrov5/photo-album/tree/main/src/views"
click node_photo_service "https://github.com/danieldimitrov5/photo-album/blob/main/src/services/photoService.ts"
click node_user_service "https://github.com/danieldimitrov5/photo-album/blob/main/src/services/userService.ts"
click node_mail_service "https://github.com/danieldimitrov5/photo-album/blob/main/src/services/userMailService.ts"
click node_comment_service "https://github.com/danieldimitrov5/photo-album/blob/main/src/services/commentService.ts"
click node_photo_model "https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/photo.ts"
click node_user_model "https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/user.ts"
click node_comment_model "https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/comment.ts"
click node_message_model "https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/message.ts"
click node_database "https://github.com/danieldimitrov5/photo-album/blob/main/src/database/sequelizeClient.ts"

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_application,node_index_routes,node_index_controller,node_photo_routes,node_photo_controller,node_user_routes,node_user_controller,node_comment_routes,node_comment_controller,node_auth,node_views,node_visitor,node_socket_clients toneBlue
class node_photo_service,node_user_service,node_mail_service,node_comment_service toneAmber
class node_photo_model,node_user_model,node_comment_model,node_message_model,node_database toneMint
class node_mail_provider toneRose
```

## Components

### Web application

- [HTTP and socket app](https://github.com/danieldimitrov5/photo-album/blob/main/src/application.ts): `src/application.ts`
- [Home routes](https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/indexRoutes.ts): `src/routes/indexRoutes.ts`
- [Home controller](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/indexController.ts): `src/controllers/indexController.ts`
- [Photo routes](https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/photoRoutes.ts): `src/routes/photoRoutes.ts`
- [Photo controller](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/photoController.ts): `src/controllers/photoController.ts`
- [User routes](https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/userRoutes.ts): `src/routes/userRoutes.ts`
- [User controller](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/userController.ts): `src/controllers/userController.ts`
- [Comment routes](https://github.com/danieldimitrov5/photo-album/blob/main/src/routes/commentRoutes.ts): `src/routes/commentRoutes.ts`
- [Comment controller](https://github.com/danieldimitrov5/photo-album/blob/main/src/controllers/commentController.ts): `src/controllers/commentController.ts`
- [Session and access](https://github.com/danieldimitrov5/photo-album/tree/main/src/middlewares/auth): `src/middlewares/auth`
- [Page templates](https://github.com/danieldimitrov5/photo-album/tree/main/src/views): `src/views`

### Photo and user services

- [Photo service](https://github.com/danieldimitrov5/photo-album/blob/main/src/services/photoService.ts): `src/services/photoService.ts`
- [User service](https://github.com/danieldimitrov5/photo-album/blob/main/src/services/userService.ts): `src/services/userService.ts`
- [User mail service](https://github.com/danieldimitrov5/photo-album/blob/main/src/services/userMailService.ts): `src/services/userMailService.ts`
- [Comment service](https://github.com/danieldimitrov5/photo-album/blob/main/src/services/commentService.ts): `src/services/commentService.ts`

### Persistence

- [Photo model](https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/photo.ts): `src/database/models/photo.ts`
- [User model](https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/user.ts): `src/database/models/user.ts`
- [Comment model](https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/comment.ts): `src/database/models/comment.ts`
- [Message model](https://github.com/danieldimitrov5/photo-album/blob/main/src/database/models/message.ts): `src/database/models/message.ts`
- [MySQL database](https://github.com/danieldimitrov5/photo-album/blob/main/src/database/sequelizeClient.ts): `src/database/sequelizeClient.ts`

### External integrations

- **Email service**

### Other components

- **Visitor / user**
- **Connected clients**

## Connections

- Visitor / user → HTTP and socket app: sends requests
- HTTP and socket app → Home routes: mounts home
- HTTP and socket app → User routes: mounts users
- HTTP and socket app → Photo routes: mounts photos
- HTTP and socket app → Comment routes: mounts comments
- HTTP and socket app → Session and access: applies sessions
- Home routes → Home controller: dispatches home
- Home controller → Photo service: loads latest photos
- Home controller → User service: loads latest users
- Photo routes → Session and access: guards actions
- Photo routes → Photo controller: dispatches photo actions
- Photo controller → Photo service: manages photos
- Photo controller → Comment service: loads comments
- Photo controller → HTTP and socket app: emits upload event
- User routes → Session and access: guards account actions
- User routes → User controller: dispatches user actions
- User controller → User mail service: handles user messages
- User controller → Comment service: deletes comments
- Comment routes → Comment controller: dispatches comment actions
- Photo service → Photo model: reads and writes
- User service → User model: reads and writes
- User mail service → User model: manages accounts
- Comment service → Comment model: reads and writes
- User mail service → Message model: stores messages
- Photo model → MySQL database: persists through
- User model → MySQL database: persists through
- Comment model → MySQL database: persists through
- Message model → MySQL database: persists through
- HTTP and socket app → Connected clients: broadcasts events
- User mail service → Email service: sends email
- Photo controller → Page templates: renders photo pages
- Home controller → Page templates: renders home pages
- User controller → Page templates: renders user pages
