# edinsoncs/sistema-restaurante architecture

> Architecture diagram of the GitHub repository edinsoncs/sistema-restaurante, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edinsoncs/sistema-restaurante
- Repository: https://github.com/edinsoncs/sistema-restaurante

## Overview

1. **System shape**
   This repository is a **single Node.js/Express monolith** for a restaurant CMS/POS-style system. It is not split into separate services; the browser talks to one server that serves pages, static assets, and feature-specific routes.

2. **Server bootstrap**
   The runtime entry points are `app.js` and `bin/www`. Together they wire up the Express application and start the HTTP server. `app.js` is the central composition point for middleware, routes, views, and authentication.

3. **Route structure**
   Business capabilities are separated into route modules under `routes/`:
   - `panel.js` for the main dashboard
   - `mesas.js` and `copymesas.js` for tables/seat management
   - `pedidos.js` for orders
   - `ventas.js` plus sale-report routes for sales views
   - `admin.js` for administration
   - `users.js`, `validate.js` for access and validation
   - `apipollos.js` for a domain-specific API endpoint
   - `index.js` as the landing/root router

4. **Authentication**
   `passport.js` and `models/local.js` indicate **Passport-based local authentication**. The app likely uses local credential checking for login and session-based access control across admin and operational screens. `routes/users.js` and `routes/validate.js` are part of that access flow.

5. **Server-rendered UI**
   The UI is rendered with **Jade/Pug templates** in `views/`. `views/layout.jade` provides the shared shell, while pages like `panel.jade`, `mesas.jade`, `pedidos.jade`, `admin.jade`, and the sales/report views form the main screens. This suggests a traditional server-rendered app with page-specific client enhancement.

6. **Frontend behavior**
   The `public/javascripts/` folder contains feature-focused browser code:
   - `mesaslist.js`, `deleteMesas.js`, `copiamesas.js` for table workflows
   - `platos.js`, `stock.js` for menu/inventory operations
   - `ventas.js`, `ventasefectivo.js`, `ventastarjetas.js`, `ventasmensual.js` for sales and reporting
   - `app.js`, `appadmin.js`, `web.js` as broader UI controllers
   - jQuery plugins such as `jquery.cookie.js` and `jquery.hideseek.js`

7. **Static asset layer**
   CSS, fonts, and images are served from `public/`. The styles are organized by feature: `mesas`, `menu`, `salon`, `reporte`, `administracion`, `print`, `notify`, etc. FontAwesome assets are included for iconography. This separation implies distinct screens with their own presentation concerns.

8. **Build/authoring workflow**
   The repo keeps both source-style and compiled assets. Many `.scss` files sit next to generated `.css` files, and there are `prepros.cfg` files plus `webpack-config.js`. That points to a frontend build pipeline for compiling SCSS and bundling or managing client scripts, even though the app itself runs as a server-rendered Node project.

9. **Alternative/legacy frontend area**
   The `aplicacion/` directory looks like a parallel or older frontend bundle containing its own `index.html`, `js/`, `css/`, fonts, and images. Architecturally, treat this as a separate static UI workspace or a prior iteration of the front-end, not the main Express app entrypoint.

10. **Primary data flow**
   Typical flow is: browser requests a route → Express route handler prepares data or checks auth → Jade template renders the page → feature-specific JavaScript in `public/javascripts/` performs interactions and updates the UI. For operational screens like tables, orders, and sales, the client scripts appear to drive most interactivity after initial page load.

11. **Functional domains**
   The repository centers on restaurant operations:
   - table management
   - orders
   - menu/dishes
   - stock
   - sales reporting
   - administrative panels
   The naming of the routes and views makes these the key bounded areas for any diagram.

12. **External dependencies and boundaries**
   No external backend services are evident in the tree. The main external-facing boundary is the browser, which consumes server-rendered pages plus static JS/CSS, while authentication is handled locally through Passport. The architecture is therefore best diagrammed as a **single server with a static asset layer and multiple feature routes**.

