# isaacisaraloone/proyecto-1-chat-cliente-servidor architecture

> Architecture diagram of the GitHub repository isaacisaraloone/proyecto-1-chat-cliente-servidor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/isaacisaraloone/proyecto-1-chat-cliente-servidor
- Repository: https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor

## Overview

This repository implements a concurrent TCP/IP instant-messaging client and server using newline-delimited JSON. The user workflow starts in the console client: it connects, identifies a username, sends commands, and displays server events. On the server, accepted connections are handled in per-client threads; the controller routes requests to shared user/room state and response or broadcast functions. The README documents private and public messaging, status and user listings, and room creation, invitations, membership, and chat. Source excerpts show the main client/server wiring; unsampled controller details are represented only where imports or documentation support the relationship.

Main entry points: [`Cliente/Chat.cs`](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/Chat.cs) (Chat session), [`Servidor/src/controlador.c`](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/controlador.c) (Request controller), [`Servidor/src/estado.c`](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/estado.c) (Users and rooms), [`Servidor/src/main.c`](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/main.c) (Server listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Console client"]
  node_client_entry["Client entry<br/>[program.cs]"]
  node_chat_session["Chat session<br/>[Chat.cs]"]
  node_command_parser["Command handling<br/>[AnalizarComando.cs]"]
  node_client_connection["TCP connection<br/>[ManejarConexion.cs]"]
end

subgraph group_server["Server runtime"]
  node_server_entry["Server listener<br/>[main.c]"]
  node_client_controller["Request controller<br/>[controlador.c]"]
  node_server_network["Response broadcasts<br/>[red.c]"]
end

subgraph group_state["Shared chat state"]
  node_global_state[("Users and rooms<br/>[estado.c]")]
  node_state_contract["State model<br/>[estado.h]"]
  node_hash_index["Hash collections<br/>[uthash.h]"]
end

subgraph group_protocol["JSON protocol support"]
  node_json_codec["JSON codec<br/>[cJSON.c]"]
  node_json_api["JSON API<br/>[cJSON.h]"]
end

node_user(("Chat user"))
node_external_network{{"TCP network"}}

node_user -->|"starts"| node_client_entry
node_client_entry -->|"starts session"| node_chat_session
node_chat_session -->|"connects and exchanges"| node_client_connection
node_chat_session -->|"processes commands"| node_command_parser
node_chat_session -->|"renders events"| node_command_parser
node_client_connection -.->|"sends and reads"| node_external_network
node_external_network -.->|"TCP connects"| node_server_entry
node_server_entry -->|"initializes and destroys"| node_global_state
node_server_entry -->|"starts client thread"| node_client_controller
node_client_controller -->|"routes state operations"| node_global_state
node_client_controller -->|"dispatches responses"| node_server_network
node_server_network -->|"reads users and rooms"| node_global_state
node_client_controller -->|"uses JSON API"| node_json_api
node_server_network -->|"builds JSON messages"| node_json_api
node_json_codec -->|"implements API"| node_json_api
node_state_contract -->|"uses hash handles"| node_hash_index
node_global_state -.->|"implements state model"| node_state_contract

click node_client_entry "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/program.cs"
click node_chat_session "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/Chat.cs"
click node_command_parser "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/AnalizarComando.cs"
click node_client_connection "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/ManejarConexion.cs"
click node_server_entry "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/main.c"
click node_client_controller "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/controlador.c"
click node_server_network "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/red.c"
click node_global_state "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/estado.c"
click node_state_contract "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/include/estado.h"
click node_hash_index "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/uthash/uthash.h"
click node_json_codec "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/cJSON.c"
click node_json_api "https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/cJSON.h"

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_chat_session,node_command_parser,node_client_connection,node_user toneBlue
class node_server_entry,node_client_controller,node_server_network toneAmber
class node_global_state,node_state_contract,node_hash_index toneMint
class node_json_codec,node_json_api toneRose
class node_external_network toneIndigo
```

## Components

### Console client

- [Client entry](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/program.cs): `Cliente/program.cs`
- [Chat session](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/Chat.cs): `Cliente/Chat.cs`
- [Command handling](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/AnalizarComando.cs): `Cliente/AnalizarComando.cs`
- [TCP connection](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Cliente/ManejarConexion.cs): `Cliente/ManejarConexion.cs`

### Server runtime

- [Server listener](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/main.c): `Servidor/src/main.c`
- [Request controller](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/controlador.c): `Servidor/src/controlador.c`
- [Response broadcasts](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/red.c): `Servidor/src/red.c`

### Shared chat state

- [Users and rooms](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/src/estado.c): `Servidor/src/estado.c`
- [State model](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/include/estado.h): `Servidor/include/estado.h`
- [Hash collections](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/uthash/uthash.h): `Servidor/lib/uthash/uthash.h`

### JSON protocol support

- [JSON codec](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/cJSON.c): `Servidor/lib/cJSON.c`
- [JSON API](https://github.com/isaacisaraloone/proyecto-1-chat-cliente-servidor/blob/main/Servidor/lib/cJSON.h): `Servidor/lib/cJSON.h`

### Other components

- **Chat user**
- **TCP network**

## Connections

- Chat user → Client entry: starts (evidence: `Cliente/program.cs`)
- Client entry → Chat session: starts session (evidence: `Cliente/program.cs`)
- Chat session → TCP connection: connects and exchanges (evidence: `Cliente/Chat.cs`)
- Chat session → Command handling: processes commands (evidence: `Cliente/Chat.cs`)
- Chat session → Command handling: renders events (evidence: `Cliente/Chat.cs`)
- TCP connection → TCP network: sends and reads (evidence: `README.md`)
- TCP network → Server listener: TCP connects (evidence: `README.md`)
- Server listener → Users and rooms: initializes and destroys (evidence: `Servidor/src/main.c`)
- Server listener → Request controller: starts client thread (evidence: `Servidor/src/main.c`)
- Request controller → Users and rooms: routes state operations (evidence: `Servidor/src/controlador.c`)
- Request controller → Response broadcasts: dispatches responses (evidence: `Servidor/src/controlador.c`)
- Response broadcasts → Users and rooms: reads users and rooms (evidence: `Servidor/src/red.c`)
- Request controller → JSON API: uses JSON API (evidence: `Servidor/src/controlador.c`)
- Response broadcasts → JSON API: builds JSON messages (evidence: `Servidor/src/red.c`)
- JSON codec → JSON API: implements API (evidence: `Servidor/lib/cJSON.c`)
- State model → Hash collections: uses hash handles (evidence: `Servidor/include/estado.h`)
- Users and rooms → State model: implements state model (evidence: `Servidor/src/estado.c`)
