How digitalcom-av/av-knowledge-base works
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.js Domain API client · AppRoutes.jsx Route composition · app.js Express composition · railway.json Railway deployment
Components 18
React Client
- Vite SPA bootstrap
client/src/main.jsx - Route composition · Public auth pages and guarded dashboard routes.
client/src/routes/AppRoutes.jsx - Dashboard shell
client/src/layouts/DashboardLayout.jsx - Auth session
client/src/context/AuthContext.jsx - Knowledge views · Dashboard, category, article, and search reading views.
client/src/pages/ArticlePage.jsx - Domain API client · Article and search API modules call the backend.
client/src/api/client.js - Administration UI
client/src/pages/Admin.jsx - Training and diagrams
client/src/pages/Training.jsx
Express API
- API process
server/server.js - Express composition · Configures middleware and mounts versionless /api routes.
server/src/app.js - API route domains · Auth, categories, articles, search, users, and training endpoints.
server/src/routes/index.js - Auth and validation · Authentication, validation, and error handling surround requests.
server/src/middleware/auth.js - Controllers · Convert API requests into domain-service calls.
server/src/controllers/articles.controller.js - Domain services · Article and search behavior is isolated from HTTP handlers.
server/src/services/articles.service.js - Persistence models · Models access articles, users, and training diagrams.
server/src/models/article.model.js
PostgreSQL Content
- PostgreSQL · Stores users, categories, articles, tags, and training diagrams.
server/src/config/db.js - Schema and content provisioning · Schema, SQL seeds, and imported Markdown provision repeatable content.
server/src/database/setup.js
Other components
- Railway deployment · Vite development proxies /api; deployed origins use configurable CORS.
railway.json
Connections 18
- 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