|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +LocalNetAppChat (LNAC) is a client-server application for local network communication written in C#/.NET 7.0. It consists of: |
| 8 | +- **Server**: ASP.NET Core Web API handling message routing and file storage |
| 9 | +- **Client**: Console application for sending/receiving messages |
| 10 | +- **Bot**: Plugin-based application for executing scripts and responding to commands |
| 11 | + |
| 12 | +## Essential Development Commands |
| 13 | + |
| 14 | +### Building the Project |
| 15 | +```bash |
| 16 | +# Build entire solution |
| 17 | +cd Source/LocalNetAppChat |
| 18 | +dotnet build |
| 19 | + |
| 20 | +# Build specific project |
| 21 | +dotnet build LocalNetAppChat.Server/LocalNetAppChat.Server.csproj |
| 22 | + |
| 23 | +# Build in Release mode |
| 24 | +dotnet build --configuration Release |
| 25 | +``` |
| 26 | + |
| 27 | +### Running Tests |
| 28 | +```bash |
| 29 | +# Run all tests |
| 30 | +cd Source/LocalNetAppChat |
| 31 | +dotnet test |
| 32 | + |
| 33 | +# Run tests for specific project |
| 34 | +dotnet test LocalNetAppChat.Domain.Tests/LocalNetAppChat.Domain.Tests.csproj |
| 35 | +dotnet test LocalNetAppChat.Server.Domain.Tests/LocalNetAppChat.Server.Domain.Tests.csproj |
| 36 | +``` |
| 37 | + |
| 38 | +### Running Applications |
| 39 | +```bash |
| 40 | +# Run Server |
| 41 | +cd Source/LocalNetAppChat/LocalNetAppChat.Server |
| 42 | +dotnet run -- --key "MySecretKey" |
| 43 | + |
| 44 | +# Run Client (example: chat mode) |
| 45 | +cd Source/LocalNetAppChat/LocalNetAppChat.ConsoleClient |
| 46 | +dotnet run -- chat --server localhost --key "MySecretKey" --clientName "TestClient" |
| 47 | + |
| 48 | +# Run Bot |
| 49 | +cd Source/LocalNetAppChat/LocalNetAppChat.Bot |
| 50 | +dotnet run -- --server localhost --key "MySecretKey" --clientName "TestBot" |
| 51 | +``` |
| 52 | + |
| 53 | +## Architecture Overview |
| 54 | + |
| 55 | +### Project Structure |
| 56 | +``` |
| 57 | +Source/LocalNetAppChat/ |
| 58 | +├── CommandLineArguments/ # Shared CLI parsing utilities |
| 59 | +├── LocalNetAppChat.Bot/ # Bot application with plugin system |
| 60 | +│ └── Plugins/ # Plugin implementations (Ping, Execute, etc.) |
| 61 | +├── LocalNetAppChat.ConsoleClient/ # Client console application |
| 62 | +├── LocalNetAppChat.Domain/ # Shared domain logic and models |
| 63 | +├── LocalNetAppChat.Server/ # Web API server application |
| 64 | +└── LocalNetAppChat.Server.Domain/ # Server-specific domain logic |
| 65 | +``` |
| 66 | + |
| 67 | +### Key Architectural Patterns |
| 68 | + |
| 69 | +1. **Message Processing Pipeline** |
| 70 | + - Server uses a pipeline pattern for processing incoming messages |
| 71 | + - Pipeline components: SecurityValidation → MessageParsing → DirectMessageProcessing → Storage |
| 72 | + - Located in `LocalNetAppChat.Server.Domain/MessageProcessing/` |
| 73 | + |
| 74 | +2. **Plugin Architecture (Bot)** |
| 75 | + - Bot plugins implement `IPlugin` interface |
| 76 | + - Plugins respond to specific commands (e.g., `/ping`, `exec`) |
| 77 | + - New plugins can be added in `LocalNetAppChat.Bot/Plugins/` |
| 78 | + |
| 79 | +3. **Command Line Parsing** |
| 80 | + - Shared `CommandLineArguments` library handles CLI parsing |
| 81 | + - Uses custom tokenizer for parsing complex command strings |
| 82 | + - Supports both simple arguments and key-value pairs |
| 83 | + |
| 84 | +4. **Client Operating Modes** |
| 85 | + - `listener`: Receive messages only |
| 86 | + - `message`: Send single message |
| 87 | + - `chat`: Interactive send/receive |
| 88 | + - `fileupload/download/delete/listfiles`: File operations |
| 89 | + |
| 90 | +5. **Security Model** |
| 91 | + - Simple key-based authentication (shared secret) |
| 92 | + - All clients must provide matching key to connect |
| 93 | + - Server validates key on every request |
| 94 | + |
| 95 | +### Important Design Decisions |
| 96 | + |
| 97 | +1. **Direct Messaging**: Recent enhancement allows 1:n messaging where messages can be sent to specific clients using `/msg ClientName message` |
| 98 | + |
| 99 | +2. **File Storage**: Server maintains central file storage accessible by all authenticated clients |
| 100 | + |
| 101 | +3. **Script Execution**: Bot can execute PowerShell and Python scripts from designated scripts folder |
| 102 | + |
| 103 | +4. **Cross-Platform**: Uses .NET 7.0 for Windows, Linux, and macOS support |
| 104 | + |
| 105 | +5. **Communication Protocol**: HTTP/HTTPS with optional SSL certificate validation bypass for development |
| 106 | + |
| 107 | +## Common Development Tasks |
| 108 | + |
| 109 | +When implementing new features: |
| 110 | + |
| 111 | +1. **Adding New Bot Commands**: Create new plugin in `LocalNetAppChat.Bot/Plugins/` implementing `IPlugin` |
| 112 | + |
| 113 | +2. **Modifying Message Processing**: Update pipeline components in `LocalNetAppChat.Server.Domain/MessageProcessing/` |
| 114 | + |
| 115 | +3. **Adding Client Commands**: Extend command parsing in `LocalNetAppChat.ConsoleClient/` |
| 116 | + |
| 117 | +4. **Testing**: Add unit tests in corresponding `.Tests` projects maintaining existing patterns |
0 commit comments