Code Monkey home page Code Monkey logo

natternet's Introduction

NatterNet

Your real-time chat application built with Golang, MongoDB, WebSockets, and Fasthttp.

Table of Contents

  1. Introduction
  2. Features
  3. Resources & Community
  4. API Documentation
  5. Blog Posts
  6. License

Introduction

NatterNet is a fast and lightweight chat WebSocket service built with Golang, MongoDB, WebSockets, and Fasthttp. It aims to provide a scalable and efficient platform for real-time chat applications.

Features

Completed Features

  • User Authentication

    • JWT-based authentication.
    • RSA keys for JWT signing.
  • Real-time Communication

    • WebSocket support for real-time updates.
    • Real-time "typing..." status display.
  • Rooms

    • Create, join, and leave rooms.
  • Message Types

    • Support for text messages.
  • Distributed Systems

    • NATS Streaming for event-driven architecture.
  • Logging

    • Comprehensive logging with Uber's Zap logger.
  • API and Web Server

    • API built on top of Fiber (FastHTTP).
  • Database

    • MongoDB for persistent storage.

Upcoming Features

  • Support for more message types like images, audio, video, etc.
  • Push notifications via Firebase/OneSignal.
  • User presence system.
  • Message editing and deletion.
  • Multi-language support.
  • Rate limiting for API requests.

Resources & Community

We've compiled a list of resources that will help you understand, use, and contribute to NatterNet more effectively:

  • Postman Team: Join our Postman Team to explore NatterNet's API.

  • Community Chat: Have questions, feedback, or just want to chat? Join our Discord Server.

  • Wiki: For detailed guides, FAQs, and other information, check out the NatterNet Wiki.

  • Blog Posts: Deep dives into the architecture, domain-driven design, and other facets of NatterNet are available in our Substack Blog.

Feel free to contribute by submitting PRs, opening issues, or spreading the word.

API Documentation with Swagger

You can access the API documentation through Swagger at the following endpoint after starting the application:

http://localhost:8080/api/v1/swagger/

Tip: Before delving into the documentation, ensure to execute make swagger at the project root. This step regenerates essential Swagger components, keeping the docs updated.

๐Ÿ“š Blog Posts for Deeper Understanding

Want to get more in-depth insights into NatterNet? Check out our blog posts:

  1. Introducing NatterNet: A Domain-Driven Real-Time Chat Application

    • Introduction to NatterNet and its architecture.
  2. NatterNet: A Deep Dive into Clean Architecture

    • Learn the details of how Clean Architecture is implemented in NatterNet.
  3. Deep Dive into Domain-Driven Design in NatterNet

    • Understand the nuances of Domain-Driven Design as it's applied in NatterNet.

License

NatterNet is licensed under the MIT License. See the LICENSE file for more details.

natternet's People

Contributors

iammuho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lemon41

natternet's Issues

Initial Project Setup

  • Project directory structure has been created.
  • Basic documentation (README, etc.) has been initiated.

Support Different Message Types - Video

  • Implement video upload and storage.
  • Enable video previews and playback within the chat interface.
  • Add a new message type for video messages in the chat domain.

SQLite with crdt

removing mongo and using SQLite

https://github.com/vlcn-io/cr-sqlite

Will allow offline and sync

the server and client both use the same db

Fly.io is using it for distributed shakeout of the servers but it can just as well be used for the clients.

Upgrade the depreceated jose package for JWT for pem

Discussed in #23

Originally posted by abird August 30, 2023
I followed the installation instructions and when I do "go run ." I get a "No RSA Certificate file found" message. I'm running on MacOS 13.4.1.