Main entry points: [`app.js`](https://github.com/edinsoncs/sistema-restaurante/blob/master/app.js) (Express app), [`views/panel.jade`](https://github.com/edinsoncs/sistema-restaurante/blob/master/views/panel.jade) (Main screens), [`bin/www`](https://github.com/edinsoncs/sistema-restaurante/tree/master/bin/www) (HTTP start), [`passport.js`](https://github.com/edinsoncs/sistema-restaurante/blob/master/passport.js) (Passport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_bin_www["HTTP start<br/>server entry"]
  node_app_js["Express app<br/>app composition<br/>[app.js]"]
end

subgraph group_auth["Auth"]
  node_passport_js["Passport<br/>auth config<br/>[passport.js]"]
  node_local_model["Local auth<br/>auth model<br/>[local.js]"]
end

subgraph group_routes["Routes"]
  node_index_route["Home<br/>root route<br/>[index.js]"]
  node_panel_route["Panel<br/>dashboard route<br/>[panel.js]"]
  node_mesas_route["Mesas<br/>tables route<br/>[mesas.js]"]
  node_copymesas_route["Copy mesas<br/>tables helper route<br/>[copymesas.js]"]
  node_pedidos_route["Pedidos<br/>orders route<br/>[pedidos.js]"]
  node_ventas_route["Ventas<br/>sales route<br/>[ventas.js]"]
  node_admin_route["Admin<br/>[admin.js]"]
  node_users_route["Users<br/>access route<br/>[users.js]"]
  node_validate_route["Validate<br/>access route<br/>[validate.js]"]
  node_apipollos_route["API pollos<br/>domain api<br/>[apipollos.js]"]
end

subgraph group_views["Views"]
  node_layout_view["Layout<br/>base template<br/>[layout.jade]"]
  node_main_views["Main screens<br/>templates<br/>[panel.jade]"]
  node_sales_views["Sales views<br/>templates<br/>[ventas.jade]"]
end

subgraph group_public["Public"]
  node_public_assets["Assets<br/>static files<br/>[style.css]"]
  node_client_js["Client JS<br/>browser scripts<br/>[app.js]"]
end

subgraph group_legacy["Legacy UI"]
  node_legacy_ui["Legacy UI<br/>static frontend<br/>[index.html]"]
end

node_browser(("Browser<br/>client"))

node_browser -->|"requests"| node_bin_www
node_bin_www -->|"boots"| node_app_js
node_app_js -->|"uses"| node_passport_js
node_passport_js -->|"delegates"| node_local_model
node_app_js -->|"mounts"| node_index_route
node_app_js -->|"mounts"| node_panel_route
node_app_js -->|"mounts"| node_mesas_route
node_app_js -->|"mounts"| node_copymesas_route
node_app_js -->|"mounts"| node_pedidos_route
node_app_js -->|"mounts"| node_ventas_route
node_app_js -->|"mounts"| node_admin_route
node_app_js -->|"mounts"| node_users_route
node_app_js -->|"mounts"| node_validate_route
node_app_js -->|"mounts"| node_apipollos_route
node_app_js -->|"renders"| node_layout_view
node_panel_route -->|"renders"| node_main_views
node_mesas_route -->|"renders"| node_main_views
node_pedidos_route -->|"renders"| node_main_views
node_ventas_route -->|"renders"| node_sales_views
node_app_js -->|"serves"| node_public_assets
node_app_js -->|"serves"| node_client_js
node_client_js -->|"runs in"| node_browser
node_legacy_ui -.->|"served to"| node_browser

click node_bin_www "https://github.com/edinsoncs/sistema-restaurante/tree/master/bin/www"
click node_app_js "https://github.com/edinsoncs/sistema-restaurante/blob/master/app.js"
click node_passport_js "https://github.com/edinsoncs/sistema-restaurante/blob/master/passport.js"
click node_local_model "https://github.com/edinsoncs/sistema-restaurante/blob/master/models/local.js"
click node_index_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/index.js"
click node_panel_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/panel.js"
click node_mesas_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/mesas.js"
click node_copymesas_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/copymesas.js"
click node_pedidos_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/pedidos.js"
click node_ventas_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/ventas.js"
click node_admin_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/admin.js"
click node_users_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/users.js"
click node_validate_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/validate.js"
click node_apipollos_route "https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/apipollos.js"
click node_layout_view "https://github.com/edinsoncs/sistema-restaurante/blob/master/views/layout.jade"
click node_main_views "https://github.com/edinsoncs/sistema-restaurante/blob/master/views/panel.jade"
click node_sales_views "https://github.com/edinsoncs/sistema-restaurante/blob/master/views/ventas.jade"
click node_public_assets "https://github.com/edinsoncs/sistema-restaurante/blob/master/public/stylesheets/style.css"
click node_client_js "https://github.com/edinsoncs/sistema-restaurante/blob/master/public/javascripts/app.js"
click node_legacy_ui "https://github.com/edinsoncs/sistema-restaurante/blob/master/aplicacion/index.html"

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_bin_www,node_app_js toneBlue
class node_passport_js,node_local_model toneAmber
class node_index_route,node_panel_route,node_mesas_route,node_copymesas_route,node_pedidos_route,node_ventas_route,node_admin_route,node_users_route,node_validate_route,node_apipollos_route toneMint
class node_layout_view,node_main_views,node_sales_views toneRose
class node_public_assets,node_client_js toneIndigo
class node_legacy_ui toneTeal
class node_browser toneNeutral
```

## Components

### Runtime

Express app startup and composition

- [HTTP start](https://github.com/edinsoncs/sistema-restaurante/tree/master/bin/www): server entry · Starts the HTTP server · `bin/www`
- [Express app](https://github.com/edinsoncs/sistema-restaurante/blob/master/app.js): app composition · Main Express configuration and middleware wiring · `app.js`

### Auth

Local authentication and session flow

- [Passport](https://github.com/edinsoncs/sistema-restaurante/blob/master/passport.js): auth config · Passport strategy and session setup · `passport.js`
- [Local auth](https://github.com/edinsoncs/sistema-restaurante/blob/master/models/local.js): auth model · Local credential checking model · `models/local.js`

### Routes

Feature route modules

- [Home](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/index.js): root route · Landing and default routing · `routes/index.js`
- [Panel](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/panel.js): dashboard route · Main operational dashboard routes · `routes/panel.js`
- [Mesas](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/mesas.js): tables route · Table and seat management routes · `routes/mesas.js`
- [Copy mesas](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/copymesas.js): tables helper route · Table copy/duplicate workflow routes · `routes/copymesas.js`
- [Pedidos](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/pedidos.js): orders route · Order entry and management routes · `routes/pedidos.js`
- [Ventas](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/ventas.js): sales route · Sales and reporting routes · `routes/ventas.js`
- [Admin](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/admin.js): admin route · Administration screens and controls · `routes/admin.js`
- [Users](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/users.js): access route · User login and access flow routes · `routes/users.js`
- [Validate](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/validate.js): access route · Validation and verification routes · `routes/validate.js`
- [API pollos](https://github.com/edinsoncs/sistema-restaurante/blob/master/routes/apipollos.js): domain api · Specialized domain API endpoint · `routes/apipollos.js`

### Views

Server-rendered Jade templates

- [Layout](https://github.com/edinsoncs/sistema-restaurante/blob/master/views/layout.jade): base template · Shared Jade shell for pages · `views/layout.jade`
- [Main screens](https://github.com/edinsoncs/sistema-restaurante/blob/master/views/panel.jade): templates · Primary operational pages and reports · `views/panel.jade`
- [Sales views](https://github.com/edinsoncs/sistema-restaurante/blob/master/views/ventas.jade): templates · Sales and reporting pages · `views/ventas.jade`

### Public

Static assets and browser scripts

- [Assets](https://github.com/edinsoncs/sistema-restaurante/blob/master/public/stylesheets/style.css): static files · CSS, fonts, images, and compiled client assets · `public/stylesheets/style.css`
- [Client JS](https://github.com/edinsoncs/sistema-restaurante/blob/master/public/javascripts/app.js): browser scripts · Feature scripts for tables, orders, sales, and admin · `public/javascripts/app.js`

### Legacy UI

Parallel static frontend workspace

- [Legacy UI](https://github.com/edinsoncs/sistema-restaurante/blob/master/aplicacion/index.html): static frontend · Parallel standalone frontend workspace · `aplicacion/index.html`

### Other components

- **Browser**: client · User-facing browser consuming pages and assets

## Connections

- Browser → HTTP start: requests · Browser reaches the Node server
- HTTP start → Express app: boots · Server entry loads the Express application
- Express app → Passport: uses · App wires authentication configuration
- Passport → Local auth: delegates · Passport local strategy checks credentials
- Express app → Home: mounts · Root routing is registered in the app
- Express app → Panel: mounts · Dashboard routes are registered
- Express app → Mesas: mounts · Table routes are registered
- Express app → Copy mesas: mounts · Copy-table routes are registered
- Express app → Pedidos: mounts · Order routes are registered
- Express app → Ventas: mounts · Sales routes are registered
- Express app → Admin: mounts · Administration routes are registered
- Express app → Users: mounts · Access routes are registered
- Express app → Validate: mounts · Validation routes are registered
- Express app → API pollos: mounts · Domain API route is registered
- Express app → Layout: renders · Express uses the shared layout and templates
- Panel → Main screens: renders · Dashboard routes render operational screens
- Mesas → Main screens: renders · Table routes render the table screens
- Pedidos → Main screens: renders · Order routes render order screens
- Ventas → Sales views: renders · Sales routes render report and totals pages
- Express app → Assets: serves · Static styles, fonts, and images are exposed
- Express app → Client JS: serves · Client-side scripts are delivered by the app
- Client JS → Browser: runs in · Feature scripts enhance server-rendered pages
- Legacy UI → Browser: served to · Standalone legacy static UI can be opened directly
