The Campus Security System is a web application designed to enhance safety and security on campus. It allows users to report incidents in real-time, alerts security personnel, and provides essential tools for managing campus safety. The system leverages a Next.js frontend for a modern user experience and a Python Flask backend for data processing and API services.
- Real-time Incident Reporting: Users can report suspicious activities instantly.
- Alerts and Notifications: Immediate alerts sent to security personnel upon incident reporting.
- User Authentication: Secure login for students and staff.
- Location Tracking: GPS functionality to assist in locating incidents.
- Emergency Contacts: Quick access to emergency services.
- Dashboard for Security Personnel: A dedicated interface for monitoring and managing incidents.
- Data Analytics: Insights into reported incidents to improve safety measures.
- Feedback Mechanism: Users can provide feedback to enhance the system.
├── app/ # Next.js app directory (frontend)
│ ├── api/ # API routes for Next.js backend
│ ├── (pages)/ # Page components
│ ├── globals.css
│ └── layout.tsx
├── components/ # Shared React components
├── public/ # Static assets
├── scripts/ # SQL scripts for database setup
├── styles/ # Global styles
├── app.py # Flask backend API
├── analysis.py # Python script for data analysis (likely generates static assets)
├── create_data.py # Python script for data generation
├── campus_incidents.csv # Sample incident data (used by Flask API)
├── feature_importance.png # Output from analysis.py
├── incident_map.html # Output from analysis.py
├── severity_heatmap.png # Output from analysis.py
├── next.config.js # Next.js configuration
├── package.json # Frontend dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Frontend: Next.js (TypeScript, React)
- Backend: Python (Flask), Next.js (API Routes)
- Database: Supabase (PostgreSQL) - inferred from
lib/supabase.tsandscripts/ - Styling: Tailwind CSS
To set up the Campus Security System locally, follow these steps:
-
Clone the repository:
git clone https://github.com/El-swaggerito/Campus-Security-System.git cd Campus-Security-System -
Set up Frontend: Install Node.js dependencies:
npm install
Note: You might need to configure Supabase environment variables. Create a
.env.localfile in the root directory and add your Supabase URL and Anon Key:NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key -
Set up Backend (Python Flask API): It's recommended to use a virtual environment for Python projects.
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install Python dependencies (assuming a
requirements.txtfile or manual installation of Flask and Pandas):pip install Flask pandas
(If a
requirements.txtfile is added in the future, usepip install -r requirements.txt) -
Database Setup (Optional - if using local Supabase/Postgres): The
scripts/directory contains SQL files (create-tables.sql,seed-data.sql) that can be used to set up the database schema and populate it with initial data if you are running a local PostgreSQL instance or want to set up your Supabase instance manually.
-
Start the Frontend (Next.js):
npm run dev
This will typically start the frontend on
http://localhost:3000. -
Start the Backend (Flask API): Open a new terminal, navigate to the project root, and activate the virtual environment:
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Run the Flask application:
flask run
This will typically start the Python backend API on
http://localhost:5000. Theapp.pyfile provides endpoints like/api/incidents,/api/trends, etc.Note: The
analysis.pyscript seems to generate static files (severity_heatmap.png,feature_importance.png,incident_map.html) that are then served by the Flask API. You may need to runpython analysis.pyfirst to generate these files if they are not already present or if you update the data.
Once both frontend and backend servers are running:
- Access the web application via
http://localhost:3000in your browser. - Users can log in (if authentication is fully set up) and start reporting incidents.
- The Flask API serves data to the frontend and potentially directly for data visualization.
The application is deployed on Vercel. You can access the live version here. (Note: The Vercel deployment likely only covers the Next.js frontend. The Python Flask backend might be deployed separately or its functionality might be partially replicated via Next.js API routes for the Vercel deployment.)
This project is licensed under the MIT License. See the LICENSE file (if it exists, otherwise assume MIT as per original README) for more details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or features.
For any inquiries, please contact:
- Name: Muhammad Zayyad Mukhtar
- Email: your-email@example.com