0% found this document useful (0 votes)
22 views6 pages

Event Management System Code Guide

The document outlines the implementation of an Event Management System using Express.js and SQLite. It includes setup instructions, database schema for users, events, tickets, and bookings, as well as Express routes for managing events and rendering HTML templates. The project follows a three-tier architecture with distinct components for the front-end, back-end, and database management.

Uploaded by

Omolewa Oreweme
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

Event Management System Code Guide

The document outlines the implementation of an Event Management System using Express.js and SQLite. It includes setup instructions, database schema for users, events, tickets, and bookings, as well as Express routes for managing events and rendering HTML templates. The project follows a three-tier architecture with distinct components for the front-end, back-end, and database management.

Uploaded by

Omolewa Oreweme
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Event Management System - Code Implementation

1. Setup and Dependencies

const express = require('express');

const sqlite3 = require('sqlite3').verbose();

const bodyParser = require('body-parser');

const path = require('path');

const app = express();

const db = new [Link]('./[Link]');

2. Database Schema (SQL)

-- Users table: Stores organiser and attendee information

CREATE TABLE users (

user_id INTEGER PRIMARY KEY AUTOINCREMENT,

user_name TEXT NOT NULL,

user_type TEXT NOT NULL -- 'organiser' or 'attendee'

);

-- Events table: Stores event details

CREATE TABLE events (

event_id INTEGER PRIMARY KEY AUTOINCREMENT,

title TEXT NOT NULL,

description TEXT NOT NULL,

event_date TEXT NOT NULL,


state TEXT NOT NULL, -- 'draft' or 'published'

created_at TEXT NOT NULL,

updated_at TEXT

);

-- Tickets table: Stores ticket information for each event

CREATE TABLE tickets (

ticket_id INTEGER PRIMARY KEY AUTOINCREMENT,

event_id INTEGER NOT NULL,

ticket_type TEXT NOT NULL, -- 'full-price' or 'concession'

price REAL NOT NULL,

quantity INTEGER NOT NULL,

FOREIGN KEY (event_id) REFERENCES events(event_id)

);

-- Bookings table: Stores bookings made by attendees for events

CREATE TABLE bookings (

booking_id INTEGER PRIMARY KEY AUTOINCREMENT,

user_id INTEGER NOT NULL,

event_id INTEGER NOT NULL,

ticket_type TEXT NOT NULL,

quantity INTEGER NOT NULL,

booking_date TEXT NOT NULL,

FOREIGN KEY (user_id) REFERENCES users(user_id),

FOREIGN KEY (event_id) REFERENCES events(event_id)

);
3. Express Routes Implementation

// Home route: Displays all events

