# digitalcom-av/av-knowledge-base architecture

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

- Interactive diagram: https://gitdiagram.com/digitalcom-av/av-knowledge-base
- Repository: https://github.com/digitalcom-av/av-knowledge-base

## Overview

#### Purpose and entry points
AV Knowledge Base is a documentation platform for AV engineers: categorized Markdown articles, tags, search, training diagrams, user accounts, and administration. It is a React SPA backed by an Express REST API and PostgreSQL.

- Frontend bootstrap and route composition: `client/src/main.jsx`, `client/src/routes/AppRoutes.jsx`, `client/src/App.jsx`
- API process and Express composition: `server/server.js`, `server/src/app.js`
- Database initialization and repeatable content setup: `server/src/database/setup.js`, `server/src/database/schema.sql`, `server/src/database/seed.js`

#### Frontend application shell and navigation
The Vite React client organizes authenticated knowledge-base views under a dashboard shell, with public authentication pages and route-level access guards. `AuthContext` supplies session state; toast state provides cross-cutting user feedback.

- Application layout/navigation: `client/src/layouts/DashboardLayout.jsx`, `client/src/layouts/Navbar.jsx`, `client/src/layouts/Sidebar.jsx`
- Authentication/session and guards: `client/src/context/AuthContext.jsx`, `client/src/components/guards.jsx`, `client/src/components/ProtectedContent.jsx`
- Principal user routes: `client/src/pages/Dashboard.jsx`, `client/src/pages/CategoryPage.jsx`, `client/src/pages/ArticlePage.jsx`

#### Content discovery and reading flow
Users navigate categories to articles or execute search. The client fetches data through domain API modules and hooks, then renders article cards and Markdown. Article/category/search logic is split at the client-server HTTP boundary.

- Client API boundary: `client/src/api/client.js`, `client/src/api/articles.js`, `client/src/api/search.js`
- Client query/state adapters: `client/src/hooks/useArticle.js`, `client/src/hooks/useCategories.js`, `client/src/hooks/useSearch.js`
- Reading and discovery presentation: `client/src/components/ArticleCard.jsx`, `client/src/components/MarkdownViewer.jsx`, `client/src/pages/SearchPage.jsx`
- Server endpoints/controllers: `server/src/routes/articles.routes.js`, `server/src/routes/search.routes.js`, `server/src/controllers/articles.controller.js`

#### Backend request pipeline and domain services
Express mounts versionless `/api` route groups, applies authentication/validation/error middleware, and delegates controllers to services. Services isolate business/query behavior from transport handlers; models represent persistence operations.

- Route aggregation and API domains: `server/src/routes/index.js`, `server/src/routes/auth.routes.js`, `server/src/routes/categories.routes.js`
- Controller-to-service layer: `server/src/controllers/auth.controller.js`, `server/src/services/articles.service.js`, `server/src/services/search.service.js`
- Request safety and failures: `server/src/middleware/auth.js`, `server/src/middleware/validate.js`, `server/src/middleware/errorHandler.js`

#### Persistence and managed content
PostgreSQL is the system of record for users, categories, articles, tags, and training diagrams. Connection/environment ownership stays server-side. Schema, migrations, SQL seeds, and imported Markdown content make content provisioning a separate operational stage from API runtime.

- Database configuration/access: `server/src/config/db.js`, `server/src/config/env.js`, `server/src/database/db.js`
- Persistence models: `server/src/models/article.model.js`, `server/src/models/user.model.js`, `server/src/models/trainingDiagram.model.js`
- Schema/content sources: `server/src/database/schema.sql`, `server/src/database/seeds/seed.sql`, `server/src/database/content/_import.js`

#### Administration, training, and diagram features
Administrative screens manage articles, categories, and users through protected API capabilities. Training is a distinct content mode backed by training routes/models and rendered diagrams; a diagram editor indicates authored visual content rather than a generic article-only system.

- Admin UI: `client/src/pages/Admin.jsx`, `client/src/components/admin/ArticlesManager.jsx`, `client/src/components/admin/UsersManager.jsx`
- Training/diagram UI: `client/src/pages/Training.jsx`, `client/src/pages/DiagramEditor.jsx`, `client/src/components/training/DiagramRenderer.jsx`
- Supporting backend contracts: `server/src/routes/training.routes.js`, `server/src/routes/users.routes.js`, `server/src/models/trainingDiagram.model.js`

