# y4g2s7/proyecto1mypchat architecture

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

- Interactive diagram: https://gitdiagram.com/y4g2s7/proyecto1mypchat
- Repository: https://github.com/y4g2s7/proyecto1mypchat

## Overview

Proyecto1MyPChat is a console-based, multi-user chat with a C# client and a concurrent C TCP server. The main workflow is: a user connects and identifies, issues chat or room commands, the client encodes newline-delimited JSON, and the server dispatches requests and sends replies or broadcasts. The client also supports status changes, user lists, private/public messages, room creation, invitations, joining, room lists/messages, leaving, and disconnecting. Server internals beyond the supplied excerpts are represented only where the tree or excerpts support them.

Main entry points: [`CLIENTE/Cliente/Controlador/ControladorCliente.cs`](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/ControladorCliente.cs) (Client controller), [`SERVIDOR/Servidor/SocketServidor.c`](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/SocketServidor.c) (Server sockets), [`CLIENTE/Cliente/Modelo/SocketCliente.cs`](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/SocketCliente.cs) (Client socket), [`CLIENTE/Cliente/Controlador/IndicacionesCliente.cs`](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/IndicacionesCliente.cs) (Command mapping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Console client"]
  node_client_entry["Client entry<br/>[Cliente.cs]"]
  node_controller["Client controller"]
  node_console["Console view<br/>[VistaConsola.cs]"]
  node_commands["Command mapping"]
  node_client_socket["Client socket<br/>[SocketCliente.cs]"]
end

subgraph group_wire["Message protocol"]
  node_client_json["JSON builder"]
  node_client_read["JSON reader<br/>[LecturaJson.cs]"]
  node_json_types["JSON formatting<br/>[TiposDeJson.c]"]
end

subgraph group_server["Server runtime"]
  node_server_socket["Server sockets<br/>[SocketServidor.c]"]
  node_dispatch["Request dispatch"]
end

subgraph group_domain["Chat state"]
  node_users[("User registry<br/>[ListaDeUsuarios.c]")]
  node_rooms[("Room state<br/>[Salas.c]")]
end

node_user(("Chat user"))
node_tcp(("TCP clients"))

node_user -->|"starts"| node_client_entry
node_client_entry -->|"starts"| node_controller
node_controller -->|"prompts/displays"| node_console
node_controller -->|"maps commands"| node_commands
node_commands -->|"reads details"| node_console
node_commands -->|"builds requests"| node_client_json
node_controller -->|"connects/sends"| node_client_socket
node_commands -->|"sends user lists"| node_client_socket
node_client_socket -->|"opens TCP"| node_tcp
node_tcp -->|"carries messages"| node_server_socket
node_server_socket -->|"dispatches requests"| node_dispatch
node_dispatch -->|"reads/updates users"| node_users
node_dispatch -->|"manages rooms"| node_rooms
node_dispatch -->|"formats replies"| node_json_types
node_server_socket -->|"formats invalid reply"| node_json_types
node_server_socket -->|"returns replies"| node_client_socket
node_client_socket -->|"emits messages"| node_controller
node_controller -->|"parses responses"| node_client_read
node_controller -->|"shows translated replies"| node_console
node_server_socket -->|"cleans up disconnects"| node_users
node_server_socket -->|"cleans up memberships"| node_rooms

click node_client_entry "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/Cliente.cs"
click node_controller "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/ControladorCliente.cs"
click node_console "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Vista/VistaConsola.cs"
click node_commands "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/IndicacionesCliente.cs"
click node_client_socket "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/SocketCliente.cs"
click node_client_json "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/ConstruccionJson.cs"
click node_client_read "https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/LecturaJson.cs"
click node_server_socket "https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/SocketServidor.c"
click node_dispatch "https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/IndicacionesServidor.c"
click node_json_types "https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/TiposDeJson.c"
click node_users "https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/ListaDeUsuarios.c"
click node_rooms "https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/Salas.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_entry,node_controller,node_console,node_commands,node_client_socket,node_user,node_tcp toneBlue
class node_client_json,node_client_read,node_json_types toneAmber
class node_server_socket,node_dispatch toneMint
class node_users,node_rooms toneRose
```

## Components

### Console client

- [Client entry](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/Cliente.cs): `CLIENTE/Cliente/Controlador/Cliente.cs`
- [Client controller](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/ControladorCliente.cs): `CLIENTE/Cliente/Controlador/ControladorCliente.cs`
- [Console view](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Vista/VistaConsola.cs): `CLIENTE/Cliente/Vista/VistaConsola.cs`
- [Command mapping](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Controlador/IndicacionesCliente.cs): `CLIENTE/Cliente/Controlador/IndicacionesCliente.cs`
- [Client socket](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/SocketCliente.cs): `CLIENTE/Cliente/Modelo/SocketCliente.cs`

### Message protocol

- [JSON builder](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/ConstruccionJson.cs): `CLIENTE/Cliente/Modelo/ConstruccionJson.cs`
- [JSON reader](https://github.com/y4g2s7/proyecto1mypchat/blob/main/CLIENTE/Cliente/Modelo/LecturaJson.cs): `CLIENTE/Cliente/Modelo/LecturaJson.cs`
- [JSON formatting](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/TiposDeJson.c): `SERVIDOR/Servidor/TiposDeJson.c`

### Server runtime

- [Server sockets](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/SocketServidor.c): `SERVIDOR/Servidor/SocketServidor.c`
- [Request dispatch](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/IndicacionesServidor.c): `SERVIDOR/Servidor/IndicacionesServidor.c`

### Chat state

- [User registry](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/ListaDeUsuarios.c): `SERVIDOR/Servidor/ListaDeUsuarios.c`
- [Room state](https://github.com/y4g2s7/proyecto1mypchat/blob/main/SERVIDOR/Servidor/Salas.c): `SERVIDOR/Servidor/Salas.c`

### Other components

- **Chat user**
- **TCP clients**

## Connections

- Chat user → Client entry: starts
- Client entry → Client controller: starts
- Client controller → Console view: prompts/displays
- Client controller → Command mapping: maps commands
- Command mapping → Console view: reads details
- Command mapping → JSON builder: builds requests
- Client controller → Client socket: connects/sends
- Command mapping → Client socket: sends user lists
- Client socket → TCP clients: opens TCP
- TCP clients → Server sockets: carries messages
- Server sockets → Request dispatch: dispatches requests
- Request dispatch → User registry: reads/updates users
- Request dispatch → Room state: manages rooms
- Request dispatch → JSON formatting: formats replies
- Server sockets → JSON formatting: formats invalid reply
- Server sockets → Client socket: returns replies
- Client socket → Client controller: emits messages
- Client controller → JSON reader: parses responses
- Client controller → Console view: shows translated replies
- Server sockets → User registry: cleans up disconnects
- Server sockets → Room state: cleans up memberships
