Coder Social home page Coder Social logo

angular2guy / angularpwamessenger Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 18.0 6.41 MB

This is an encrypted Angular 18 PWA messenger application with an AI friend that can work offline and has a reactive Spring Boot 3 backend with a MongoDB to store the messages in a clean architecture. With a Kubernetes setup. Structurizr is used for C4 diagrams.

Home Page: http://angular2guy.wordpress.com

License: Apache License 2.0

Dockerfile 0.08% JavaScript 0.76% TypeScript 52.64% HTML 5.49% Java 36.12% Shell 0.94% SCSS 2.19% Mustache 0.43% ASL 1.33%
spring-boot angular java typescript mongodb webflux docker kubernetes helm webcryptoapi clean-architecture archunit spring-actuator angular-components springboot3 structurizr webrtc ollama springai angular18

angularpwamessenger's Introduction

This is an example of a Progressive Web Application(PWA) with an Angular frontend and a Spring Boot backend with MongoDb.

Author: Sven Loesekann

Technologies: PWA, WebRtc, WebSocket(Frontend, Backend), Angular, Angular-Cli, Angular-Material, Typescript, Spring Boot, Java, Spring Webflux, MongoDB, Maven, Docker

CodeQL

Articles

Backend improvement

The Spring Boot MongoDb server can now handle more concurrent users.

What is the goal?

The goal is to provide an Angular based Progressive Web App with a backend server that offers chats or video calls. To do that the PWA uses the Angular PWA support and Angular Material. The backend server is written with Spring Boot and uses its Webflux features with the MongoDB database in clean architecture. For development the project uses an in memory MongoDB to be just cloned and ready to run. More documentation can be found in the blog.

What is it?

The application is an encrypted chat system that can be run offline. The PWA is served by the server like any website and installs a service worker. Then it can run offline because the PWA stores the data locally in the browser. The login, the chat history and sending new messages work offline. The messages can be text of photos taken with the devices camera. When the PWA is online again the stored pending messages are send to the server and it is checked for new messages. Adding new contacts and signing in only works online. The backend server stores only the pending messages and the available contacts and is implemented in clean architecture. That is checked with an ArchUnit test. The message texts are send encrypted and are stored encrypted. (If you delete your browsers indexed DB your chat history and your contacts are gone!).
The video calls are done with WebRtc in the Angular frontend in the browser and need the ability of the browsers to connect to each other. The WebSocket is used for signaling and is supported by the Spring Boot backend.

The application has been extended to provide a bingo game. The Frontend is implemented in Angular lazy loaded standalone components and the backend is done in Spring Boot with reactive Controllers/Services/Repositories.

AI friend available as new contact

The application has been extended to provide an AI friend that can can provide companionship. It uses Spring AI to call a Ollama model that is trained with psychological/philosophical data. To enable it the application has to be started with the 'ollama' profile and Ollama has to be installed or run in a docker container. The needed commands for the docker container can be found in this file.

C4 Architecture Diagrams

The project has a System Context Diagram, a Container Diagram and a Component Diagram. The Diagrams have been created with Structurizr. The file runStructurizr.sh contains the commands to use Structurizr and the directory structurizr contains the dsl file.

Minikube setup

The application can be run in a Minikube cluster. The cluster runs the docker images for the AngularPwaMessenger and the Mongodb. The Mongodb has a persistent volume to store its data between restarts. The configuraton of the application can be found in the helm directory and is done as a helm chart. It uses the resource limit support of Jdk 16 to limit memory. Kubernetes limits the cpu use and uses the startupprobes and livenessprobes that Spring Actuator provides. To run it minikube, kubectl and helm need to be installed. Further documentation can be found in the wiki.

Monitoring

The Spring Actuator interface with Prometheus interface can be used as it is described in this article:

Monitoring Spring Boot with Prometheus and Grafana

To test the setup the application has to be started and the Docker Images for Prometheus and Grafana have to be started and configured. The scripts 'runGraphana.sh' and 'runPrometheus.sh' can be used as a starting point.

Setup

MongoDB 4.4.x or newer.

Eclipse IDE for Enterprise Java and Web Developers newest version.

Maven 3.9.5 or newer.

Java 21 or newer

Nodejs 18.19.x or newer

Npm 10.2.x or newer

Angular Cli 18 or newer.

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.