This repository contains the frontend for my portfolio project for Milestone 1. It is a responsive single-page application built with Bootstrap and vanilla JavaScript. Pages live in frontend/views/ and are loaded dynamically by frontend/js/spapp.js. To run locally, place the project folder in c:/xampp/htdocs/portfolio-handan, start Apache in XAMPP, and open http://localhost/portfolio-handan/frontend/index.html. Key files and folders are frontend/index.html, frontend/views/, frontend/css/, frontend/js/ and frontend/assets/images/. The ERD diagram is at frontend/assets/images/erd-diagram.jpg.

- MySQL database with 5 tables: users, projects, skills, experiences, contacts
- DAO classes for CRUD operations (Create, Read, Update, Delete)
- Place project in
c:/xampp/htdocs/portfolio-handan - Start Apache and MySQL in XAMPP
- Import database: open
backend/config/database.sqlin phpMyAdmin - Open:
http://localhost/portfolio-handan/frontend/index.html
frontend/- HTML, CSS, JS filesbackend/config/database.sql- database setupbackend/dao/- DAO classes for database accessbackend/test_dao.php- test if backend works
- Business Logic Layer: Service classes for all entities (UserService, SkillService, ExperienceService, ProjectService, ContactService)
- JWT Authentication: Secure token-based authentication using Firebase/PHP-JWT
- REST API Routes: Complete CRUD operations with proper HTTP methods (GET, POST, PUT, DELETE)
- OpenAPI/Swagger Documentation: Interactive API documentation with Swagger UI
- Route Definitions: All endpoints documented with Swagger annotations
- Secure JWT-based authentication for protected routes
- RESTful API endpoints following best practices
- Interactive API documentation at
/backend/public/v1/docs/ - Dependency injection container using FlightPHP
- Prepared statements for SQL security
- Service layer for business logic separation
- FlightPHP 3.17+ - Lightweight REST API framework
- Firebase/PHP-JWT 6.0 - JWT authentication
- Zircote Swagger-PHP 5.5 - OpenAPI documentation
- MySQL 5.7+ with PDO - Database layer
- Place project in
c:/xampp/htdocs/mojnoviprojekat - Start Apache and MySQL in XAMPP
- Import database: run
backend/config/database.sqlin phpMyAdmin - Access Swagger UI:
http://localhost/mojnoviprojekat/web-programming/backend/public/v1/docs/
- Register: POST
/auth/register - Login: POST
/auth/login(returns JWT token) - Use token in Authorization header:
Authorization: Bearer <token> - Access protected endpoints with the token
backend/services/- Business logic layerbackend/routes/- API endpoint definitionsbackend/middleware/AuthMiddleware.php- JWT authenticationbackend/public/v1/docs/- Swagger documentationbackend/dao/- Data access objects (from Milestone 2)backend/config/database.sql- Database schema
For production, change the secret key in backend/middleware/AuthMiddleware.php from the default value.
- Role-Based Access Control (RBAC): Admin vs User permissions enforced on all protected endpoints
- Ownership Enforcement: Users can only access/modify their own data (projects, skills, experiences)
- Frontend-Backend Integration: SPA dynamically loads user-specific data when logged in
- Dashboard CRUD: Users can add/delete skills and projects from the dashboard
- Apache-Only Setup: No need to start a separate PHP server — everything runs through XAMPP
Request → Routes → AuthMiddleware → Services → DAO → MySQL
- Routes (
backend/routes/): Define endpoints with Swagger annotations - Services (
backend/services/): Business logic + validation + ownership checks - DAO (
backend/dao/): Data access layer with prepared statements - Middleware (
backend/middleware/AuthMiddleware.php): JWT verification + role extraction
Backend API http://localhost/mojnoviprojekat/web-programming/backend
Frontend SPA http://localhost/mojnoviprojekat/web-programming/frontend/
Swagger UI http://localhost/mojnoviprojekat/web-programming/backend/public/v1/docs/
- Admin: Can access
GET /users(list all users) - User: Cannot access
GET /users(returns 403) - Owner: Can only access their own
/users/{id}/*endpoints - Non-owner: Gets 403 when accessing another user's data
- Open
http://localhost/mojnoviprojekat/web-programming/frontend/ - Click Login → enter
[email protected]/password - Verify: Dashboard loads, "Admin" link visible in navbar
- Click "View Skills" → shows user's skills (or "No skills yet" with Add button)
- Go to Dashboard → Add a skill → Verify it appears
- Click Logout → Token removed, redirects to home
- Login as regular user → "Admin" link hidden
- Open:
http://localhost/mojnoviprojekat/web-programming/backend/public/v1/docs/ - Expand
GET /health→ Try it out → Execute → Show 200 response - Expand
POST /auth/login→ Enter{"email":"[email protected]","password":"password"}→ Execute - Copy the token from response
- Click "Authorize" button (top right) → Paste
Bearer <token>→ Authorize - Expand
POST /auth/verify→ Execute → Showvalid: true, role: admin - Expand
GET /users→ Execute → Show 200 with user list - Log out of Swagger, login as regular user, try
GET /users→ Show 403
- Open:
http://localhost/mojnoviprojekat/web-programming/frontend/ - Show public pages: Home, About, Projects (static showcase), Skills (static showcase)
- Login as admin → Show dashboard with profile info
- Go to Skills page → Show dynamic user data (or empty + add button)
- Add a skill from Dashboard → Refresh Skills page → Verify it appears
- Show Admin panel (admin only)
- Logout → Show navbar updates (Login/Register visible, Dashboard/Admin hidden)
- Login as regular user → Show Admin link is hidden
- Show
backend/index.php— Flight routing + base path handling - Show
backend/routes/UserRoutes.php— Swagger annotations + middleware - Show
backend/services/UserService.php— Ownership validation - Show
frontend/js/api.js— Computed API_BASE for Apache - Show
frontend/js/dashboard.js— CRUD operations for skills/projects
backend/index.php— Base path normalization for Apachebackend/services/*— Ownership enforcementbackend/middleware/AuthMiddleware.php— Role extraction
frontend/js/api.js— Computed API_BASE, CRUD functionsfrontend/js/app.js— Auth UI (show/hide nav items)frontend/js/dashboard.js— Skills/Projects CRUDfrontend/js/features.js— Dynamic data loading for logged-in usersfrontend/views/dashboard.html— CRUD formsfrontend/views/skills.html— Dynamic/static content togglefrontend/views/projects.html— Dynamic/static content toggle
Contact: [email protected]