An open API service indexing awesome lists of open source software.

https://github.com/aivmic/event_system

An ASP.NET Core event management API that allows users to create, view, update, and delete event categories, events, and ratings.
https://github.com/aivmic/event_system

asp-net-core jwt react restful-api session

Last synced: 2 months ago
JSON representation

An ASP.NET Core event management API that allows users to create, view, update, and delete event categories, events, and ratings.

Awesome Lists containing this project

README

          

# Event Management System

An ASP.NET Core event management API that allows users to create, view, update, and delete event categories, events, and ratings. This system implements role-based authorization using JWT to secure endpoints, ensuring only authenticated users with appropriate roles can perform specific actions. Users can register as event organizers, manage their events, and leave ratings, while admins have control over all resources.

## Features:

Event Categories: Create and manage different events of categories.
Events: Organize events within categories, with options for detailed descriptions, schedules, and pricing.
Ratings: Add and manage event ratings.
Secure Endpoints: JWT-based authentication with user roles and permissions to restrict actions by role.
Scalability: Built to handle future extensions with a modular, RESTful API design.

## Functional Requirements for Event Management System

User Management
Users can register, log in, and log out of the system.
Each user must have a unique login name for identification.
The system supports two primary roles:
Admin: Full control over all resources.
User: Manage their events and leave ratings.

Role-Based Authorization
Endpoints are secured with JWT-based authentication.
Authorization ensures:
Admins have access to all API endpoints.
Event Organizers can only access their resources and rate events.

Event Categories

Create Event Categories
Admins can create new event categories with the following details:
Category name (required).
Description (optional).

Delete Event Categories
Admins can delete categories that do not have any associated events.

Events

Create Events
Event Organizers can create events under specific categories.
Required fields:
Event name.
Description.
Schedule (start and end times).
Pricing information.
Associated category.

View Events
All users can view a list of events.
Users can filter events by:
Category.
Name.
Event details include:
Name, description, schedule, pricing, category, and average rating.

Update Events
Event Organizers can update their events.

Delete Events
Event Organizers can delete their events.
Admin can delete events.

Ratings

Add Ratings
Authenticated users can leave ratings for events.
Required fields:
Rating score (1 to 5).

View Ratings
Users can view ratings for a specific event, including:
Average rating score.

Secure Endpoints

Authentication and Authorization
JWT tokens are required for accessing any secure endpoint.
Tokens are verified for each request to ensure validity and role permissions.

Role-Based Permissions
Admins:
Full CRUD access to event categories, events, and ratings.
Event Organizers:
CRUD access to their events.
Create ratings.
General Users:
View events and ratings.

Scalability and Modularity

The API design follows RESTful principles to ensure:
Easy addition of new features or modules.
Clean and modular code structure for scalability.
Endpoints should include pagination for retrieving large datasets (e.g., events and ratings).
Support for localization and time-zone management for global users.

This project follows REST principles and can be extended for various event management functionalities.

## UML Deployment diagram.

