This project is a real-time web application built in Go with a React frontend. It allows users to submit content through a form and uses Redis Pub/Sub and WebSocket for real-time notifications. Submitted content is stored in a MySQL database.
The system supports both user notifications via user input and clock-based events to simulate real-time triggers.
- Project Overview
- Features
- Real-World Applications
- System Architecture
- Installation
- Usage
- API Endpoints
- Database
- Middleware
- Test Output
- Docker Deployment
- Contributing
The Realtime Notification System integrates a Go backend, Redis-based event-driven notifications, and a React frontend. It allows:
- user notifications through user input via the custom notification input panel on the frontend.
- Clock-based events to simulate real-time notifications.
- WebSocket connections for instant updates to the frontend.
- Submit text-based content via the frontend input panel or a POST request.
- Store submitted content in a MySQL database.
- Redis Pub/Sub for event-driven notifications.
- WebSocket integration for real-time updates.
- Clock-based events to simulate real-time triggers.
- Frontend built with React and TypeScript.
- Middleware for handling CORS between backend and frontend.
This system drives real-time engagement across multiple industries. Below are some of its key use cases:
- Deliver breaking news alerts and content recommendations instantly.
- Boost user engagement and ad revenue with timely notifications.
- Notify players about live events, rewards, and leader-board updates.
- Encourage in-app purchases and enhance player retention.
- Provide real-time stock alerts, transaction updates, and payment notifications.
- Help users manage finances and stay ahead with market insights.
- Send updates on order tracking, promotions, and stock availability.
- Improve sales conversions and enhance customer satisfaction.
- Notify users about mentions, messages, and new followers.
- Keep the user base engaged and connected.
- Alert on system anomalies, equipment failures, and temperature changes.
- Enable fast responses to prevent downtime and ensure safety.
- Send appointment reminders, lab results, and prescription updates.
- Reduce missed appointments and improve patient engagement.
- Provide reminders for meetings, events, and webinars.
- Improve participation and ensure better time management.
This format:
- Uses bullet points for clarity.
- Keeps each use case brief and highlights the core impact.
- Aligns with the rest of the README structure for a consistent look.
Here is a system design diagram for the system
- Go (v1.23 or later)
- Node.js and npm (for frontend)
- Redis Server
- MySQL Server
git clone https://github.com/yourusername/Realtime-Notification-System.git
cd Realtime-Notification-System
-
Install Go Dependencies:
cd backend_system go mod tidy
-
Set Up MySQL Database:
mysql -u your_username -p realtime_notification_system < backend_system/server/mysql_schema.sql
-
Run Redis Server:
redis-server
-
Navigate to Frontend Directory:
cd frontend_application
-
Install Frontend Dependencies:
npm install
-
Copy
.env.example
to.env
:cp .env.example .env
-
Update Database Credentials in
.env
:MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DB=realtime_notification_system MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306
cd backend_system/server
go run main.go
cd frontend_application
npm start
Submit content via the frontend custom notification input panel or using Postman:
curl -X POST -d "content=Manual Notification" http://localhost:8080/submit
Every minute, a clock-based event publishes a notification via Redis to simulate real-time events.
- POST /submit: Submits content to the database and triggers a manual notification.
- WebSocket /ws: Listens for real-time notifications from Redis.
The MySQL database stores submitted content using the following schema:
Added a init.db (backend_system/sql
folder) file for configuring the database
The CORS middleware allows the frontend to communicate with the backend. It is implemented in backend_system/middleware_layer/cors.go
and applied to backend routes.
User Notification Submission (Front End):
User Notification Submission (Postman):
Database Content View (Event Driven Notifications):
Database Content View (User Notifications):
Did following changes and configurations made for Docker deployment:
-
Docker Compose File:
- Added
docker-compose.yml
to coordinate services: backend, frontend, MySQL, and Redis. - Specified health checks and dependencies for the backend to wait until MySQL and Redis are ready.
- Added
-
Environment Variables:
- Extended the
.env.example
file to include Docker-specific variables. - Updated Redis and MySQL connection settings from
localhost
to their Docker container names.
- Extended the
-
Redis and MySQL Client Changes:
- Changed Redis connection in the backend code to
redis:6379
. - Changed MySQL connection in the backend to
mysql:3306
.
- Changed Redis connection in the backend code to
-
SQL Schema File for Database Setup:
- Added a template SQL file (
permission.sql.template
) schema file to add permissions are correctly, if the database does not grant them initially.
- Added a template SQL file (
-
Backend and Frontend Dockerfiles:
- Created separate Dockerfiles for backend and frontend services to containerize the applications efficiently.
-
Build and Start Docker Containers:
docker-compose up --build
-
Verify Services:
-
Ensure MySQL, Redis, backend, and frontend services are running correctly with:
docker ps
-
-
Access Frontend:
- Open http://localhost:3000 in your browser.
-
Backend API:
-
Test the backend API via Postman or curl:
curl -X POST -d "content=Hello Docker" http://localhost:8080/submit
-
Contributions are welcome! Fork the repository and submit a pull request.