Quick Start
Prerequisites
Before you begin, ensure you have the following installed on your local machine:
- Node.js: Version 18.0.0 or higher.
- npm or yarn: A functional package manager.
- Git: For cloning the repository.
Installation
-
Clone the repository:
git clone https://github.com/JenishSambahamphe24/campus-template.git cd campus-template -
Install dependencies:
npm install # or yarn install
Environment Configuration
This template relies on environment variables for API connections and campus-specific metadata. Create a .env file in the root directory and configure the following variables:
# API and Resource URLs
VITE_API_URL=your_backend_api_base_url
VITE_FILE_URL=your_file_storage_url
VITE_IMAGE_URL=your_image_storage_url
# Campus Branding
VITE_COLLEGE_NAME="Your College Name"
VITE_DEFAULT_IMG=path_to_default_image
# Contact Information
VITE_ADDRESS="123 Campus Way, City, Country"
VITE_EMAIL="contact@campus.edu"
VITE_PHONE="+1234567890"
VITE_MAP_IFRAME="your_google_maps_embed_url"
Available Scripts
Development
Launch the development server with Hot Module Replacement (HMR):
npm run dev
The application will typically be available at http://localhost:5173.
Production
Build the application for production:
npm run build
The compiled assets will be generated in the dist/ directory.
Linting
Check the codebase for ESLint errors:
npm run lint
Basic Usage Patterns
Authentication & CMS Access
The template includes a pre-built CMS (Content Management System) located under the /admin routes. Access to these routes is protected via PrivateRoutes.
- Token Management: The system automatically looks for an
authTokenin the browser'slocalStorageto authorize API requests for Faculty, Programs, FAQ, and Gallery management. - Protected Routes: To add a protected route, wrap the route component within
PrivateRoutes.jsxin your router configuration.
Interacting with APIs
All API services are centralized in the src/Screens/cmsScreen/cms-components/ directory. You can import these functions to fetch or mutate data:
import { getAllFaculties } from './path/to/academicsApi';
const loadData = async () => {
try {
const faculties = await getAllFaculties();
console.log(faculties);
} catch (error) {
console.error("Failed to fetch data", error);
}
};
Content Updates
You can update the following sections by using the corresponding API modules:
- About Us: Manage campus history and mission.
- Academics: Manage Faculties and Programs.
- Gallery: Supports both Image and Video (YouTube) categories.
- Publications: Manage downloadable files and research categories.