# plmanuel/ordernet architecture

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

- Interactive diagram: https://gitdiagram.com/plmanuel/ordernet
- Repository: https://github.com/plmanuel/ordernet

## Overview

##### Project type and purpose
- This is a full-stack web application built with Astro (a static-and-SSR site generator) plus React/TSX components and a set of built-in API routes under `src/pages/api`.
- Judging by the pages (`login.astro`, `usuarios.astro`, `catalogo.astro`, `pedidos.astro`) and API endpoints (`category`, `product`, `table`, `user`), it appears to be a restaurant or inventory/order management dashboard.

##### File structure
- Top-level config:
- `astro.config.mjs`, `tsconfig.json`, `package.json`, `pnpm-workspace.yaml`
- Public assets: `public/imgs`, CSS under `src/styles/global.css`
- Frontend:
- `src/pages/` holds your route files (`.astro` pages)
- `src/components/` contains React/TSX UI pieces (tables, modals, forms) and some Astro components (`.astro`) for layouts/navigation
- `src/layouts/` defines the page shells (`Layout.astro`, `LayoutDashboard.astro`)
- Backend/API:
- `src/pages/api/` implements RESTful routes for auth (`login`, `logout`, `refresh-token`) and CRUD on `category`, `product`, `table`, `user`
- `src/lib/` houses cross-cutting utilities for auth cookies and authenticated fetches
- No explicit ORM or DB code is visible, but the API layer presumably calls a database or external service.

##### README
- We’ll augment with the actual structure above to reflect our real components and services.

##### Detailed breakdown of components/subsystems
- Frontend:
- Layouts (`Layout.astro`, `LayoutDashboard.astro`)
- Pages (`index.astro`, `login.astro`, `usuarios.astro`, etc.)
- Components (CatalogGrid, ProductCard, tables, modals, forms)
- Auth Library:
- `setAuthCookies.ts`, `clearAuthCookies.ts`
- `fetchWithAuth.ts` (wraps fetch with token, handles refresh)
- API Endpoints: group them by resource (Auth, Category, Product, Table, User)
- Data Store: tables/collections for users, products, categories, tables, orders

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser + Astro)" 
        direction TB
        Browser["User Browser"]:::external
        CDN["CDN / Static Host"]:::external
        subgraph "Astro Server" 
            direction TB
            Layouts["Layouts"]:::frontend
            Pages["Pages"]:::frontend
            Components["UI Components"]:::frontend
            Styles["Global CSS"]:::frontend
            Images["Public Images"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Node.js API)" 
        direction TB
        AuthLib["Auth Library"]:::auth
        subgraph "API Endpoints" 
            direction TB
            AuthAPI["Auth Routes"]:::backend
            CategoryAPI["Category Routes"]:::backend
            ProductAPI["Product Routes"]:::backend
            TableAPI["Table Routes"]:::backend
            UserAPI["User Routes"]:::backend
        end
        DB["Database"]:::db
    end

    %% Flows
    Browser -->|loads| CDN
    Browser -->|requests SSR| AstroServer["Astro Server"]:::frontend
    AstroServer -->|serves pages & assets| Browser
    Browser -->|API calls| AuthAPI
    Browser -->|API calls| CategoryAPI
    Browser -->|API calls| ProductAPI
    Browser -->|API calls| TableAPI
    Browser -->|API calls| UserAPI
    AuthAPI -->|uses| AuthLib
    CategoryAPI -->|queries| DB
    ProductAPI -->|queries| DB
    TableAPI -->|queries| DB
    UserAPI -->|queries| DB

    %% Click events - Layouts
    click Layouts "https://github.com/plmanuel/ordernet/blob/main/src/layouts/Layout.astro"
    click Layouts "https://github.com/plmanuel/ordernet/blob/main/src/layouts/LayoutDashboard.astro"

    %% Click events - Pages
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/index.astro"
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/login.astro"
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/usuarios.astro"
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/catalogo.astro"
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/pedidos.astro"
    click Pages "https://github.com/plmanuel/ordernet/blob/main/src/pages/ajustes.astro"

    %% Click events - Components
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/CatalogGrid.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/ProductCard.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/CategoriesTable.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/TablesList.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UsersTable.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/CategoryCreateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/ProductCreateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/ProductUpdateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/TableCreateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UserCreateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UserUpdateModal.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/LoginForm.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/LogoutButton.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/Sidebar.astro"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UserSection.astro"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UserInfo.tsx"
    click Components "https://github.com/plmanuel/ordernet/blob/main/src/components/UserDeleteButton.tsx"

    %% Click events - Auth Library
    click AuthLib "https://github.com/plmanuel/ordernet/blob/main/src/lib/setAuthCookies.ts"
    click AuthLib "https://github.com/plmanuel/ordernet/blob/main/src/lib/clearAuthCookies.ts"
    click AuthLib "https://github.com/plmanuel/ordernet/blob/main/src/lib/fetchWithAuth.ts"

    %% Click events - API Endpoints
    click AuthAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/auth/login.ts"
    click AuthAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/auth/logout.ts"
    click AuthAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/auth/refresh-token.ts"
    click CategoryAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/category/create.ts"
    click CategoryAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/category/getAll.ts"
    click CategoryAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/category/update.ts"
    click CategoryAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/category/delete.ts"
    click CategoryAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/category/[id].ts"
    click ProductAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/product/create.ts"
    click ProductAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/product/getAll.ts"
    click ProductAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/product/update.ts"
    click ProductAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/product/delete.ts"
    click ProductAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/product/[id].ts"
    click TableAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/table/create.ts"
    click TableAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/table/getAll.ts"
    click TableAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/table/delete.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/create.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/getAll.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/getMyUser.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/update.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/delete.ts"
    click UserAPI "https://github.com/plmanuel/ordernet/blob/main/src/pages/api/user/[id].ts"

    %% Click events - Styles & Images & Types
    click Styles "https://github.com/plmanuel/ordernet/blob/main/src/styles/global.css"
    click Images "https://github.com/plmanuel/ordernet/tree/main/public/imgs/"
    click DB "https://github.com/plmanuel/ordernet/blob/main/src/types/catalog.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef auth fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