#### Runtime and deployment boundaries
Node.js 18+ runs both Vite client tooling and the Express server. PostgreSQL 13+ is required externally. In development, Vite proxies `/api` to the backend; CORS is configurable for deployed origins. Railway deployment configuration exists at `railway.json`.

- Client runtime/build configuration: `client/package.json`, `client/vite.config.js`
- Server runtime/dependencies: `server/package.json`, `server/server.js`
- Deployment configuration: `railway.json`

Main entry points: [`client/src/api/client.js`](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/api/client.js) (Domain API client), [`client/src/routes/AppRoutes.jsx`](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/routes/AppRoutes.jsx) (Route composition), [`server/src/app.js`](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/app.js) (Express composition), [`railway.json`](https://github.com/digitalcom-av/av-knowledge-base/blob/main/railway.json) (Railway deployment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_vite["Vite SPA bootstrap<br/>frontend entry<br/>[main.jsx]"]
  node_routes["Route composition<br/>client routing<br/>[AppRoutes.jsx]"]
  node_shell["Dashboard shell<br/>application layout"]
  node_auth_context["Auth session<br/>client state<br/>[AuthContext.jsx]"]
  node_knowledge_views["Knowledge views<br/>article UI<br/>[ArticlePage.jsx]"]
  node_client_api["Domain API client<br/>HTTP adapter<br/>[client.js]"]
  node_admin_ui["Administration UI<br/>protected management UI<br/>[Admin.jsx]"]
  node_training_ui["Training and diagrams<br/>visual content UI<br/>[Training.jsx]"]
end

subgraph group_server["Express API"]
  node_server_entry["API process<br/>Node entry<br/>[server.js]"]
  node_express_app["Express composition<br/>application server<br/>[app.js]"]
  node_api_routes["API route domains<br/>route aggregation<br/>[index.js]"]
  node_request_safety["Auth and validation<br/>middleware<br/>[auth.js]"]
  node_controllers["Controllers<br/>transport handlers"]
  node_services["Domain services<br/>business/query layer"]
  node_models["Persistence models<br/>data access<br/>[article.model.js]"]
end

subgraph group_data["PostgreSQL Content"]
  node_postgres[("PostgreSQL<br/>system of record<br/>[db.js]")]
  node_provisioning["Schema and content provisioning<br/>database setup<br/>[setup.js]"]
end

node_deployment{{"Railway deployment<br/>deployment config<br/>[railway.json]"}}

node_vite -->|"boots"| node_routes
node_routes -->|"renders protected area"| node_shell
node_routes -->|"uses session guards"| node_auth_context
node_shell -->|"hosts"| node_knowledge_views
node_knowledge_views -->|"loads content"| node_client_api
node_admin_ui -->|"manages content and users"| node_client_api
node_training_ui -->|"loads diagrams"| node_client_api
node_client_api -->|"HTTP /api"| node_express_app
node_server_entry -->|"starts"| node_express_app
node_express_app -->|"applies"| node_request_safety
node_request_safety -->|"protects requests"| node_api_routes
node_api_routes -->|"dispatches"| node_controllers
node_controllers -->|"delegates"| node_services
node_services -->|"queries and mutates"| node_models
node_models -->|"persists"| node_postgres
node_provisioning -->|"initializes and seeds"| node_postgres
node_deployment -.->|"deploys client build"| node_vite
node_deployment -.->|"deploys API"| node_server_entry

click node_vite "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/main.jsx"
click node_routes "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/routes/AppRoutes.jsx"
click node_shell "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/layouts/DashboardLayout.jsx"
click node_auth_context "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/context/AuthContext.jsx"
click node_knowledge_views "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/ArticlePage.jsx"
click node_client_api "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/api/client.js"
click node_admin_ui "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/Admin.jsx"
click node_training_ui "https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/Training.jsx"
click node_server_entry "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/server.js"
click node_express_app "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/app.js"
click node_api_routes "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/routes/index.js"
click node_request_safety "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/middleware/auth.js"
click node_controllers "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/controllers/articles.controller.js"
click node_services "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/services/articles.service.js"
click node_models "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/models/article.model.js"
click node_postgres "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/config/db.js"
click node_provisioning "https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/database/setup.js"
click node_deployment "https://github.com/digitalcom-av/av-knowledge-base/blob/main/railway.json"

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_vite,node_routes,node_shell,node_auth_context,node_knowledge_views,node_client_api,node_admin_ui,node_training_ui toneBlue
class node_server_entry,node_express_app,node_api_routes,node_request_safety,node_controllers,node_services,node_models toneAmber
class node_postgres,node_provisioning toneMint
class node_deployment toneNeutral
```

## Components

### React Client

- [Vite SPA bootstrap](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/main.jsx): frontend entry · `client/src/main.jsx`
- [Route composition](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/routes/AppRoutes.jsx): client routing · Public auth pages and guarded dashboard routes. · `client/src/routes/AppRoutes.jsx`
- [Dashboard shell](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/layouts/DashboardLayout.jsx): application layout · `client/src/layouts/DashboardLayout.jsx`
- [Auth session](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/context/AuthContext.jsx): client state · `client/src/context/AuthContext.jsx`
- [Knowledge views](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/ArticlePage.jsx): article UI · Dashboard, category, article, and search reading views. · `client/src/pages/ArticlePage.jsx`
- [Domain API client](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/api/client.js): HTTP adapter · Article and search API modules call the backend. · `client/src/api/client.js`
- [Administration UI](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/Admin.jsx): protected management UI · `client/src/pages/Admin.jsx`
- [Training and diagrams](https://github.com/digitalcom-av/av-knowledge-base/blob/main/client/src/pages/Training.jsx): visual content UI · `client/src/pages/Training.jsx`

### Express API

- [API process](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/server.js): Node entry · `server/server.js`
- [Express composition](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/app.js): application server · Configures middleware and mounts versionless /api routes. · `server/src/app.js`
- [API route domains](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/routes/index.js): route aggregation · Auth, categories, articles, search, users, and training endpoints. · `server/src/routes/index.js`
- [Auth and validation](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/middleware/auth.js): middleware · Authentication, validation, and error handling surround requests. · `server/src/middleware/auth.js`
- [Controllers](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/controllers/articles.controller.js): transport handlers · Convert API requests into domain-service calls. · `server/src/controllers/articles.controller.js`
- [Domain services](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/services/articles.service.js): business/query layer · Article and search behavior is isolated from HTTP handlers. · `server/src/services/articles.service.js`
- [Persistence models](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/models/article.model.js): data access · Models access articles, users, and training diagrams. · `server/src/models/article.model.js`

### PostgreSQL Content

- [PostgreSQL](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/config/db.js): system of record · Stores users, categories, articles, tags, and training diagrams. · `server/src/config/db.js`
- [Schema and content provisioning](https://github.com/digitalcom-av/av-knowledge-base/blob/main/server/src/database/setup.js): database setup · Schema, SQL seeds, and imported Markdown provision repeatable content. · `server/src/database/setup.js`

### Other components

- [Railway deployment](https://github.com/digitalcom-av/av-knowledge-base/blob/main/railway.json): deployment config · Vite development proxies /api; deployed origins use configurable CORS. · `railway.json`

## Connections

- Vite SPA bootstrap → Route composition: boots
- Route composition → Dashboard shell: renders protected area
- Route composition → Auth session: uses session guards
- Dashboard shell → Knowledge views: hosts
- Knowledge views → Domain API client: loads content
- Administration UI → Domain API client: manages content and users
- Training and diagrams → Domain API client: loads diagrams
- Domain API client → Express composition: HTTP /api
- API process → Express composition: starts
- Express composition → Auth and validation: applies
- Auth and validation → API route domains: protects requests
- API route domains → Controllers: dispatches
- Controllers → Domain services: delegates
- Domain services → Persistence models: queries and mutates
- Persistence models → PostgreSQL: persists
- Schema and content provisioning → PostgreSQL: initializes and seeds
- Railway deployment → Vite SPA bootstrap: deploys client build
- Railway deployment → API process: deploys API
