# lfsmariz/projeto-integrador-transdisciplinar architecture

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

- Interactive diagram: https://gitdiagram.com/lfsmariz/projeto-integrador-transdisciplinar
- Repository: https://github.com/lfsmariz/projeto-integrador-transdisciplinar

## Overview

##### Main System Components

A. Frontend Layer
- Static Web Pages (HTML/CSS)
- Client-side JavaScript
- Express Server (frontend/server.js)

B. Backend Layer
- API Server (Express)
- Business Logic (usecases)
- Data Access Layer (repository)
- Database (PostgreSQL)

##### Detailed Component Breakdown

Frontend Components (Top Layer):
- Web Pages (login, register, cart, product details)
- Static Assets (styles, scripts, images)
- Frontend Server (Express static file server)

Backend Components (Middle & Bottom Layers):
- API Routes Layer (userRoutes, productRoutes, cartRoutes, orderRoutes)
- Business Logic Layer (usecases)
- Data Access Layer (repository)
- Database Layer (PostgreSQL)

##### Connection Flows

- Client Browser → Frontend Server (HTTP/HTTPS)
- Frontend Server → Backend API (REST API calls)
- Backend API → Business Logic → Data Access Layer → Database

##### Specific Implementation Details

Frontend Section:
**┌─ Frontend Layer ─────────────────┐**
- ┌─ Web Pages ─────┐ ┌─ Assets ─┐ │
- index.html    │ │ - CSS    │ │
- login.html    │ │ - JS     │ │
- register.html │ │ - Images │ │
- cart.html     │ └─────────┘ │
- ┘              │
- ┘

Backend Section:
**┌─ Backend Layer ──────────────────┐**
- ┌─ API Routes ─────────────────┐ │
- User   - Product          │ │
- Cart   - Order            │ │
- ┘ │
- ┌─ Business Logic (Usecases) ──┐ │
- User   - Product          │ │
- Cart   - Order            │ │
- ┘ │
- ┌─ Data Access (Repository) ───┐ │
- User   - Product          │ │
- Cart   - Order            │ │
- ┘ │
- ┘

##### Additional Elements

- Docker containers (show Docker composition)
- Test coverage scope
- External service integrations (if any)
- Security layers (authentication/authorization)
- Cache layers (if implemented)

##### Important Architectural Patterns to Highlight

- Clean Architecture pattern (shown in the backend structure with usecases and repository layers)
- MVC pattern in the frontend organization
- Repository pattern for data access
- REST API architecture for communication

##### Technical Stack Callouts

- Node.js/Express (Backend framework)
- PostgreSQL (Database)
- Sequelize (ORM)
- Jest (Testing framework)
- Docker (Containerization)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend
        direction TB
        FServer["Frontend Server"]:::server
        click FServer "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/server.js"
        
        subgraph WebPages
            direction TB
            Index["index.html"]:::webpage
            Login["login.html"]:::webpage
            Register["register.html"]:::webpage
            Cart["cart.html"]:::webpage
            Detail["detail.html"]:::webpage
            click Index "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/index.html"
            click Login "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/login.html"
            click Register "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/register.html"
            click Cart "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/cart.html"
            click Detail "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/detail.html"
        end

        subgraph ClientJS
            direction TB
            IndexJS["index.js"]:::script
            LoginJS["login.js"]:::script
            RegisterJS["register.js"]:::script
            CartJS["cart.js"]:::script
            DetailJS["detail.js"]:::script
            click IndexJS "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/scripts/index.js"
            click LoginJS "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/scripts/login.js"
            click RegisterJS "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/scripts/register.js"
            click CartJS "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/scripts/cart.js"
            click DetailJS "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/frontend/public/scripts/detail.js"
        end

        subgraph StaticAssets
            direction TB
            Styles["CSS Styles"]:::asset
            Images["Images"]:::asset
            click Styles "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/tree/main/frontend/public/styles/"
            click Images "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/tree/main/frontend/public/images/"
        end
    end

    subgraph Backend
        direction TB
        subgraph APIRoutes
            direction TB
            UserRoutes["User Routes"]:::api
            ProductRoutes["Product Routes"]:::api
            CartRoutes["Cart Routes"]:::api
            OrderRoutes["Order Routes"]:::api
            click UserRoutes "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/routes/userRoutes.js"
            click ProductRoutes "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/routes/productRoutes.js"
            click CartRoutes "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/routes/cartRoutes.js"
            click OrderRoutes "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/routes/orderRoutes.js"
        end

        subgraph BusinessLogic
            direction TB
            UserLogic["User Usecase"]:::logic
            ProductLogic["Product Usecase"]:::logic
            CartLogic["Cart Usecase"]:::logic
            OrderLogic["Order Usecase"]:::logic
            click UserLogic "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/usecases/user.js"
            click ProductLogic "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/usecases/product.js"
            click CartLogic "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/usecases/cart.js"
            click OrderLogic "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/usecases/order.js"
        end

        subgraph DataAccess
            direction TB
            UserRepo["User Repository"]:::repo
            ProductRepo["Product Repository"]:::repo
            CartRepo["Cart Repository"]:::repo
            OrderRepo["Order Repository"]:::repo
            DBConn["Database Connection"]:::repo
            click UserRepo "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/repository/user.js"
            click ProductRepo "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/repository/product.js"
            click CartRepo "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/repository/cart.js"
            click OrderRepo "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/repository/order.js"
            click DBConn "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/repository/conn.js"
        end
    end

    subgraph Infrastructure
        direction TB
        Docker["Docker Container"]:::infra
        PostgreSQL["PostgreSQL Database"]:::db
        click Docker "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/docker-compose.yml"
    end

    subgraph Testing
        direction TB
        UserTest["User Tests"]:::test
        ProductTest["Product Tests"]:::test
        CartTest["Cart Tests"]:::test
        OrderTest["Order Tests"]:::test
        click UserTest "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/test/usecases/user.test.js"
        click ProductTest "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/test/usecases/product.test.js"
        click CartTest "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/test/usecases/cart.test.js"
        click OrderTest "https://github.com/lfsmariz/projeto-integrador-transdisciplinar/blob/main/backend/test/usecases/order.test.js"
    end

    %% Connections
    Browser <--> FServer
    FServer <--> APIRoutes
    APIRoutes <--> BusinessLogic
    BusinessLogic <--> DataAccess
    DataAccess <--> PostgreSQL
    Testing -.-> BusinessLogic

    %% Styles
    classDef webpage fill:#E1F5FE,stroke:#0288D1
    classDef script fill:#E8F5E9,stroke:#388E3C
    classDef asset fill:#FFF3E0,stroke:#F57C00
    classDef server fill:#E8EAF6,stroke:#3F51B5
    classDef api fill:#F3E5F5,stroke:#9C27B0
    classDef logic fill:#E1BEE7,stroke:#7B1FA2
    classDef repo fill:#FFE0B2,stroke:#FF9800
    classDef db fill:#D1C4E9,stroke:#673AB7
    classDef infra fill:#B2DFDB,stroke:#00796B
    classDef test fill:#FFCDD2,stroke:#D32F2F
```