![image](https://github.com/user-attachments/assets/e86c81ba-4d19-494b-9c14-179efb37d030)

## Conslusions

The Event Management System built using ASP.NET Core demonstrates a robust and scalable API capable of meeting diverse event management needs. With its modular design and adherence to REST principles, the system offers seamless CRUD operations for event categories, events, and ratings while maintaining high security through JWT-based role authorization.

Key achievements of this project include:

Secure Access: The implementation of JWT for authentication and role-based authorization ensures that users and admins operate within their respective scopes, enhancing security and accountability.
User-Centric Design: Features like event filtering, detailed event views, and user-friendly ratings provide a comprehensive and intuitive experience.
Admin Controls: Admin users benefit from full control over the platform, enabling efficient management of resources such as event categories and ratings.
Scalability: With RESTful design principles, the API is prepared for future enhancements, such as integrating new modules or scaling for larger datasets.

This system stands as a versatile and secure solution for event organizers, attendees, and administrators, capable of adapting to growing user needs and evolving requirements in event management.

# Images from website

Main page

![image](https://github.com/user-attachments/assets/3313a934-5d39-40f5-a207-2ff0adc620ce)

Inventory page

![image](https://github.com/user-attachments/assets/d8271da5-10af-4b9e-b3c1-b1d49335c111)

Admin panel page

![image](https://github.com/user-attachments/assets/d3842cf1-35ce-45fa-8a59-0cdbda3f9d56)

# Open API documentation

openapi: 3.0.1
info:
title: My API
version: v1
paths:
/api/categories:
get:
summary: Get all categories
tags:
- Event_system
responses:
'200':
description: A list of categories
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CategoryDto'
example:
- id: 1
name: Music
description: Music events
- id: 2
name: Sports
description: Sports events
'400':
description: Bad request
'500':
description: Internal server error
post:
description: Create a new category
tags:
- category
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCategoryDto'
example:
name: "Music"
description: "Music events and concerts"
required: true
responses:
'201':
description: Category created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CategoryDto'
example:
id: 1
name: "Music"
description: "Music events and concerts"
'400':
description: Invalid input data
content:
application/json:
example:
message: "Bad request due to validation errors"
'422':
description: Unprocessable entity - validation failed
content:
application/json:
example:
errors:
name: "Name is required and must be between 3 and 50 characters"
description: "Description must be between 5 and 200 characters"

'/api/categories/{categoryId}':
get:
tags:
- category
summary: Get category by ID
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
responses:
'200':
description: Category details retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CategoryDto'
example:
id: 1
name: "Music"
description: "Music events and concerts"
'404':
description: Category not found
put:
tags:
- category
summary: Update a category
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateCategoryDto'
example:
description: "Updated description for music events"
required: true
responses:
'200':
description: Category updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CategoryDto'
'404':
description: Category not found
'400':
description: Invalid input data
delete:
tags:
- category
summary: Delete a category
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
responses:
'200':
description: Category deleted successfully
'404':
description: Category not found

'/api/categories/{categoryId}/events':
get:
tags:
- event
summary: Get all events for a category
responses:
'200':
description: A list of events for the category
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/EventDto'
example:
- id: 1
title: "Concert"
description: "A live music concert"
startDate: "2024-10-01T19:00:00Z"
endDate: "2024-10-01T22:00:00Z"
price: 50.00
- id: 2
title: "Festival"
description: "An outdoor music festival"
startDate: "2024-10-05T12:00:00Z"
endDate: "2024-10-05T23:00:00Z"
price: 75.00
'404':
description: Category not found
post:
tags:
- event
summary: Create a new event in a category
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEventDto'
example:
title: "Concert"
description: "A live music concert"
startDate: "2024-10-01T19:00:00Z"
endDate: "2024-10-01T22:00:00Z"
price: 50.00
required: true
responses:
'201':
description: Event created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/EventDto'
'404':
description: Category not found
'400':
description: Invalid input data

'/api/categories/{categoryId}/events/{eventId}':
get:
tags:
- event
summary: Get event by ID for a category
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
- name: eventId
in: path
required: true
schema:
type: integer
format: int32
responses:
'200':
description: Event details retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/EventDto'
example:
id: 1
title: "Concert"
description: "A live music concert"
startDate: "2024-10-01T19:00:00Z"
endDate: "2024-10-01T22:00:00Z"
price: 50.00
'404':
description: Event not found

'/api/categories/{categoryId}/events/{eventId}/ratings':
get:
tags:
- rating
summary: Get all ratings for an event
responses:
'200':
description: A list of ratings for the event
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/RatingDto'
example:
- id: 1
stars: 5
- id: 2
stars: 4
'404':
description: Event not found
post:
tags:
- rating
summary: Add a rating to an event
parameters:
- name: categoryId
in: path
required: true
schema:
type: integer
format: int32
- name: eventId
in: path
required: true
schema:
type: integer
format: int32
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateRatingDto'
example:
stars: 5
required: true
responses:
'201':
description: Rating created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/RatingDto'
'404':
description: Event not found
/api/accounts:
post:
summary: Register a new user
tags:
- Authentication
requestBody:
description: User registration details
content:
application/json:
schema:
$ref: '#/components/schemas/RegisterUserDto'
example:
userName: "johndoe"
email: "johndoe@example.com"
password: "StrongPassword123"
required: true
responses:
'201':
description: User registered successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserDto'
example:
userId: "12345"
username: "johndoe"
email: "johndoe@example.com"
'422':
description: Username already taken or validation failed
content:
application/json:
example:
errors:
- "Username already taken"
/api/login:
post:
summary: User login
tags:
- Authentication
requestBody:
description: User login details
content:
application/json:
schema:
$ref: '#/components/schemas/LoginDto'
example:
userName: "johndoe"
password: "StrongPassword123"
required: true
responses:
'200':
description: Login successful
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessfulLoginDto'
example:
accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
refreshToken: "dGhpc2lzYXJlZnJlc2h0b2tlbg=="
'422':
description: Username or password incorrect
content:
application/json:
example:
message: "Username or password was incorrect."
/api/accessToken:
post:
summary: Refresh access token
tags:
- Authentication
responses:
'200':
description: Access token refreshed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessfulLoginDto'
example:
accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
refreshToken: "bmV3cmVmcmVzaHRva2VuZGF0YQ=="
'422':
description: Refresh token invalid or session expired
content:
application/json:
example:
message: "Invalid refresh token or session expired."
/api/logout:
post:
summary: Logout user
tags:
- Authentication
responses:
'200':
description: Logout successful
'422':
description: Invalid session or refresh token
content:
application/json:
example:
message: "No valid session found."

components:
schemas:
CategoryDto:
type: object
properties:
id:
type: integer
format: int32
name:
type: string
example: Music
description:
type: string
example: "Music events"
required:
- name
- description

CreateCategoryDto:
type: object
properties:
name:
type: string
minLength: 3
maxLength: 50
example: "Music"
description:
type: string
minLength: 5
maxLength: 200
example: "Events related to music"
required:
- name
- description

UpdateCategoryDto:
type: object
properties:
description:
type: string
minLength: 5
maxLength: 200
example: "Updated description for category"
required:
- description

EventDto:
type: object
properties:
id:
type: integer
format: int32
title:
type: string
description:
type: string
startDate:
type: string
format: date-time
endDate:
type: string
format: date-time
price:
type: number
format: decimal
required:
- title
- description
- startDate
- endDate
- price

CreateEventDto:
type: object
properties:
title:
type: string
minLength: 3
maxLength: 50
example: "Concert"
description:
type: string
minLength: 5
maxLength: 200
example: "A live music concert"
startDate:
type: string
format: date-time
endDate:
type: string
format: date-time
price:
type: number
format: decimal
required:
- title
- description
- startDate
- endDate
- price

UpdateEventDto:
type: object
properties:
title:
type: string
description:
type: string
minLength: 5
maxLength: 200
startDate:
type: string
format: date-time
endDate:
type: string
format: date-time
price:
type: number
format: decimal
categoryId:
type: integer
format: int32
required:
- title
- description
- startDate
- endDate
- price
- categoryId

RatingDto:
type: object
properties:
id:
type: integer
format: int32
stars:
type: integer
format: int32
minimum: 1
maximum: 5
required:
- stars

CreateRatingDto:
type: object
properties:
stars:
type: integer
format: int32
minimum: 1
maximum: 5
required:
- stars

UpdateRatingDto:
type: object
properties:
stars:
type: integer
format: int32
minimum: 1
maximum: 5
required:
- stars

RegisterUserDto:
type: object
properties:
userName:
type: string
email:
type: string
format: email
password:
type: string
required:
- userName
- email
- password
UserDto:
type: object
properties:
userId:
type: string
username:
type: string
email:
type: string
format: email
LoginDto:
type: object
properties:
userName:
type: string
password:
type: string
required:
- userName
- password
SuccessfulLoginDto:
type: object
properties:
accessToken:
type: string
refreshToken:
type: string
required:
- accessToken
- refreshToken

responses:
singleTopic:
description: A category
content:
application/json:
schema:
type: object
items:
$ref: "#/components/schemas/topic"
example:
- id: 1
title: "OpenAPI Best Practices"
description: "Discussion about best practices when using OpenAPI"
unprocessableEntity:
description: Unprocessable entity response
content:
application/problem+json:
schema:
type: object
items:
$ref: "#/components/schemas/problemDetails"
example:
type: "https://tools.ietf.org/html/rfc4918#section-11.2"
title: "Unprocessable Entity"
status: 422
errors:
Name:
- "'Name' must not be empty."