A scalable and tamper-proof event logging platform designed for distributed applications. This system provides RESTful APIs for logging and querying events, supports real-time updates via WebSocket, and includes a basic frontend for interaction.
- Event Logging API: Log events with metadata like event type, timestamp, source application ID, and payload.
- Tamper-Proof Design: Events are chained with cryptographic hashes for integrity.
- Search and Query: Filter events by type, source, and date range.
- Real-Time Updates: WebSocket support for real-time log streaming.
- Basic Frontend: Simple interface to log and view events.
- Scalability: Designed to handle large datasets with MongoDB's indexing.
- Node.js: Server-side runtime.
- Express.js: Web framework.
- MongoDB: NoSQL database.
- WebSocket: Real-time updates.
- Crypto: Cryptographic hashing.
- HTML, CSS, JavaScript: Basic user interface.
event-logging-system/
│
├── backend/
│ ├── app.js # Main server entry point
│ ├── routes/
│ │ ├── events.js # API routes for events
│ │ └── real_time.js # WebSocket route
│ ├── models/
│ │ └── Event.js # Mongoose schema
│ ├── utils/
│ │ └── hashUtils.js # Hashing utility functions
│ ├── config/
│ │ └── db.js # MongoDB connection
│ ├── package.json # Node.js dependencies
│ └── .env # Environment variables
│
├── frontend/
│ ├── index.html # Frontend HTML
│ ├── style.css # Frontend CSS
│ ├── script.js # Frontend JavaScript
│
└── README.md # Project Documentation
- Node.js (v14 or higher)
- MongoDB (Ensure MongoDB is running locally or use a cloud instance)
- Web browser (for the frontend)
- Navigate to the
backendfolder:cd backend - Install dependencies:
npm install
- Create a
.envfile:Add the following content to thetouch .env
.envfile:PORT=5000 MONGO_URI=mongodb://localhost:27017/event_logging - Start the server:
node app.js
The backend will run at http://localhost:5000.
- Navigate to the
frontendfolder. - Open
index.htmlin your browser.
Log a new event.
{
"eventType": "user_login",
"timestamp": "2024-11-21T12:34:56Z",
"sourceAppId": "APP001",
"payload": {
"userId": "123",
"ipAddress": "192.168.1.1"
}
}{
"message": "Event logged successfully!",
"data": {
"eventType": "user_login",
"timestamp": "2024-11-21T12:34:56Z",
"sourceAppId": "APP001",
"payload": { "userId": "123", "ipAddress": "192.168.1.1" },
"previousHash": "0",
"currentHash": "abc123..."
}
}Query events by filters.
eventType(optional)sourceAppId(optional)startDate(optional, e.g.,2024-11-20T00:00:00Z)endDate(optional, e.g.,2024-11-21T23:59:59Z)
{
"count": 2,
"data": [
{
"eventType": "user_login",
"timestamp": "2024-11-21T12:34:56Z",
"sourceAppId": "APP001",
"payload": { "userId": "123", "ipAddress": "192.168.1.1" },
"previousHash": "0",
"currentHash": "abc123..."
}
]
}- Log Event: Click "Log Event" to log a new event (predefined data).
- View Events: Click "View Events" to fetch and display all logged events.
Enable real-time logging with WebSocket:
- Use a WebSocket client like
wscat:wscat -c ws://localhost:5000
- Monitor real-time event streams.
- Implement a dashboard for better event visualization.
- Add support for distributed logging.
- Enhance real-time features with client-side integration.
- Fork the repository.
- Create a new branch (
feature/your-feature). - Commit your changes.
- Push to your branch.
- Create a pull request.
This project is licensed under the MIT License.