# davidakerlind/harpaviljongen-db-api architecture

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

- Interactive diagram: https://gitdiagram.com/davidakerlind/harpaviljongen-db-api
- Repository: https://github.com/davidakerlind/harpaviljongen-db-api

## Overview

Harpaviljongen API is a MongoDB-backed restaurant content and administration backend. Website and admin clients call the Express API: public reads serve menus, wine lists, hours, events, PDFs, hero slides, and site configuration; authenticated admin writes manage that content and user accounts. The graph follows server mounts and the sampled authentication and PDF routes; unsampled route-to-controller and controller-to-model wiring is not inferred. Cloudinary upload behavior and the hero settings/image service are shown where source supports them.

Main entry points: [`server.js`](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/server.js) (Express server), [`services/cloudinaryService.js`](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/cloudinaryService.js) (File uploads), [`controllers/menuPdfController.js`](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/controllers/menuPdfController.js) (PDF operations), [`routes/menuPdfRoutes.js`](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuPdfRoutes.js) (Menu PDF routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_content["Restaurant content"]
  node_menu_routes["Menu routes<br/>[menuRouter.js]"]
  node_wine_routes["Wine routes<br/>[wineListRouter.js]"]
  node_list_routes["Menu list routes<br/>[menuListRouter.js]"]
  node_pdf_routes["Menu PDF routes<br/>[menuPdfRoutes.js]"]
  node_hours_routes["Opening hours routes"]
  node_events_routes["Event routes<br/>[eventRouter.js]"]
  node_hero_routes["Hero image routes<br/>[heroRouter.js]"]
  node_config_routes["Site config routes"]
  node_settings_routes["Site settings routes"]
  node_menu_pdf_controller["PDF operations"]
  node_menu_pdf_model[("PDF records<br/>[MenuPdf.js]")]
  node_menu_list_model[("Menu list records<br/>[menuList.js]")]
  node_hero_service["Hero slides/settings<br/>[heroService.js]"]
  node_hero_model[("Hero image records<br/>[heroImage.js]")]
  node_settings_model[("Site settings records<br/>[siteSettings.js]")]
end

subgraph group_admin["Administration"]
  node_auth_routes["Authentication routes<br/>[authRouter.js]"]
  node_users_routes["User routes<br/>[userRouter.js]"]
  node_auth_controller["Authentication operations<br/>[authController.js]"]
  node_user_service["User management<br/>[userService.js]"]
  node_user_model[("User records<br/>[user.js]")]
end

subgraph group_insights["Activity and analytics"]
  node_activity_routes["Activity routes<br/>[activityRouter.js]"]
  node_analytics_routes["Analytics routes<br/>[analyticsRouter.js]"]
  node_activity_service["Activity logging<br/>[activityService.js]"]
  node_analytics_service["Analytics"]
end

subgraph group_integrations["External services"]
  node_mongo[("MongoDB")]
  node_cloudinary[("Cloudinary")]
  node_cloudflare_service["Cloudflare analytics"]
  node_cloudinary_service["File uploads"]
end

node_clients(("Website and admin"))

node_clients -->|"send API requests"| node_server
node_server -->|"mounts"| node_menu_routes
node_server -->|"mounts"| node_wine_routes
node_server -->|"mounts"| node_list_routes
node_server -->|"mounts"| node_pdf_routes
node_server -->|"mounts"| node_hours_routes
node_server -->|"mounts"| node_events_routes
node_server -->|"mounts"| node_hero_routes
node_server -->|"mounts"| node_config_routes
node_server -->|"mounts"| node_settings_routes
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_users_routes
node_server -->|"mounts"| node_activity_routes
node_server -->|"mounts"| node_analytics_routes
node_pdf_routes -->|"dispatches"| node_menu_pdf_controller
node_menu_pdf_controller -->|"reads/writes"| node_menu_pdf_model
node_menu_pdf_controller -->|"checks menu types"| node_menu_list_model
node_pdf_routes -->|"uploads middleware"| node_cloudinary_service
node_menu_pdf_controller -->|"uploads/deletes files"| node_cloudinary_service
node_cloudinary_service -->|"stores files"| node_cloudinary
node_hero_service -->|"reads/writes"| node_hero_model
node_hero_service -->|"reads/writes"| node_settings_model
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"manages accounts"| node_user_service
node_auth_routes -->|"avatar upload middleware"| node_cloudinary_service
node_auth_controller -->|"uploads avatars"| node_cloudinary_service
node_cloudinary_service -->|"stores files"| node_cloudinary

click node_server "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/server.js"
click node_menu_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuRouter.js"
click node_wine_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/wineListRouter.js"
click node_list_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuListRouter.js"
click node_pdf_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuPdfRoutes.js"
click node_hours_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/openingHoursRouter.js"
click node_events_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/eventRouter.js"
click node_hero_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/heroRouter.js"
click node_settings_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/siteSettingsRouter.js"
click node_menu_pdf_controller "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/controllers/menuPdfController.js"
click node_menu_pdf_model "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/MenuPdf.js"
click node_menu_list_model "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/menuList.js"
click node_hero_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/heroService.js"
click node_hero_model "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/heroImage.js"
click node_settings_model "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/siteSettings.js"
click node_auth_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/authRouter.js"
click node_users_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/userRouter.js"
click node_auth_controller "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/controllers/authController.js"
click node_user_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/userService.js"
click node_user_model "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/user.js"
click node_activity_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/activityRouter.js"
click node_analytics_routes "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/analyticsRouter.js"
click node_activity_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/activityService.js"
click node_analytics_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/analyticsService.js"
click node_cloudflare_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/cloudflareAnalytics.js"
click node_cloudinary_service "https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/cloudinaryService.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_server toneBlue
class node_menu_routes,node_wine_routes,node_list_routes,node_pdf_routes,node_hours_routes,node_events_routes,node_hero_routes,node_config_routes,node_settings_routes,node_menu_pdf_controller,node_menu_pdf_model,node_menu_list_model,node_hero_service,node_hero_model,node_settings_model toneAmber
class node_auth_routes,node_users_routes,node_auth_controller,node_user_service,node_user_model toneMint
class node_activity_routes,node_analytics_routes,node_activity_service,node_analytics_service toneRose
class node_mongo,node_cloudinary,node_cloudflare_service,node_cloudinary_service,node_clients toneIndigo
```

## Components

### API runtime

- [Express server](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/server.js): `server.js`

### Restaurant content

- [Menu routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuRouter.js): `routes/menuRouter.js`
- [Wine routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/wineListRouter.js): `routes/wineListRouter.js`
- [Menu list routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuListRouter.js): `routes/menuListRouter.js`
- [Menu PDF routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/menuPdfRoutes.js): `routes/menuPdfRoutes.js`
- [Opening hours routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/openingHoursRouter.js): `routes/openingHoursRouter.js`
- [Event routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/eventRouter.js): `routes/eventRouter.js`
- [Hero image routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/heroRouter.js): `routes/heroRouter.js`
- **Site config routes**
- [Site settings routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/siteSettingsRouter.js): `routes/siteSettingsRouter.js`
- [PDF operations](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/controllers/menuPdfController.js): `controllers/menuPdfController.js`
- [PDF records](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/MenuPdf.js): `models/MenuPdf.js`
- [Menu list records](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/menuList.js): `models/menuList.js`
- [Hero slides/settings](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/heroService.js): `services/heroService.js`
- [Hero image records](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/heroImage.js): `models/heroImage.js`
- [Site settings records](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/siteSettings.js): `models/siteSettings.js`

### Administration

- [Authentication routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/authRouter.js): `routes/authRouter.js`
- [User routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/userRouter.js): `routes/userRouter.js`
- [Authentication operations](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/controllers/authController.js): `controllers/authController.js`
- [User management](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/userService.js): `services/userService.js`
- [User records](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/models/user.js): `models/user.js`

### Activity and analytics

- [Activity routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/activityRouter.js): `routes/activityRouter.js`
- [Analytics routes](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/routes/analyticsRouter.js): `routes/analyticsRouter.js`
- [Activity logging](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/activityService.js): `services/activityService.js`
- [Analytics](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/analyticsService.js): `services/analyticsService.js`

### External services

- **MongoDB**
- **Cloudinary**
- [Cloudflare analytics](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/cloudflareAnalytics.js): `services/cloudflareAnalytics.js`
- [File uploads](https://github.com/davidakerlind/harpaviljongen-db-api/blob/main/services/cloudinaryService.js): `services/cloudinaryService.js`

### Other components

- **Website and admin**

## Connections

- Website and admin → Express server: send API requests
- Express server → Menu routes: mounts
- Express server → Wine routes: mounts
- Express server → Menu list routes: mounts
- Express server → Menu PDF routes: mounts
- Express server → Opening hours routes: mounts
- Express server → Event routes: mounts
- Express server → Hero image routes: mounts
- Express server → Site config routes: mounts
- Express server → Site settings routes: mounts
- Express server → Authentication routes: mounts
- Express server → User routes: mounts
- Express server → Activity routes: mounts
- Express server → Analytics routes: mounts
- Menu PDF routes → PDF operations: dispatches
- PDF operations → PDF records: reads/writes
- PDF operations → Menu list records: checks menu types
- Menu PDF routes → File uploads: uploads middleware
- PDF operations → File uploads: uploads/deletes files
- File uploads → Cloudinary: stores files
- Hero slides/settings → Hero image records: reads/writes
- Hero slides/settings → Site settings records: reads/writes
- Authentication routes → Authentication operations: dispatches
- Authentication operations → User management: manages accounts
- Authentication routes → File uploads: avatar upload middleware
- Authentication operations → File uploads: uploads avatars
- File uploads → Cloudinary: stores files
