The system will consist of:
- A full-year calendar view displaying 12 months at once (skipping past dates)
- Three possible states for each date: Available, Booked, or Half-booked
- Admin functionality with password protection and 24-hour session persistence
- Public view for anyone to see the calendar states
- Frontend: Vue.js with shadcn components and Tailwind CSS
- Backend: PHP
- Database: SQLite
erDiagram
DATES {
integer id PK
date date
string status "Available/Booked/Half-booked"
timestamp created_at
timestamp updated_at
}
ADMIN_SESSIONS {
integer id PK
string session_token
timestamp expires_at
timestamp created_at
}
flowchart TD
A[Public User] -->|Views Calendar| B[Vue.js Frontend]
C[Admin] -->|Authenticates & Updates| B
B <-->|API Requests| D[PHP Backend]
D <-->|Data Operations| E[SQLite Database]
subgraph Frontend
B --> F[Calendar Component]
B --> G[Admin Login Component]
end
subgraph Backend
D --> H[Date API]
D --> I[Auth API]
end
flowchart TD
A[App.vue] --> B[Calendar.vue]
A --> C[AdminLogin.vue]
B --> D[Month.vue]
D --> E[Day.vue]
C --> F[AdminPanel.vue]
F --> B
- GET /api/dates - Get all dates and their statuses
- POST /api/dates/{date} - Update status for a specific date (admin only)
- POST /api/auth/login - Admin login
- POST /api/auth/logout - Admin logout
- GET /api/auth/check - Check if admin session is valid
lite-booking/
├── public/
│ └── index.html
├── src/
│ ├── assets/
│ ├── components/
│ │ ├── Calendar.vue
│ │ ├── Month.vue
│ │ ├── Day.vue
│ │ ├── AdminLogin.vue
│ │ └── AdminPanel.vue
│ ├── lib/
│ │ └── utils.js
│ ├── App.vue
│ └── main.js
├── api/
│ ├── config/
│ │ └── database.php
│ ├── models/
│ │ ├── Date.php
│ │ └── Session.php
│ ├── auth.php
│ └── dates.php
├── database/
│ └── calendar.sqlite
├── package.json
├── tailwind.config.js
└── vite.config.js
sequenceDiagram
Admin->>+Frontend: Enter password
Frontend->>+Backend: POST /api/auth/login
Backend->>Backend: Verify password
Backend->>Backend: Generate session token
Backend->>Backend: Store token with 24h expiry
Backend->>-Frontend: Return session token
Frontend->>Frontend: Store token in localStorage
Frontend->>-Admin: Show admin interface
Note over Admin,Backend: Later requests
Frontend->>+Backend: Request with session token
Backend->>Backend: Validate token
Backend->>-Frontend: Allow or deny access
- Full year calendar showing all 12 months
- Past dates are hidden/disabled
- Each date shows its status with both color and text label
- Simple, clean interface focused on readability
- Same calendar view as public
- Clickable dates that show a dropdown of state options
- Visual feedback when state is changed
- Session persistence for 24 hours
- Logout option
- PHP 7.4 or higher
- Node.js 14 or higher
- npm or yarn
-
Clone the repository:
git clone github.com/lajlev/availability-calendar-php-sqlite.git cd availability-calendar-php-sqlite -
Install frontend dependencies:
npm install -
Set up the database: The SQLite database will be automatically created when you first run the application.
You can run both the frontend and backend servers with a single command:
php dev-server.php
This will start:
- PHP backend server at http://localhost:8000
- Vite development server at http://localhost:5173/
Alternatively, you can run them separately:
-
Start the PHP backend server:
php -S localhost:8000 -t api -
Start the Vite development server:
npm run dev
You can edit admin password with php api/update_password.php
-
Build the frontend:
npm run build -
Deploy the built files
/distalong with the PHP backend/apito your web server.