Overview
FTP-WIRE follows a modular client-server architecture which separates concerns between command processing, data transfer, and connection management. The system is composed of two primary modules: a Server and a Client — which communicate using structured packet-based messages over TCP sockets.
High Level Diagram ¶
graph TD
classDef default rx:15, ry:15;
%% --- SERVER SIDE ---
subgraph ServerSide["Server"]
ServerModule["Server Module"]
end
%% --- CLIENTS SIDE ---
subgraph Client1["Client 1"]
Client1UI["Client UI"]
Client1Module["Client Module"]
Client1UI --> Client1Module
end
subgraph Client2["Client 2"]
Client2UI["Client UI"]
Client2Module["Client Module"]
Client2UI --> Client2Module
end
%% --- CONNECTIONS BETWEEN CLIENTS AND SERVER ---
Client1 <-->|Commands / Replies| ServerSide
Client2 <-->|Commands / Replies| ServerSide
A Server Module is used to act as a central service for many clients. Each of those clients has a Client UI which could be different such as a CLI or a GUI application that integrates ftp-wire.
Each client should be able to operate with the server separately, regardless of other clients errors or disconnections.
The FTP Model¶
The Server/Client architecure follows the FTP-Model design which is shown as follows
flowchart LR
classDef rounded rx:15, ry:15;
User-->|Interaction|UI
Client<-->user-storage["FileSystem"]
subgraph User-FTP
UI<-->|Control|Client
end
subgraph Server-FTP
Server
end
Server<-->server-storage["FileSystem"]
Server-FTP<-->|Command Connection|User-FTP
Server-FTP<-->|Data Connection|User-FTP
class User,UI,Client,user-storage,Server,server-storage rounded;
Project Structure¶
The Client Module is represented with the Client package, same for the Server Module. Each of the two modules has many other submodules, each one is providing a specific functionality. There are many common submodules between the Client and the Server modules which are located in the Common package
ftp-wire
Client
Controllers
CommandController.javaDataController.java
Loggers
ClientLogger.java
ReplyHandlers
FILE_INFO_ReplyHandler.javaMESSAGE_ReplyHandler.javaReplyHandler.javaCWD_ReplyHandler.javaPWD_ReplyHandler.java
Models
ClientConfig.javaCommandSender.javaConnectionManager.javaLoggerManager.javaReply.javaReplyPacketFactory.javaResponseReceiver.java
Client.java
clientCLI
ClientCLI.javaClientCLILogger.javaCommandHandler.javaOfflineClientCLI.javaOfflineCommandType.java
Common
Exceptions
CommandFormatException.javaNoCommandWithSpecifiedHeaderException.javaRemoteDisconnectionException.java
Loggers
Logger.java
Models
Command.javaStatus.javaUtilityFunctions.java
Packets
Communication
CommandPacket.javaReplyPacket.java
HandShaking
DonePacket.javaHelloPacket.javaPairPacket.javaWelcomePacket.java
IO
PacketReader.javaPacketWriter.java
Packet.java
Serialization
PacketSerializer.java
Types
PacketType.javaReplyType.java
Server
Exceptions
CanNotReadPacketException.java
Handlers
ChangeWorkingDirectoryHandler.javaCommandErrorHandler.javaCommandHandler.javaErrorHandler.javaHelpCommandHandler.javaListFilesCommandHandler.javaPrintWorkingDirectoryHandler.javaQuitCommandHandler.javaRetrieveFileCommandHandler.java
HandShaking
HandShakeManager.javaSession.java
Loggers
ServerCLILogger.javaServerLogger.java
Models
Types
CommandType.javaErrorType.java
ClientProfile.javaCommandSelectorDispatcher.javaServerConfig.javaTaskDispatcher.javaThreadPool.javaUserConnection.java
Registeries
SessionRegistry.java
SocketAcceptors
CommandSocketAcceptor.javaDataSocketAcceptor.java
Tasks
CommandTask.javaDataTask.javaSendFileTask.javaSendPacketTask.javaTask.java
Server.java
Run
Client_CLI.javaServer_CLI.java
Data/Connection flow¶
The Client first will do a handshaking process which will identify his connection info and username then if the client connection success (for now there is no login functionality), he can send a command to the server then the server will schedule a task to serve that command. After the task is completed, the server schedule another task for sending a reply packet to the client which will identify the success or failure of the sent command. this also could be followed by sending a file from the server to the client through the Data Connection.
sequenceDiagram
participant C as Client
participant S as Server
participant H as Handler
C<<->>S: HandShaking process
C->>S: Send CommandPacket
S->>H: Dispatch Command
H-->>S: Generate ReplyPacket
S-->>C: Send ReplyPacket