Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Project516/p2p-chat/llms.txt

Use this file to discover all available pages before exploring further.

p2p-chat is an open-source project licensed under AGPL-3.0. Contributions are welcome — whether that means fixing a bug, improving the documentation, or adding a new feature. This page covers the development environment setup, project conventions, and licensing requirements you need to know before submitting a change.
p2p-chat does not currently have an automated test suite. All verification is done by running the program manually with go run.

Requirements

  • Go 1.26.2 or later. The project uses standard library features and module support from this version.
If you do not have Go installed, the repository includes install-go.sh which downloads and installs Go 1.26.2 on Linux:
bash install-go.sh
After installation, make sure the Go binary is on your PATH:
go version
# go version go1.26.2 linux/amd64

Clone and build

1

Clone the repository

git clone https://github.com/Project516/p2p-chat
cd p2p-chat
2

Download dependencies

The project uses Go modules. Dependencies are recorded in go.mod and go.sum. Fetch them with:
go mod download
3

Run the program

p2p-chat is run directly with go run. There is no separate build step required for development. Open two terminals in the project directory:Terminal 1 — start the listener:
go run . listen localhost:5555
Terminal 2 — connect:
go run . connect localhost:5555
Both terminals should show a connected prompt and allow bidirectional chat.

Formatting and vetting

Before submitting a change, run run.sh to format and vet the code:
bash run.sh
run.sh runs the following commands in sequence:
go fmt ./...   # format all Go source files
go vet ./...   # check for common correctness issues
go run .       # run the program (prints usage — no address given)
go run . at the end of run.sh prints the usage line and exits immediately since no subcommand is provided. This is expected behavior, not an error.
You can also run formatting and vetting independently:
go fmt ./...
go vet ./...
All submitted Go code must pass both go fmt (no diff) and go vet (no output) before being merged.

Project structure

p2p-chat/
├── main.go                   # CLI entry point: argument parsing and dispatch
├── go.mod                    # Module definition and Go version
├── go.sum                    # Dependency checksums
├── assets/
│   └── version.txt           # Version string (currently 1.0.0)
├── crypto/
│   └── crypto.go             # Key exchange, encryption, decryption
├── internal/
│   ├── chat/
│   │   └── chat.go           # Session logic, slash commands, message loop
│   ├── transport/
│   │   └── transport.go      # Length-prefixed frame encoding/decoding
│   └── version/
│       └── version.go        # Reads assets/version.txt at runtime
├── host.sh                   # Shortcut: go run . listen localhost:5555
├── connect.sh                # Shortcut: go run . connect localhost:5555
├── run.sh                    # Format, vet, and run
└── install-go.sh             # Downloads and installs Go 1.26.2 on Linux
When adding new packages, place them under internal/ if they are not intended for use outside the module, or at the top level alongside crypto/ if they are general-purpose.

Making changes

The argument dispatcher lives in main.go. Add new cases to the switch statement there and implement the logic in a new or existing package under internal/.
Slash commands are parsed and dispatched in internal/chat/chat.go. Add a new case to the slash command handler and implement the behavior in the same file or a helper function. If the command sends data to the peer, encrypt it through the transport layer as the existing commands do.
The wire frame format is defined in internal/transport/transport.go. Any change to SendFrame or ReceiveFrame will break compatibility with existing clients, so document the change clearly and update both functions together.
Bump the version by editing assets/version.txt. The string is read at runtime by internal/version/version.go and used by both go run . version and the /version slash command.

License

p2p-chat is released under the GNU Affero General Public License v3.0 (AGPL-3.0). By contributing to this project, you agree that your contributions will be licensed under the same license.
AGPL-3.0 has strong copyleft requirements. If you distribute a modified version of p2p-chat — including running it as a network service — you must make the complete source code of your modified version available under AGPL-3.0. Contributions that incorporate code under an incompatible license cannot be accepted.
The full license text is in the LICENSE file at the root of the repository. When in doubt about license compatibility, open a discussion on the GitHub repository before submitting a pull request.

Build docs developers (and LLMs) love