This is a secure multi-threaded chat application with AI integration using Ollama. The application supports multiple chat rooms, user authentication, SSL/TLS encryption, and AI assistants in select rooms. It features connection resilience to handle network disruptions gracefully.
-
Setup and Compilation
make all
-
Run Individual Components
To run the SSL setup script only:
make run_ssl_setup
To run the server (SSL setup will run first):
make run_server
To run a client (SSL setup will run first):
make run_client
-
Run the Complete Stack (SSL setup, Server, and Client) - EXTRA (EXCLUSIVE TO MACOS)
make run_all
This will:
- Run the SSL setup to generate security credentials
- Start the server in a new terminal window
- Start a client in another terminal window
Once connected to the server, users can use the following commands:
/join <room>- Join or create a chat room/ai <room> <prompt>- Create an AI room with custom prompt/rooms- List available rooms/logout- Logout from the server/help- Show help message with available commands- Just type to send a message to the current room
The application follows a client-server architecture with the following key components:
The server (Server.java) manages:
- User authentication and registration
- Chat room management
- Client connections and message handling
- Secure communication via SSL/TLS
- Integration with Ollama for AI-powered chat rooms
- Session management for connection resilience and state preservation
The client (Client.java) provides:
- User authentication (login/registration)
- Room selection
- Message sending and receiving
- Secure communication with the server via SSL/TLS
- Automatic reconnection when connections break
- State persistence across reconnections
Chat rooms (ChatRoom.java) feature:
- Regular rooms for human-to-human communication
- AI-powered rooms with Ollama integration
- Message history tracking
- Concurrent access handling with read/write locks
- State persistence for rejoining after disconnection
The session management system (SessionManager.java) provides:
- Token-based authentication for reconnection without credentials
- User state preservation across connection breaks
- Automatic token expiration for security
- Room state tracking and restoration after reconnection
Security is provided through SSL/TLS using:
SSLSetupScript.java: Generates the necessary keystores and truststores- Server certificate export and client trust configuration
The Ollama integration (OllamaConnection.java) provides:
- Contextual conversation support
- Custom system prompts for specialized AI assistants
- Java SE 21 or higher (for virtual threads)
- Ollama running locally (for AI features)
- macOS for the full
run_allscript (usesosascriptfor terminal management)
The SSL setup script generates:
- A server keystore (
serverkeystore.jks) - A server certificate (
server.cer) - A client truststore (
clienttruststore.jks)
All with the default password: "password"