[Link]('/', (req, res) => {

[Link]('SELECT * FROM events WHERE state="published"', [], (err, events) => {

if (err) {

throw err;

[Link]('index', { events });

});

});

// Add event form

[Link]('/add-event', (req, res) => {

[Link]('add-event');

});

// Handle new event submission

[Link]('/add-event', (req, res) => {

const { title, description, event_date } = [Link];

const state = 'draft'; // default state for new events

const createdAt = new Date().toISOString();

[Link]('INSERT INTO events (title, description, event_date, state, created_at) VALUES (?, ?,

?, ?, ?)',

[title, description, event_date, state, createdAt], function(err) {

if (err) {
return [Link]([Link]);

[Link]('/');

});

});

4. HTML Template for Published Events

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Event Manager</title>

<link rel="stylesheet" href="/[Link]">

</head>

<body>

<h1>Published Events</h1>

<ul>

<% [Link](event => { %>

<li>

<h3><%= [Link] %></h3>

<p><%= [Link] %></p>

<p>Date: <%= event.event_date %></p>

<a href="#">Book Tickets</a>

</li>

<% }) %>
</ul>

<a href="/add-event">Add New Event</a>

</body>

</html>

5. CSS for the Webpage

/* [Link] */

body {

font-family: Arial, sans-serif;

margin: 0;

padding: 0;

h1 {

text-align: center;

margin-top: 20px;

ul {

list-style-type: none;

padding: 0;

li {

padding: 10px;
margin-bottom: 10px;

border: 1px solid #ddd;

background-color: #f9f9f9;

a{

text-decoration: none;

color: #007bff;

6. Final Remarks

The implementation of the Event Management System allows an organiser to create and

manage events,

while attendees can view and book these events. The routes are set up to handle event

creation, viewing,

and booking. A basic database schema has been designed to store user, event, ticket, and

booking information.

The HTML templates are dynamically rendered using EJS, and CSS is used to style the

pages. The [Link]

framework handles routing, and SQLite stores the data. This project follows a three-tier

architecture,

with separate components for the front-end, back-end, and database.

Common questions

Powered by AI

The database tables are strategically designed to facilitate core functions of the Event Management System. The "events" table stores event details and distinguishes between different states such as 'draft' and 'published', enabling controlled event workflows from creation to publicizing . The "tickets" table associates ticket types and quantities with specific events via event_id, facilitating ticket management . The "bookings" table records user participation by linking user_id and event_id, supporting the view and booking functionalities . These interlinked tables ensure thorough tracking and management of all event-related transactions, enabling efficient event organization and attendee engagement .

Using Express and SQLite in combination for the Event Management System has several security implications. Express, being a flexible Node.js framework, could be vulnerable to common web application threats like Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF) if not properly configured or patched . SQLite, although lightweight and fast, lacks certain security features present in larger database management systems, such as robust access control and encryption at rest. This setup requires careful handling of input validation, secure session management, and implementing additional safeguards like HTTPS to ensure data integrity and confidentiality .

Using middleware libraries like body-parser enhances the functionality of the Event Management System by simplifying the process of parsing incoming request bodies and making them easily accessible within routes. This is crucial for handling form submissions where data sent in POST requests needs to be extracted and processed . It allows developers to focus on their specific application logic rather than manually parsing raw request data, thus accelerating development and reducing the likelihood of errors .

The three-tier architecture of the Event Management System segregates its structure into three distinct components: front-end, back-end, and database. This separation enables efficient application management and development as each layer can be developed, managed, and updated independently without impacting the others, facilitating scalability and maintenance . The front-end handles user interaction and presentation, the back-end manages business logic and server-side processing using Express.js, and the database ensures persistent data storage with SQLite. This modular approach allows for clearer separation of concerns and better resource allocation across development processes, enhancing overall system efficiency .

The "users" table stores information about organizers and attendees, each identified by a unique user_id which functions as the primary key . This table integrates with the Event Management System by linking user identities to both events and bookings. It helps manage who can create events (organisers) and who book them (attendees). Furthermore, it is a fundamental part of maintaining and enforcing relational integrity within the system, as user_id is used as a foreign key in the "bookings" table, ensuring that bookings are aligned with existing users .

The Express route for displaying published events operates by querying the "events" table to select events where the state is 'published'. This route uses Express.js to handle the HTTP GET request at the root path . The queried data is passed to an EJS template which dynamically generates an HTML page displaying the events . Technologies involved include Express.js for server-side logic, EJS for templating, and SQLite for database interaction .

The event creation flow is designed so that new events are initially saved as drafts by setting the default state for any newly submitted event to 'draft'. When an organizer submits a new event through the '/add-event' route, the system processes this submission and inserts the event data into the "events" table with 'draft' as the default state, as indicated in the route implementation . This ensures events are reviewed or completed before being published for attendees to view and book .

Rendering HTML templates with EJS dynamically can present technical challenges such as managing state between server-side logic and client-side representation, correctly escaping input to avoid XSS attacks, and efficiently updating pages without excessive server requests. These challenges can be addressed by maintaining a clean separation of logic and presentation, utilizing middleware for data validation, ensuring proper input sanitization, and integrating AJAX for partial page updates, reducing server load and improving user experience . Keeping the EJS files modular and organized also aids in managing template logic effectively .

The system's structure supports both the addition of new events by organizers and booking by attendees through the organization of its database tables and Express routes. Organizers can add events via the '/add-event' route which processes input data and saves them as drafts in the "events" table . For booking, attendees interact with paths that list published events and allow booking through forms that update the "bookings" table . This segregation ensures that each user's interactions are accurately reflected in the system according to their role, providing a streamlined experience for both creating and engaging with events .

Styling the Event Management System's webpage with CSS enhances user interaction by improving the visual appeal and overall usability of the interface. CSS controls the layout and presentation, such as font style, text alignment, and background colors, creating a more engaging and accessible experience. It also aids in emphasizing important elements like event titles and booking links, ultimately making the interface intuitive and pleasant for users .

You might also like