Added a new README File
This commit is contained in:
88
README.md
88
README.md
@@ -1,14 +1,36 @@
|
|||||||
# Positeasy Clone - Canteen Automation Ecosystem
|
# Positeasy Clone - Canteen Automation Ecosystem
|
||||||
|
|
||||||
## 🔐 Security Overhaul (Branch: krishna)
|
Welcome to the **Positeasy Clone**, a comprehensive Canteen Automation Ecosystem. This project is designed to handle point-of-sale (POS), inventory management, user ordering, and administrative tasks for canteen operations.
|
||||||
|
|
||||||
This branch represents a major security milestone for the Canteen Automation system, transitioning from open/unprotected endpoints to a robust **JWT-based Authentication** architecture.
|
## 🏗️ Ecosystem Architecture
|
||||||
|
|
||||||
### 🔐 Critical: Security Configuration
|
The application is split into several interconnected modules:
|
||||||
|
|
||||||
|
1. **Backend (`/backend`)**
|
||||||
|
- **Stack**: Java, Spring Boot, Maven, PostgreSQL.
|
||||||
|
- **Purpose**: Serves as the core API for all frontend applications. Handles business logic, database transactions, and security.
|
||||||
|
|
||||||
|
2. **Admin & Counter Frontend (`/frontend`)**
|
||||||
|
- **Stack**: React 19, TypeScript, Vite, Tailwind CSS, Recharts.
|
||||||
|
- **Purpose**: The main dashboard for canteen administrators and counter staff to manage POS, inventory, and reports. Includes PDF generation and charts.
|
||||||
|
|
||||||
|
3. **Ordering Site (`/ordering_site`)**
|
||||||
|
- **Stack**: React 19, TypeScript, Vite, Tailwind CSS, Framer Motion.
|
||||||
|
- **Purpose**: The customer-facing application where users can browse the menu, place orders, and view order status.
|
||||||
|
|
||||||
|
4. **Counter Frontend (`/counter-frontend`)**
|
||||||
|
- **Stack**: React 19, TypeScript, Vite, Tailwind CSS.
|
||||||
|
- **Purpose**: A streamlined interface specifically for counter operations.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔐 Security & Authentication
|
||||||
|
|
||||||
|
The system uses a robust **JWT-based Authentication** architecture to secure endpoints.
|
||||||
|
|
||||||
|
### Critical: Security Configuration
|
||||||
To run this application securely, you **MUST** configure the following environment variables. Do **NOT** commit real secrets to the repository.
|
To run this application securely, you **MUST** configure the following environment variables. Do **NOT** commit real secrets to the repository.
|
||||||
|
|
||||||
#### Required Environment Variables
|
|
||||||
| Variable | Description | Example/Hint |
|
| Variable | Description | Example/Hint |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| `JWT_SECRET` | Secret key for signing tokens | `openssl rand -base64 32` |
|
| `JWT_SECRET` | Secret key for signing tokens | `openssl rand -base64 32` |
|
||||||
@@ -16,32 +38,38 @@ To run this application securely, you **MUST** configure the following environme
|
|||||||
| `MASTER_USER` | Initial admin email | `admin@example.com` |
|
| `MASTER_USER` | Initial admin email | `admin@example.com` |
|
||||||
| `MASTER_PASSWORD` | Initial admin password | `SecurePassword123` |
|
| `MASTER_PASSWORD` | Initial admin password | `SecurePassword123` |
|
||||||
|
|
||||||
#### How to set them:
|
#### Setting Environment Variables:
|
||||||
- **Local Development**: Create a `.env` file (if using a loader) or set them in your IDE (IntelliJ/Eclipse) Run Configurations.
|
- **Local Development**: Create a `.env` file or set them in your IDE (IntelliJ/Eclipse) Run Configurations.
|
||||||
- **Production**: Set them as System Environment Variables on your server or CI/CD platform (e.g., GitHub Secrets, Railway, Docker).
|
- **Production**: Set them as System Environment Variables on your server or CI/CD platform.
|
||||||
|
|
||||||
### 🏗️ Ecosystem Architecture
|
### Security Features
|
||||||
- **Backend (Java/Spring Boot)**: Now fully protected by JWT guards. Includes `JwtAuthFilter`, `JwtUtil`, and enhanced `SecurityConfig`.
|
- **Backend**: Protected by JWT guards (`JwtAuthFilter`, `JwtUtil`). Role-based access restricts sensitive endpoints (Orders, Wallets, Coupons) to authenticated users. Implements rate limiting (`LoginRateLimiter`) to prevent brute-force attacks.
|
||||||
- **Frontend (Counter/Admin)**: Migrated to use an authenticated API wrapper (`src/api.ts`).
|
- **Frontend**: Centralized API wrapper (`src/api.ts`) injects authentication headers automatically. `AuthContext` persists tokens securely.
|
||||||
- **Ordering Site**: Also migrated to the shared security pattern.
|
|
||||||
|
|
||||||
### 🚀 Major Changes in this Branch
|
|
||||||
|
|
||||||
#### Backend Security
|
|
||||||
- **JWT Implementation**: Added token generation, validation, and filtering.
|
|
||||||
- **Role-Based Access**: Restricted sensitive endpoints (Orders, Wallets, Coupons) to authenticated users.
|
|
||||||
- **Rate Limiting**: Implemented `LoginRateLimiter` to prevent brute-force attacks.
|
|
||||||
- **CORS Configuration**: Updated to allow secure communication with frontend origins.
|
|
||||||
|
|
||||||
#### Frontend Hardening
|
|
||||||
- **API Wrapper**: Centralized all data fetching through a secure wrapper that injects authentication headers automatically.
|
|
||||||
- **Context Protection**: Updated `AuthContext` to persist tokens securely.
|
|
||||||
- **Screen Migration**: Every major page (POS, Inventory, Reports) has been refactored to use the new secure communication pattern.
|
|
||||||
|
|
||||||
### 🛠️ Developer Setup
|
|
||||||
1. **Backend**: Update `application.properties` with your `jwt.secret`.
|
|
||||||
2. **Frontend**: Ensure `.env` points to the correct backend URL.
|
|
||||||
3. **Migration**: See `migrate_fetch.ps1` in the `frontend` directory for details on how the transition was automated.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
Developed by the Canteen Automation Team.
|
|
||||||
|
## 🚀 How to Run
|
||||||
|
|
||||||
|
### Backend
|
||||||
|
1. Ensure Java 17+ and Maven are installed.
|
||||||
|
2. Navigate to the `backend` directory: `cd backend`
|
||||||
|
3. Update `src/main/resources/application.properties` with your database credentials and set the `jwt.secret` (or use environment variables).
|
||||||
|
4. Run the application: `./mvnw spring-boot:run`
|
||||||
|
|
||||||
|
### Frontends (`frontend`, `ordering_site`, `counter-frontend`)
|
||||||
|
1. Ensure Node.js (v18+) is installed.
|
||||||
|
2. Navigate to the desired frontend directory: `cd frontend` (or `ordering_site` / `counter-frontend`)
|
||||||
|
3. Install dependencies: `npm install`
|
||||||
|
4. Set up your `.env` file to point to the backend URL (e.g., `VITE_API_URL=http://localhost:8080`).
|
||||||
|
5. Run the development server: `npm run dev`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ Additional Tools & Scripts
|
||||||
|
|
||||||
|
- **`generate_report.py`**: A Python script used to generate deployment or analytics reports.
|
||||||
|
- **`push_to_git.bat`**: A quick batch script for Windows users to automate git commits and pushes.
|
||||||
|
- **`migrate_fetch.ps1`**: A PowerShell script in the `frontend` directory used to automate the transition of fetch calls to the secure API wrapper.
|
||||||
|
|
||||||
|
---
|
||||||
|
*Developed by the Canteen Automation Team.*
|
||||||
|
|||||||
Reference in New Issue
Block a user