# nathanlee5163/loopify architecture

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

- Interactive diagram: https://gitdiagram.com/nathanlee5163/loopify
- Repository: https://github.com/nathanlee5163/loopify

## Overview

Loopify is a social platform whose main workflow is a user interacting through the client, sending commands to the server, and receiving results from command handling backed by domain objects and persistent files. The server delegates each connection to a client handler; the README describes the supported account, friend/block, profile, and post interactions. The shown source supports the handler’s database and domain dependencies, plus file-backed user relationships and post comments. Unsampled modules and some persistence wiring are represented only where documented or indexed.

Main entry points: [`src/ClientHandler.java`](https://github.com/nathanlee5163/loopify/blob/main/src/ClientHandler.java) (Command handler), [`src/Database.java`](https://github.com/nathanlee5163/loopify/blob/main/src/Database.java) (File database), [`src/User.java`](https://github.com/nathanlee5163/loopify/blob/main/src/User.java) (User accounts), [`src/TerminalClient.java`](https://github.com/nathanlee5163/loopify/blob/main/src/TerminalClient.java) (Desktop client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client access"]
  node_terminal_client["Desktop client"]
  node_loopify_entry["Loopify entry<br/>[Loopify.java]"]
  node_terminal_contract["Client contract"]
end

subgraph group_server["Request handling"]
  node_server["Socket server<br/>[LoopifyServer.java]"]
  node_server_contract["Server contract"]
  node_handler["Command handler<br/>[ClientHandler.java]"]
  node_handler_contract["Handler contract"]
end

subgraph group_domain["Social domain"]
  node_user_domain["User accounts<br/>[User.java]"]
  node_user_contract["User contract<br/>[UserInterface.java]"]
  node_post_domain["Posts and comments<br/>[Post.java]"]
  node_post_contract["Post contract<br/>[PostInterface.java]"]
  node_search_contract["Search contract"]
  node_input_error["Input validation error"]
  node_user_error["Missing user error"]
  node_username_error["Duplicate username error"]
  node_post_error["Missing post error"]
end

subgraph group_storage["Persistence"]
  node_database[("File database<br/>[Database.java]")]
  node_database_contract["Database contract"]
  node_account_files[("User records<br/>[Users.txt]")]
  node_post_files[("Post records<br/>[Posts.txt]")]
  node_social_files[("Friend and block records")]
  node_comment_files[("Comment records")]
  node_online_file[("Online users<br/>[Online.txt]")]
end

node_user_actor(("User"))

node_user_actor -->|"uses"| node_terminal_client
node_terminal_client -->|"sends requests"| node_server
node_server -->|"delegates connections"| node_handler
node_handler -->|"queries and updates"| node_database
node_handler -->|"handles accounts"| node_user_domain
node_handler -->|"handles posts"| node_post_domain
node_database -->|"persists users"| node_account_files
node_database -->|"persists posts"| node_post_files
node_user_domain -->|"looks up users"| node_database
node_user_domain -->|"reads and writes"| node_social_files
node_post_domain -->|"stores comments"| node_comment_files
node_handler -->|"reads online users"| node_online_file

click node_terminal_client "https://github.com/nathanlee5163/loopify/blob/main/src/TerminalClient.java"
click node_loopify_entry "https://github.com/nathanlee5163/loopify/blob/main/src/Loopify.java"
click node_terminal_contract "https://github.com/nathanlee5163/loopify/blob/main/src/TerminalClientInterface.java"
click node_server "https://github.com/nathanlee5163/loopify/blob/main/src/LoopifyServer.java"
click node_server_contract "https://github.com/nathanlee5163/loopify/blob/main/src/LoopifyServerInterface.java"
click node_handler "https://github.com/nathanlee5163/loopify/blob/main/src/ClientHandler.java"
click node_handler_contract "https://github.com/nathanlee5163/loopify/blob/main/src/ClientHandlerInterface.java"
click node_user_domain "https://github.com/nathanlee5163/loopify/blob/main/src/User.java"
click node_user_contract "https://github.com/nathanlee5163/loopify/blob/main/src/UserInterface.java"
click node_post_domain "https://github.com/nathanlee5163/loopify/blob/main/src/Post.java"
click node_post_contract "https://github.com/nathanlee5163/loopify/blob/main/src/PostInterface.java"
click node_search_contract "https://github.com/nathanlee5163/loopify/blob/main/src/SearchInterface.java"
click node_input_error "https://github.com/nathanlee5163/loopify/blob/main/src/InvalidInputException.java"
click node_user_error "https://github.com/nathanlee5163/loopify/blob/main/src/UserNotFoundException.java"
click node_username_error "https://github.com/nathanlee5163/loopify/blob/main/src/UsernameTakenException.java"
click node_post_error "https://github.com/nathanlee5163/loopify/blob/main/src/PostNotFoundException.java"
click node_database "https://github.com/nathanlee5163/loopify/blob/main/src/Database.java"
click node_database_contract "https://github.com/nathanlee5163/loopify/blob/main/src/DatabaseInterface.java"
click node_account_files "https://github.com/nathanlee5163/loopify/blob/main/src/Users.txt"
click node_post_files "https://github.com/nathanlee5163/loopify/blob/main/src/Posts.txt"
click node_social_files "https://github.com/nathanlee5163/loopify/tree/main/Resources"
click node_comment_files "https://github.com/nathanlee5163/loopify/tree/main/Resources"
click node_online_file "https://github.com/nathanlee5163/loopify/blob/main/Resources/Online.txt"

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_terminal_client,node_loopify_entry,node_terminal_contract,node_user_actor toneBlue
class node_server,node_server_contract,node_handler,node_handler_contract toneAmber
class node_user_domain,node_user_contract,node_post_domain,node_post_contract,node_search_contract,node_input_error,node_user_error,node_username_error,node_post_error toneMint
class node_database,node_database_contract,node_account_files,node_post_files,node_social_files,node_comment_files,node_online_file toneRose
```

## Components

### Client access

- [Desktop client](https://github.com/nathanlee5163/loopify/blob/main/src/TerminalClient.java): `src/TerminalClient.java`
- [Loopify entry](https://github.com/nathanlee5163/loopify/blob/main/src/Loopify.java): `src/Loopify.java`
- [Client contract](https://github.com/nathanlee5163/loopify/blob/main/src/TerminalClientInterface.java): `src/TerminalClientInterface.java`

### Request handling

- [Socket server](https://github.com/nathanlee5163/loopify/blob/main/src/LoopifyServer.java): `src/LoopifyServer.java`
- [Server contract](https://github.com/nathanlee5163/loopify/blob/main/src/LoopifyServerInterface.java): `src/LoopifyServerInterface.java`
- [Command handler](https://github.com/nathanlee5163/loopify/blob/main/src/ClientHandler.java): `src/ClientHandler.java`
- [Handler contract](https://github.com/nathanlee5163/loopify/blob/main/src/ClientHandlerInterface.java): `src/ClientHandlerInterface.java`

### Social domain

- [User accounts](https://github.com/nathanlee5163/loopify/blob/main/src/User.java): `src/User.java`
- [User contract](https://github.com/nathanlee5163/loopify/blob/main/src/UserInterface.java): `src/UserInterface.java`
- [Posts and comments](https://github.com/nathanlee5163/loopify/blob/main/src/Post.java): `src/Post.java`
- [Post contract](https://github.com/nathanlee5163/loopify/blob/main/src/PostInterface.java): `src/PostInterface.java`
- [Search contract](https://github.com/nathanlee5163/loopify/blob/main/src/SearchInterface.java): `src/SearchInterface.java`
- [Input validation error](https://github.com/nathanlee5163/loopify/blob/main/src/InvalidInputException.java): `src/InvalidInputException.java`
- [Missing user error](https://github.com/nathanlee5163/loopify/blob/main/src/UserNotFoundException.java): `src/UserNotFoundException.java`
- [Duplicate username error](https://github.com/nathanlee5163/loopify/blob/main/src/UsernameTakenException.java): `src/UsernameTakenException.java`
- [Missing post error](https://github.com/nathanlee5163/loopify/blob/main/src/PostNotFoundException.java): `src/PostNotFoundException.java`

### Persistence

- [File database](https://github.com/nathanlee5163/loopify/blob/main/src/Database.java): `src/Database.java`
- [Database contract](https://github.com/nathanlee5163/loopify/blob/main/src/DatabaseInterface.java): `src/DatabaseInterface.java`
- [User records](https://github.com/nathanlee5163/loopify/blob/main/src/Users.txt): `src/Users.txt`
- [Post records](https://github.com/nathanlee5163/loopify/blob/main/src/Posts.txt): `src/Posts.txt`
- [Friend and block records](https://github.com/nathanlee5163/loopify/tree/main/Resources): `Resources`
- [Comment records](https://github.com/nathanlee5163/loopify/tree/main/Resources): `Resources`
- [Online users](https://github.com/nathanlee5163/loopify/blob/main/Resources/Online.txt): `Resources/Online.txt`

### Other components

- **User**

## Connections

- User → Desktop client: uses (evidence: `README.md`)
- Desktop client → Socket server: sends requests (evidence: `README.md`)
- Socket server → Command handler: delegates connections (evidence: `README.md`)
- Command handler → File database: queries and updates (evidence: `src/ClientHandler.java`)
- Command handler → User accounts: handles accounts (evidence: `src/ClientHandler.java`)
- Command handler → Posts and comments: handles posts (evidence: `src/ClientHandler.java`)
- File database → User records: persists users (evidence: `README.md`)
- File database → Post records: persists posts (evidence: `README.md`)
- User accounts → File database: looks up users (evidence: `src/User.java`)
- User accounts → Friend and block records: reads and writes (evidence: `src/User.java`)
- Posts and comments → Comment records: stores comments (evidence: `src/Post.java`)
- Command handler → Online users: reads online users (evidence: `src/ClientHandler.java`)
