Updated changes in backend
This commit is contained in:
@@ -24,7 +24,7 @@ The EMS platform addresses these challenges by offering:
|
||||
|
||||
## 2. System Architecture & Tech Stack
|
||||
|
||||
The platform is designed around a modern decoupled client-server architecture.
|
||||
The platform runs on a serverless, database-first architecture using Firebase. All backend endpoints are intercepted and resolved client-side in the browser.
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
@@ -33,31 +33,24 @@ graph LR
|
||||
Router[Component & Context Routing]
|
||||
Tailwind[Tailwind CSS & Glassmorphism UI]
|
||||
Framer[Framer Motion Animations]
|
||||
Interceptor[Fetch Interceptor firebaseBackend.ts]
|
||||
end
|
||||
|
||||
subgraph Backend [Spring Boot API Server]
|
||||
Controller[REST API Controllers]
|
||||
Security[Spring Security Config]
|
||||
Services[JPA / Hibernate Data Access]
|
||||
subgraph Backend [Firebase Cloud Platform]
|
||||
Firestore[(Cloud Firestore Database)]
|
||||
Auth[Firebase Authentication]
|
||||
end
|
||||
|
||||
subgraph Database [Relational Storage]
|
||||
MySQL[(Local MySQL ems_db)]
|
||||
end
|
||||
|
||||
React <-->|REST over HTTP| Controller
|
||||
Controller <--> Services
|
||||
Services <--> MySQL
|
||||
React <--> Interceptor
|
||||
Interceptor <-->|Firebase Client SDK| Firestore
|
||||
Interceptor <-->|Firebase Client SDK| Auth
|
||||
```
|
||||
|
||||
### Backend Specifications
|
||||
* **Core Framework:** Spring Boot 3.2.5 (Java 17)
|
||||
* **ORM & Data Access:** Spring Data JPA with Hibernate
|
||||
* **Database Driver:** MySQL Connector/J (`com.mysql.cj.jdbc.Driver`)
|
||||
* **Security:** Spring Security (Permit-all filter bypass, with role-based checks and authorization handling verified inside the controller/service scope).
|
||||
* **Cryptographic Hashing:** `BCryptPasswordEncoder` for storing/verifying user passwords.
|
||||
* **Dev Tools:** Project Lombok, Spring Boot DevTools.
|
||||
* **Port Configuration:** Runs on port `8081` (CORS-enabled for frontend origins).
|
||||
### Firebase Backend Specifications
|
||||
* **Database Service:** Cloud Firestore for real-time document storage.
|
||||
* **Data Access & Interception:** A client-side fetch interceptor implemented in `firebaseBackend.ts` intercepts all `/api/*` REST HTTP requests and handles the queries/transactions natively using the Firebase Client SDK.
|
||||
* **Authentication:** Google OAuth 2.0 and email/passcode flows, integrated with Firebase Auth and sync'd to the `ems_users` Firestore collection.
|
||||
* **Security & Roles:** Verified inside frontend routing handlers and secured using Firestore Security Rules.
|
||||
|
||||
### Frontend Specifications
|
||||
* **Core Framework:** React 19, TypeScript, Vite
|
||||
@@ -73,7 +66,7 @@ graph LR
|
||||
|
||||
## 3. Database Schema & Architecture
|
||||
|
||||
The database contains four primary entities managed via Spring Data JPA.
|
||||
The database contains four primary collections managed in Cloud Firestore.
|
||||
|
||||
```mermaid
|
||||
erDiagram
|
||||
@@ -338,16 +331,16 @@ graph TD
|
||||
## 6. Key Workflows & Logic Specs
|
||||
|
||||
### A. Real-time Conflict Auditing Engine
|
||||
During event creation, the backend validates for timing and location conflicts.
|
||||
1. The backend runs the custom JPA method `findConflictingEvents()` matching location, institution, status (`APPROVED`), and overlapping times:
|
||||
During event creation, the application validates for timing and location conflicts directly against Firestore.
|
||||
1. The frontend query helper scan the `ems_events` collection to identify overlapping bookings:
|
||||
$$\text{Start}_A < \text{End}_B \quad \text{and} \quad \text{End}_A > \text{Start}_B$$
|
||||
2. **Placement Override Case:**
|
||||
If the proposer is a `PLACEMENT` coordinator and `cancelConflicting=true` is checked:
|
||||
* The backend sets all conflicting events to `CANCELLED`.
|
||||
* The backend registers a rejection/displacement reason on the cancelled events.
|
||||
* The fetch interceptor updates all conflicting Firestore event documents' status to `CANCELLED`.
|
||||
* It registers a rejection/displacement reason on the cancelled events.
|
||||
* The placement event is saved in `PENDING_PR` (for Principal review).
|
||||
3. **General Case:**
|
||||
If conflicts exist and it is not an overridden placement, the backend throws a `409 Conflict` HTTP exception with conflicting details.
|
||||
If conflicts exist and it is not an overridden placement, a conflict message is returned and flagged to the user.
|
||||
|
||||
### B. Event Approval Pipeline
|
||||
The approval flow routes events dynamically depending on the proposer:
|
||||
@@ -387,27 +380,9 @@ This tool allows admins/HODs/Principals to duplicate schedules for new semesters
|
||||
## 7. Developer & Local Deployment Guide
|
||||
|
||||
### Prerequisites
|
||||
* Java JDK 17
|
||||
* Node.js (v18+)
|
||||
* MySQL Database Server
|
||||
|
||||
### 1. Database Setup
|
||||
1. Start your local MySQL instance.
|
||||
2. Create the target schema (automatic if configuration is active):
|
||||
```sql
|
||||
CREATE DATABASE ems_db;
|
||||
```
|
||||
3. Update the credentials in `backend/src/main/resources/application.properties` (defaults: username `root`, password `Abiram@07`).
|
||||
|
||||
### 2. Launch Backend Server
|
||||
1. Navigate to the `backend` folder.
|
||||
2. Compile and run using Maven:
|
||||
```bash
|
||||
mvnw spring-boot:run
|
||||
```
|
||||
3. The server starts at `http://localhost:8081`. The `DataInitializer` runs on startup to seed the default user accounts.
|
||||
|
||||
### 3. Launch Frontend Client
|
||||
### 1. Launch Frontend Client
|
||||
1. Navigate to the `frontend` folder.
|
||||
2. Install dependencies:
|
||||
```bash
|
||||
@@ -419,7 +394,11 @@ This tool allows admins/HODs/Principals to duplicate schedules for new semesters
|
||||
```
|
||||
4. The frontend runs at `http://localhost:5173`.
|
||||
|
||||
### 4. Seed User Accounts & Logins
|
||||
### 2. Firebase Configurations
|
||||
* The Firebase client config is hardcoded in `frontend/src/lib/firebaseBackend.ts` to connect directly to the Firestore backend.
|
||||
* On first load, if the database collections (`ems_users` or `ems_classes`) are empty, `firebaseBackend.ts` automatically seeds default institutional accounts and mock classes.
|
||||
|
||||
### 3. Seed User Accounts & Logins
|
||||
On startup, the system seeds accounts with their default passwords:
|
||||
* **Faculty Member:** `faculty@rit.edu` / `faculty123`
|
||||
* **HOD:** `hod@rit.edu` / `hod123`
|
||||
|
||||
Reference in New Issue
Block a user