# sudokentucky/-sbd1-p1_202100106 architecture

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

- Interactive diagram: https://gitdiagram.com/sudokentucky/-sbd1-p1_202100106
- Repository: https://github.com/sudokentucky/-sbd1-p1_202100106

## Overview

##### Main Components Identification
- API Server: The core of the project resides under the “client” directory, where run.py serves as the entry point. Within “client/app”, the system is modularized into separate submodules for “users”, “products”, “orders”, and “payments”. Each of these modules has its own routes file, and some (like orders) also include additional business logic and database interaction layers.
- Database Layer: The project uses Oracle Database 21c for persisting data. The file “client/utils/db.py” encapsulates the database connectivity logic (using cx_Oracle or the newer oracledb library).
- External Clients: These represent the HTTP clients (via web, mobile, or integration tests) that consume the API endpoints.
- Documentation & Auxiliary Resources: Though not part of runtime, include references to documentation (manuals, Postman collections) as they offer clarity on API usage and behavior.

##### Analyzing the File Structure and Architectural Patterns
- Separation of Concerns: Each major functional area is grouped into its own module inside “client/app” (e.g., users, products, orders, payments). This modular design also registers each module’s routes to the main Flask application (likely through blueprints configured in client/app/__init__.py).
- API Endpoint & Business Logic Separation: For instance, “orders” contains a clear segregation between its HTTP routes (routes.py), business logic (services.py), and database operations (db_operations.py). This indicates adherence to a layered design approach.
- Support Files: Files such as “consultas.sql”, “script.sql”, and “sequences.sql” indicate that there are dedicated SQL scripts for setup or maintenance of the database schema and procedures.

## Diagram (Mermaid)

```mermaid
graph TD
    ExternalClient["External Client (HTTP)"]:::external
    APIServer["Flask API Server"]:::api

    ExternalClient -->|"sends request"| APIServer

    %% Users Module Subgraph
    subgraph "Users Module"
        UsersRoutes["Users Routes"]:::module
        UsersBL["Users Business Logic"]:::business
        UsersDB["Users DB Operations"]:::db_module
        UsersRoutes -->|"calls"| UsersBL
        UsersBL -->|"queries"| UsersDB
    end

    %% Products Module Subgraph
    subgraph "Products Module"
        ProductsRoutes["Products Routes"]:::module
        ProductsBL["Products Business Logic"]:::business
        ProductsDB["Products DB Operations"]:::db_module
        ProductsRoutes -->|"calls"| ProductsBL
        ProductsBL -->|"queries"| ProductsDB
    end

    %% Orders Module Subgraph
    subgraph "Orders Module"
        OrdersRoutes["Orders Routes"]:::module
        OrdersServices["Orders Services"]:::business
        OrdersDB["Orders DB Operations"]:::db_module
        OrdersRoutes -->|"calls"| OrdersServices
        OrdersServices -->|"queries"| OrdersDB
    end

    %% Payments Module Subgraph
    subgraph "Payments Module"
        PaymentsRoutes["Payments Routes"]:::module
        PaymentsBL["Payments Business Logic"]:::business
        PaymentsDB["Payments DB Operations"]:::db_module
        PaymentsRoutes -->|"calls"| PaymentsBL
        PaymentsBL -->|"queries"| PaymentsDB
    end

    %% Connections from API Server to Modules Routes
    APIServer -->|"routes to"| UsersRoutes
    APIServer -->|"routes to"| ProductsRoutes
    APIServer -->|"routes to"| OrdersRoutes
    APIServer -->|"routes to"| PaymentsRoutes

    %% Database Utility and Oracle Database
    DBUtility["DB Connection Utility"]:::util
    OracleDB["Oracle Database"]:::database

    %% All module DB Operations connect to DB Utility
    UsersDB -->|"uses"| DBUtility
    ProductsDB -->|"uses"| DBUtility
    OrdersDB -->|"uses"| DBUtility
    PaymentsDB -->|"uses"| DBUtility

    DBUtility -->|"connects to"| OracleDB

    %% Click Events
    click APIServer "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/run.py"
    click UsersRoutes "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/users/routes.py"
    click UsersDB "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/users/db_users.py"
    click UsersBL "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/users/users.py"
    click ProductsRoutes "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/products/routes.py"
    click ProductsDB "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/products/db_products.py"
    click ProductsBL "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/products/products.py"
    click OrdersRoutes "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/orders/routes.py"
    click OrdersServices "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/orders/services.py"
    click OrdersDB "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/orders/db_operations.py"
    click PaymentsRoutes "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/payments/routes.py"
    click PaymentsDB "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/payments/db_payments.py"
    click PaymentsBL "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/app/payments/payments.py"
    click DBUtility "https://github.com/sudokentucky/-sbd1-p1_202100106/blob/main/client/utils/db.py"

    %% Styles
    classDef external fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef api fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef module fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef business fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef db_module fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef util fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef database fill:#f5b7b1,stroke:#c0392b,stroke-width:2px,stroke-dasharray: 5,5;
```
