# sayalimkale1209/elabel_docker architecture

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

- Interactive diagram: https://gitdiagram.com/sayalimkale1209/elabel_docker
- Repository: https://github.com/sayalimkale1209/elabel_docker

## Overview

##### Project Type and Purpose
- This is a full-stack Wine Inventory Management System, consisting of a React/Tailwind frontend (client/) and an Express/Node.js backend (server/), with a PostgreSQL database (via Drizzle ORM) and file storage for uploads. It supports user authentication, product & ingredient CRUD, image uploads, and Excel import/export.

##### Main Components
a. Frontend (client/)
- React + TypeScript + Vite application
- UI layer: reusable components (forms, tables, modals, UI primitives)
- Pages: login, register, product/ingredient listings and forms
- Auth & data fetching: custom hooks and supabase.ts (JWT-based auth)
b. Backend (server/)
- Express.js server exposing REST endpoints (/api/auth, /api/products, /api/ingredients)
- Business logic: auth.ts, routes.ts, storage.ts (CRUD + import/export)
- File handling: Multer for image uploads (uploads/ directory)
- Excel processing: XLSX library for import/export
- JWT auth and email confirmation via external SMTP service
c. Database
- PostgreSQL with Drizzle ORM (drizzle.config.ts + shared/schema.ts)
- Tables: users, products, ingredients
d. File Storage
- Local filesystem (uploads/) for product images
e. External Services
- Email SMTP for account confirmation
- (Optional) Supabase if used for real‐time or auth

##### Component Relationships and Data Flow
1. User interacts with the React UI →
2. Frontend issues HTTP(S) requests to Express API →
3. Express routes call storage.ts → Drizzle ORM executes SQL against PostgreSQL
4. File uploads handled by Multer → stored in uploads/ → served via static file endpoint
5. Excel import/export handled in-memory via XLSX → data persisted or streamed back to frontend
6. Auth flows: JWT issued by backend, stored in client; email confirmation via SMTP service

##### Architectural Patterns & Principles
- Separation of concerns: UI vs API vs data layer
- RESTful API design
- Modular folder structure (client/, server/, shared/)
- Shared code (types/schemas in shared/) to guarantee end-to-end type safety
- Environment-driven configuration and containerization (Dockerfile, docker-compose.yml)

##### Essential Details to Capture
- All top-level modules (client/, server/, shared/)
- Key libraries/frameworks (React, Tailwind, Express, Drizzle)
- Data flows: user → UI → API → DB/Storage → UI
- Authentication & authorization path
- Import/export pipelines

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        FE_APP["Frontend Application<br/>(client/)"]:::frontend
        UI_COMP["UI Components<br/>(components/)"]:::frontend
        PAGES["Pages<br/>(pages/)"]:::frontend
        HOOKS["Auth & Data Fetching<br/>(hooks + supabase)"]:::frontend
        ENTRY["Entry Point & Styling"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        API_SERVER["Express API Server<br/>(server/index.ts)"]:::backend
        ROUTES["Route Definitions<br/>(server/routes.ts)"]:::backend
        AUTH_LOGIC["Authentication Logic<br/>(server/auth.ts)"]:::backend
        STORAGE_LOGIC["Storage & Business Logic<br/>(server/storage.ts)"]:::backend
        DB_CONN["DB Connection & ORM Setup<br/>(server/db.ts)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        POSTGRES["PostgreSQL<br/>(Drizzle ORM)"]:::database
        UPLOADS["File Storage<br/>(uploads/)"]:::storage
        SHARED["Shared Utilities & Types<br/>(shared/)"]:::shared
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["Email SMTP Service"]:::external
        SUPABASE["Supabase (Optional)"]:::external
    end

    %% Data Flows
    User["User"]:::user
    User -->|"Interacts via UI"| FE_APP
    FE_APP -->|"HTTPS/JSON"| API_SERVER
    API_SERVER -->|"Routes request"| ROUTES
    ROUTES -->|"Calls auth/storage"| AUTH_LOGIC
    AUTH_LOGIC -->|"JWT Issuance"| FE_APP
    ROUTES -->|"Calls storage"| STORAGE_LOGIC
    STORAGE_LOGIC -->|"SQL via Drizzle ORM"| DB_CONN
    DB_CONN -->|"Queries"| POSTGRES
    STORAGE_LOGIC -->|"Multer uploads"| UPLOADS
    STORAGE_LOGIC -->|"Excel import/export (XLSX)"| FE_APP
    AUTH_LOGIC -->|"Sends email"| SMTP
    FE_APP -->|"Supabase Real-time/Auth"| SUPABASE

    %% Click Events - Frontend
    click FE_APP "https://github.com/sayalimkale1209/elabel_docker/tree/main/client/"
    click UI_COMP "https://github.com/sayalimkale1209/elabel_docker/tree/main/client/src/components/"
    click PAGES "https://github.com/sayalimkale1209/elabel_docker/tree/main/client/src/pages/"
    click HOOKS "https://github.com/sayalimkale1209/elabel_docker/blob/main/client/src/lib/supabase.ts"
    click ENTRY "https://github.com/sayalimkale1209/elabel_docker/blob/main/client/src/main.tsx"

    %% Click Events - Backend
    click API_SERVER "https://github.com/sayalimkale1209/elabel_docker/blob/main/server/index.ts"
    click ROUTES "https://github.com/sayalimkale1209/elabel_docker/blob/main/server/routes.ts"
    click AUTH_LOGIC "https://github.com/sayalimkale1209/elabel_docker/blob/main/server/auth.ts"
    click STORAGE_LOGIC "https://github.com/sayalimkale1209/elabel_docker/blob/main/server/storage.ts"
    click DB_CONN "https://github.com/sayalimkale1209/elabel_docker/blob/main/server/db.ts"

    %% Click Events - Data Layer & Shared
    click POSTGRES "https://github.com/sayalimkale1209/elabel_docker/blob/main/drizzle.config.ts"
    click SHARED "https://github.com/sayalimkale1209/elabel_docker/blob/main/shared/schema.ts"
    click UPLOADS "https://github.com/sayalimkale1209/elabel_docker/tree/main/uploads/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:2px;
    classDef backend fill:#D6F5D6,stroke:#28a745,color:#155724,stroke-width:2px;
    classDef database fill:#FFD8A8,stroke:#de751f,color:#92400e,stroke-width:2px,shape:cylinder;
    classDef storage fill:#FFF3B2,stroke:#facc15,color:#854d0e,stroke-width:2px;
    classDef external fill:#E9D5FF,stroke:#7e22ce,color:#4c1d95,stroke-width:2px;
    classDef shared fill:#FFE4E6,stroke:#be123c,color:#881337,stroke-width:2px;
    classDef user fill:#FFFFFF,stroke:#000000,stroke-width:2px;
    class User user
```
