A way for people to find open Butteries at Yale
This application displays the current open/closed status of various "butteries." A buttery is a late-night student-run snack bar within a residential college (For those at Harvard who don't know). The application allows users to view which butteries are currently open, along with their operating hours. Administrators (whose account I have hard-coded in for now) can log in to update the hours and open/closed status of each buttery.
- Frontend: Built with React.
- Backend: Built with Node.js, Express, and SQLite (SQL-based database).
- Authentication: Simple JWT-based authentication for administrators.
-
Viewing Butteries:
- Users can see a dropdown list of residential colleges.
- Selecting a college shows its detailed info (operating hours and description).
- Displays a list of butteries currently open and those closed (including reasons if provided).
-
Real-Time Updates:
- The frontend periodically checks and updates which butteries are open (once per minute).
-
Administrator Editing:
- Admin can log in to update hours, days open, and closed status.
- Changes immediately reflect on the frontend.
-
Responsive Design:
- The React UI is styled and uses Tailwind CSS/DaisyUI classes for a more aesthetically pleasing frontend.
- React: JavaScript library for building user interfaces.
- DaisyUI/Tailwind CSS: For styling, responsive design, and easily customizable UI components.
- Axios: For sending AJAX requests to the backend.
- Node.js & Express: For handling HTTP requests and serving API endpoints.
- SQLite: A lightweight, file-based SQL database.
- JWT (JSON Web Token): For secure authentication.
- bcrypt: For hashing and checking passwords.
-
Data Flow:
- On startup, the backend initializes a SQLite database
butteries.dbwith some preset buttery data if it's empty. - The React frontend queries the backend's
/api/butteriesendpoint to get a list of butteries and their info.
- On startup, the backend initializes a SQLite database
-
Open/Closed Logic:
- Each buttery record includes:
hours_startandhours_endin fractional hours (e.g., 22.5 for 10:30 PM).hours_dayslisting which days of the week the buttery operates (0=Sunday, 1=Monday, etc.).
- The frontend determines which butteries are open by comparing the current time and day to the stored schedule.
- If a buttery is marked
closedToday, it will appear in the closed list regardless of schedule.
- Each buttery record includes:
-
Editing Hours:
- Admins can log in using the hardcoded credentials (
admin/password). - Upon logging in, a JWT token is stored in
localStorage. - When editing hours, the frontend sends an authorized
PUTrequest with updated times/days. - The backend updates the SQLite database and responds with the updated buttery info.
- Admins can log in using the hardcoded credentials (
-
Clone this repository:
git clone https://github.com/JMasson0706/ButteryBook.git cd ButteryBook -
Install Backend Dependencies: bash Copy code cd backend npm install
-
Install Frontend Dependencies: bash Copy code cd ../frontend npm install
-
Run the Backend: bash Copy code cd ../backend node server.js This will start the server on http://localhost:8000.
-
Run the Frontend:
bash Copy code cd ../frontend npm install web-vitals npm start This will start the React development server on http://localhost:3000. (You might run into an error on first boot with web-vitals: if so, reinstall using npm install web-vitals)