# bsoto-fc/proyecto-1-myp architecture

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

- Interactive diagram: https://gitdiagram.com/bsoto-fc/proyecto-1-myp
- Repository: https://github.com/bsoto-fc/proyecto-1-myp

## Overview

Xerces Chat is a desktop chat client paired with a C server. The main workflow is: a user connects with a username, the client identifies over TCP, then sends chat and room requests; the server authenticates and dispatches them, maintains users and rooms, and replies for the client to update its UI state. The README establishes the client/server product; sampled Kotlin and server entry-point code support the main connections. Server-side room and user internals are represented by their exact source paths, but their detailed dispatch wiring was not sampled.

Main entry points: [`gui/app/src/main/kotlin/mx/unam/ciencias/myp/App.kt`](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/App.kt) (Screen manager), [`server/src/server.c`](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/server.c) (Connection server), [`gui/app/src/main/kotlin/mx/unam/ciencias/myp/sockets/SocketClient.kt`](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/sockets/SocketClient.kt) (TCP client), [`server/src/users.c`](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/users.c) (User handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop client"]
  node_ui["Chat UI<br/>[ChatScreen.kt]"]
  node_connection["Connection UI"]
  node_app["Screen manager<br/>[App.kt]"]
  node_clientwire["TCP client<br/>[SocketClient.kt]"]
  node_codec["Message codec<br/>[Message.kt]"]
end

subgraph group_server["Chat server"]
  node_servermain["Server entry<br/>[main.c]"]
  node_server["Connection server<br/>[server.c]"]
  node_socketutil["Socket utilities<br/>[socketutil.c]"]
  node_jsonutil["JSON utilities<br/>[jsonutil.c]"]
end

subgraph group_domain["Chat state"]
  node_userdomain["User handling<br/>[users.c]"]
  node_userstate[("User registry<br/>[users.h]")]
  node_roomdomain["Room handling<br/>[rooms.c]"]
  node_roomstate[("Room registry<br/>[rooms.h]")]
end

node_person(("Chat user"))
node_remote(("Chat server"))

node_person -->|"enters connection"| node_connection
node_person -->|"uses chat"| node_ui
node_connection -->|"submits details"| node_app
node_app -->|"connects"| node_clientwire
node_app -->|"encodes requests"| node_codec
node_clientwire -->|"identifies and exchanges JSON"| node_remote
node_remote -->|"returns responses"| node_clientwire
node_clientwire -->|"delivers messages"| node_app
node_app -->|"decodes messages"| node_codec
node_app -->|"updates chat state"| node_ui
node_servermain -->|"starts server"| node_server
node_server -->|"creates and accepts sockets"| node_socketutil
node_remote -->|"opens TCP connection"| node_server
node_server -->|"uses JSON parsing"| node_jsonutil
node_server -->|"authenticates and dispatches"| node_userdomain
node_server -->|"disconnects user"| node_userdomain
node_userdomain -->|"reads and updates"| node_userstate
node_roomdomain -->|"reads and updates"| node_roomstate

click node_ui "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/ChatScreen.kt"
click node_connection "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/ConnectionWindow.kt"
click node_app "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/App.kt"
click node_clientwire "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/sockets/SocketClient.kt"
click node_codec "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/messages/Message.kt"
click node_servermain "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/main.c"
click node_server "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/server.c"
click node_socketutil "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/util/socketutil.c"
click node_jsonutil "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/util/jsonutil.c"
click node_userdomain "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/users.c"
click node_userstate "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/include/users.h"
click node_roomdomain "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/rooms.c"
click node_roomstate "https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/include/rooms.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_ui,node_connection,node_app,node_clientwire,node_codec,node_person toneBlue
class node_servermain,node_server,node_socketutil,node_jsonutil toneAmber
class node_userdomain,node_userstate,node_roomdomain,node_roomstate,node_remote toneMint
```

## Components

### Desktop client

- [Chat UI](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/ChatScreen.kt): `gui/app/src/main/kotlin/mx/unam/ciencias/myp/ChatScreen.kt`
- [Connection UI](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/ConnectionWindow.kt): `gui/app/src/main/kotlin/mx/unam/ciencias/myp/ConnectionWindow.kt`
- [Screen manager](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/App.kt): `gui/app/src/main/kotlin/mx/unam/ciencias/myp/App.kt`
- [TCP client](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/sockets/SocketClient.kt): `gui/app/src/main/kotlin/mx/unam/ciencias/myp/sockets/SocketClient.kt`
- [Message codec](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/gui/app/src/main/kotlin/mx/unam/ciencias/myp/messages/Message.kt): `gui/app/src/main/kotlin/mx/unam/ciencias/myp/messages/Message.kt`

### Chat server

- [Server entry](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/main.c): `server/src/main.c`
- [Connection server](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/server.c): `server/src/server.c`
- [Socket utilities](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/util/socketutil.c): `server/util/socketutil.c`
- [JSON utilities](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/util/jsonutil.c): `server/util/jsonutil.c`

### Chat state

- [User handling](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/users.c): `server/src/users.c`
- [User registry](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/include/users.h): `server/include/users.h`
- [Room handling](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/src/rooms.c): `server/src/rooms.c`
- [Room registry](https://github.com/bsoto-fc/proyecto-1-myp/blob/main/server/include/rooms.h): `server/include/rooms.h`

### Other components

- **Chat user**
- **Chat server**

## Connections

- Chat user → Connection UI: enters connection
- Chat user → Chat UI: uses chat
- Connection UI → Screen manager: submits details
- Screen manager → TCP client: connects
- Screen manager → Message codec: encodes requests
- TCP client → Chat server: identifies and exchanges JSON
- Chat server → TCP client: returns responses
- TCP client → Screen manager: delivers messages
- Screen manager → Message codec: decodes messages
- Screen manager → Chat UI: updates chat state
- Server entry → Connection server: starts server
- Connection server → Socket utilities: creates and accepts sockets
- Chat server → Connection server: opens TCP connection
- Connection server → JSON utilities: uses JSON parsing
- Connection server → User handling: authenticates and dispatches
- Connection server → User handling: disconnects user
- User handling → User registry: reads and updates
- Room handling → Room registry: reads and updates
