# leumas13/practica3_psp_damb architecture

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

- Interactive diagram: https://gitdiagram.com/leumas13/practica3_psp_damb
- Repository: https://github.com/leumas13/practica3_psp_damb

## Overview

##### Project Type and Purpose
- This is a chat application that demonstrates networking concepts and concurrent programming practices.
- There are two implementations:
- chatTCP: A TCP-based chat system that leverages multi-threading (note the HiloServidor.java) to handle client connections.
- chatUDP: A UDP-based chat system which uses a connectionless protocol for messaging.
- The simplicity of the README (“# practica3_PSP_DAMB”) hints that it is likely for educational or practice purposes in a “PSP” (Programming of System Processes) context.

##### File Structure
- Top-Level Organization:
- Two main directories: chatTCP and chatUDP, each with its own .gitignore, .idea, and project files.
- Under each project’s “src” folder:
- “cliente”: Contains the client-side code (Cliente.java) and its associated UI form (Cliente.form). This likely represents the chat user interface.
- “servidor”: Contains the server-side code (Servidor.java) that listens for incoming connections.
- “data”: Contains shared data models (Conversacion.java and Usuario.java) that are used to represent chat conversations and user information.
- Additionally, chatTCP contains a “hilos” (threads) directory with HiloServidor.java, which indicates that the TCP version uses multi-threading to handle multiple connections concurrently.

##### Extracting Architectural Insights
- Main Components:
- Client Module: Handles user input through a GUI (likely implemented with a form). Located under “cliente” directories in both implementations.
- Server Module: Listens for and processes incoming messages from clients. The TCP version uses a dedicated thread (HiloServidor) to manage client sessions.
- Data Models: Provides a shared structure for chat data (users and conversations) used by both clients and servers.
- Communication Flow:
- In both versions, a client sends messages to a server. The TCP implementation manages a persistent connection using threads, whereas the UDP implementation deals with stateless messaging.
- Architectural Patterns:
- Separation of Concerns: The project separates the client, server, and data layers.
- Concurrency: The TCP version leverages multi-threading for simultaneous client handling.
- Relevant Technologies:
- Java is the programming language, with potential use of Swing or similar frameworks for the UI forms.
- Networking libraries for TCP/UDP communication, along with standard Java threading for handling multiple clients concurrently.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "ChatTCP System"
        direction TB
        TCP_Client_Logic["ChatTCP Client (Logic)"]:::client
        TCP_Client_UI["ChatTCP Client (UI)"]:::client
        TCP_Server["ChatTCP Server"]:::server
        TCP_Data_Conversacion["ChatTCP Data: Conversacion"]:::data
        TCP_Data_Usuario["ChatTCP Data: Usuario"]:::data
        TCP_HiloServidor["HiloServidor (Thread Manager)"]:::thread
    end

    subgraph "ChatUDP System"
        direction TB
        UDP_Client_Logic["ChatUDP Client (Logic)"]:::client
        UDP_Client_UI["ChatUDP Client (UI)"]:::client
        UDP_Server["ChatUDP Server"]:::server
        UDP_Data_Conversacion["ChatUDP Data: Conversacion"]:::data
        UDP_Data_Usuario["ChatUDP Data: Usuario"]:::data
    end

    %% ChatTCP Relationships
    TCP_Client_Logic -->|"sendsMessage"| TCP_Server
    TCP_Client_UI -->|"triggersLogic"| TCP_Client_Logic
    TCP_Server -->|"dispatchesThread"| TCP_HiloServidor
    TCP_Server -->|"usesData"| TCP_Data_Conversacion
    TCP_Server -->|"usesData"| TCP_Data_Usuario
    TCP_Server -->|"respondsTo"| TCP_Client_UI

    %% ChatUDP Relationships
    UDP_Client_Logic -->|"sendsMessage"| UDP_Server
    UDP_Client_UI -->|"triggersLogic"| UDP_Client_Logic
    UDP_Server -->|"usesData"| UDP_Data_Conversacion
    UDP_Server -->|"usesData"| UDP_Data_Usuario
    UDP_Server -->|"respondsTo"| UDP_Client_UI

    %% Click Events for ChatTCP
    click TCP_Client_Logic "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/cliente/Cliente.java"
    click TCP_Client_UI "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/cliente/Cliente.form"
    click TCP_Server "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/servidor/Servidor.java"
    click TCP_Data_Conversacion "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/data/Conversacion.java"
    click TCP_Data_Usuario "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/data/Usuario.java"
    click TCP_HiloServidor "https://github.com/leumas13/practica3_psp_damb/blob/main/chatTCP/src/hilos/HiloServidor.java"

    %% Click Events for ChatUDP
    click UDP_Client_Logic "https://github.com/leumas13/practica3_psp_damb/blob/main/chatUDP/src/cliente/Cliente.java"
    click UDP_Client_UI "https://github.com/leumas13/practica3_psp_damb/blob/main/chatUDP/src/cliente/Cliente.form"
    click UDP_Server "https://github.com/leumas13/practica3_psp_damb/blob/main/chatUDP/src/servidor/Servidor.java"
    click UDP_Data_Conversacion "https://github.com/leumas13/practica3_psp_damb/blob/main/chatUDP/src/data/Conversacion.java"
    click UDP_Data_Usuario "https://github.com/leumas13/practica3_psp_damb/blob/main/chatUDP/src/data/Usuario.java"

    %% Styles
    classDef client fill:#a1d99b,stroke:#333,stroke-width:2px;
    classDef server fill:#9ecae1,stroke:#333,stroke-width:2px;
    classDef data fill:#fdae6b,stroke:#333,stroke-width:2px;
    classDef thread fill:#fdd0a2,stroke:#333,stroke-width:2px;
```
