Skip to content

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.java
  • DataController.java
Loggers
  • ClientLogger.java
ReplyHandlers
  • FILE_INFO_ReplyHandler.java
  • MESSAGE_ReplyHandler.java
  • ReplyHandler.java
  • CWD_ReplyHandler.java
  • PWD_ReplyHandler.java
Models
  • ClientConfig.java
  • CommandSender.java
  • ConnectionManager.java
  • LoggerManager.java
  • Reply.java
  • ReplyPacketFactory.java
  • ResponseReceiver.java
  • Client.java
clientCLI
  • ClientCLI.java
  • ClientCLILogger.java
  • CommandHandler.java
  • OfflineClientCLI.java
  • OfflineCommandType.java
Common
Exceptions
  • CommandFormatException.java
  • NoCommandWithSpecifiedHeaderException.java
  • RemoteDisconnectionException.java
Loggers
  • Logger.java
Models
  • Command.java
  • Status.java
  • UtilityFunctions.java
Packets
Communication
  • CommandPacket.java
  • ReplyPacket.java
HandShaking
  • DonePacket.java
  • HelloPacket.java
  • PairPacket.java
  • WelcomePacket.java
IO
  • PacketReader.java
  • PacketWriter.java
  • Packet.java
Serialization
  • PacketSerializer.java
Types
  • PacketType.java
  • ReplyType.java
Server
Exceptions
  • CanNotReadPacketException.java
Handlers
  • ChangeWorkingDirectoryHandler.java
  • CommandErrorHandler.java
  • CommandHandler.java
  • ErrorHandler.java
  • HelpCommandHandler.java
  • ListFilesCommandHandler.java
  • PrintWorkingDirectoryHandler.java
  • QuitCommandHandler.java
  • RetrieveFileCommandHandler.java
HandShaking
  • HandShakeManager.java
  • Session.java
Loggers
  • ServerCLILogger.java
  • ServerLogger.java
Models
Types
  • CommandType.java
  • ErrorType.java
  • ClientProfile.java
  • CommandSelectorDispatcher.java
  • ServerConfig.java
  • TaskDispatcher.java
  • ThreadPool.java
  • UserConnection.java
Registeries
  • SessionRegistry.java
SocketAcceptors
  • CommandSocketAcceptor.java
  • DataSocketAcceptor.java
Tasks
  • CommandTask.java
  • DataTask.java
  • SendFileTask.java
  • SendPacketTask.java
  • Task.java
  • Server.java
Run
  • Client_CLI.java
  • Server_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