(jose jwt package)[https://github.com/square/go-jose] has been archived and we need to change it to a proper and active library to be able to handle the JWT signing operations.

Htmx style frontend

Easy to update parts of any html / go template based gui

and also easy to extend in a decoupled way with plugins for other gui elements etc .

I have been using htmx for gui where you want to update parts in real time . Htmx can use WS or SSE to update the gui html is response to bsckend events

Implement Service-Agnostic Context for Notification Service

The goal of this issue is to build a service-agnostic context for the Notification Service from scratch. By employing a factory pattern, we aim to provide the Notification Service the flexibility to adapt different notification service providers (like Firebase, OneSignal, etc.) without impacting the internal workings of the system.

Tasks:

  • Define an interface that outlines the essential methods for notification operations such as Send, Receive, Delete, UpdateStatus, etc.
  • Implement a factory pattern to instantiate the appropriate notification service provider based on configuration or runtime requirements.
  • Develop an initial implementation using a placeholder or dummy notification service that adheres to the defined interface.
  • Integrate this factory and interface into the existing Notification Service codebase.
  • Write unit tests to confirm that the Notification Service works as expected with the dummy implementation.

Acceptance Criteria:

  • Notification Service should be able to operate with different notification service providers without changes to the internal services.
  • Unit tests confirm that the new implementation meets the expected behavior.

Fiber Setup

  • Integrated Fiber for fast HTTP requests.
  • Created essential middleware.

Implement Real-Time User Presence in Chat Rooms

Implement a real-time system to indicate the online/offline status of users in a chat room. The feature will involve both server-side logic and WebSocket notifications to inform room participants of any status changes.

Requirements:

  • API Endpoint: Extend existing APIs to handle the online/offline presence of users. Add presence information to relevant data models. Consider a status field with values like online, offline, away, etc.
  • Event Types: Define event types to communicate user presence status.

EventTypeUserOnline: User has come online.
EventTypeUserOffline: User has gone offline.
EventTypeUserAway: User is temporarily away.

  • WebSocket Notification: Notify room participants of any changes in user presence via WebSockets.
  • Persistence: Store the latest presence information in the database, so new room participants can get up-to-date info.

Success Criteria:

  • Users in a chat room should see accurate, real-time updates on the online/offline status of room participants.
  • User presence information should be persistent and retrievable for future reference.

Expired discord invite link

As the title says, the discord invite link in the README is expired.

I really like what you are doing here as it is pretty hard to find good information on how to do DDD/Clean Architecture well in go and I wanted to come on to ask a few questions.

No RSA Certificate file found

Discussed in #23

Originally posted by abird August 30, 2023
I followed the installation instructions and when I do "go run ." I get a "No RSA Certificate file found" message. I'm running on MacOS 13.4.1.

Implement "Show 'typing...' status" in Chat Rooms

Implement a real-time update system to notify all users in a chat room when someone starts or stops typing. The feature will be implemented using a POST API endpoint and WebSocket notifications.

Requirements:

  • API Endpoint: Create a new POST API endpoint /room/:roomID/event for the typing event. This endpoint will accept an eventType to indicate whether typing has started or stopped.

Sample API Contract:

POST /room/:roomID/event { "eventType": "typing.started" }

  • Event Types: Two event types should be supported:

EventTypeTypingStart ("typing.started"): User has started typing.
EventTypeTypingStop ("typing.stopped"): User has stopped typing.

  • WebSocket Notification: Once the server receives the API request, it should broadcast this event to all users in the room using WebSockets.
  • Rate Limiting: Implement rate limiting for this feature to avoid unnecessary network calls. For example, limit the number of "typing started" and "typing stopped" events per user per second.

Success Criteria:

  • Users in the same room should see real-time updates when someone starts or stops typing.
  • The feature should be resilient and optimized, adhering to best practices.

Create an Example Client

To be able to showcase the system, we need to create an example client

  • Set up a new Vue.js(might change) project as an example client to connect with the NatterNet backend.
  • Implement basic chat functionality, allowing users to join rooms, send messages, and receive notifications.
  • Make sure the client is compatible with the current WebSocket implementation in the NatterNet backend.
  • Provide comprehensive documentation to guide users on how to set up and use the example client.

Support Different Message Types - Image

  • Add support for image uploads to the server.
  • Implement a feature to preview image messages in chat.
  • Create a new message type in the chat domain to handle images.

Convert MongoDB Context into a Factory for Database Agnosticism

The goal of this issue is to refactor our MongoDB context into a factory pattern. This will enable us to easily switch between different database adapters without affecting the internal packages or application logic. The internal packages should be unaware of the database structure, and this refactor will help us achieve that level of abstraction.

Tasks:

  • Create an interface that defines all the methods required for data manipulation (e.g., Insert, Update, Delete, Find, etc.)
  • Implement the factory pattern to produce instances of different database adapters.
  • Refactor the existing MongoDB context to conform to the new interface.
  • Update the application logic to use the new factory and interface, replacing any direct MongoDB calls.
  • Test to ensure that the existing functionality remains intact after the refactor.

Acceptance Criteria:

  • All internal packages should be able to perform CRUD operations without being aware of the underlying database structure.
  • It should be easy to plug in a new database adapter (like MySQL, PostgreSQL, etc.) without modifying the internal packages.
  • The existing test suite should pass without any failures.

Enable Message Editing and Deleting in Chat Rooms

Implement functionality that allows users to edit or delete their messages in chat rooms. This will enhance user experience by allowing corrections and removals.

Requirements:
API Endpoints: Extend existing APIs to handle the editing and deleting of messages. The operations should be restricted to the original message author.

Sample API Extensions:

PUT /message/:messageID/edit
DELETE /message/:messageID/delete
  • Event Types: Define event types to communicate message edit and delete actions.

EventTypeMessageEdited: Message has been edited.
EventTypeMessageDeleted: Message has been deleted.
WebSocket Notification: Notify room participants of any message edits or deletes via WebSockets.

  • Database Changes: Ensure the edited message is updated in the database, and deleted messages are either removed or flagged as deleted, depending on your data retention policy.
  • Client-Side Behavior: Update the frontend to reflect these changes in real-time without requiring a page reload. (Note: While this task focuses on the backend, the frontend will also need adjustments.)
  • Testing: Include unit and integration tests to confirm that the feature functions as expected.

Success Criteria:

  • Users should be able to edit their own messages.
  • Users should be able to delete their own messages.
  • All participants in the room should be notified of these actions in real-time.

Implement Service-Agnostic Storage Context

The objective of this task is to design and implement a service-agnostic context for the storage system. Utilizing a factory pattern, the goal is to create a system flexible enough to adapt to various storage solutions (such as AWS S3, Google Cloud Storage, local filesystem, etc.) without affecting the existing application layers.

Tasks:

  • Define a Storage interface that includes essential methods for storage operations like Upload, Download, Delete, List, etc.
  • Implement a factory pattern to generate instances of the appropriate storage service provider, based on configuration or runtime requirements.
  • Create a basic initial implementation using a placeholder or dummy storage service that complies with the defined interface.
  • Integrate this factory and interface into the existing storage service codebase.
  • Write unit tests to verify the correct behavior of the service-agnostic storage context.

Acceptance Criteria:

  • The storage service must be capable of interacting with multiple storage service providers without requiring modifications to the internal application layers.
  • Unit tests should validate that the new implementation works as expected, adhering to the defined interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.