EasyAttend - Record and Manage Attendance hassle-free
+An attendance app for teachers to record student arrivals and remove incorrect entries.
+Add arrival
+ + +Today’s attendance
+Saved in database.
+| # | +Name | +Arrival | +Created | +Action | +
|---|
diff --git a/sk1/.env.example b/sk1/.env.example new file mode 100644 index 0000000..f8c3a57 --- /dev/null +++ b/sk1/.env.example @@ -0,0 +1,9 @@ +# Copy this file to .env and change the values before running prepare-app.sh +DOMAIN_NAME=easyattend.duckdns.org +LETSENCRYPT_EMAIL=somangsu.mukherjee@student.tuke.sk +POSTGRES_USER=attendance_user +POSTGRES_PASSWORD=change_this_password +POSTGRES_DB=attendance_db +DB_HOST=db +DB_PORT=5432 +PORT=3000 diff --git a/sk1/Dockerfile b/sk1/Dockerfile new file mode 100644 index 0000000..12b504a --- /dev/null +++ b/sk1/Dockerfile @@ -0,0 +1,7 @@ +FROM node:20-alpine +WORKDIR /app +COPY package*.json ./ +RUN npm install --omit=dev +COPY server.js ./ +EXPOSE 3000 +CMD ["npm", "start"] diff --git a/sk1/README.md b/sk1/README.md new file mode 100644 index 0000000..3bd4fa2 --- /dev/null +++ b/sk1/README.md @@ -0,0 +1,490 @@ +# EasyAttend – Classroom Attendance Checklist Application +Author: Somangsu Mukherjee + +## 1. Description of the Application + +EasyAttend is a web-based classroom attendance management application designed for teachers, lecturers, or classroom administrators. The application allows users to record student attendance quickly and efficiently through a clean web interface. + +Main features: + +- Add student names +- Record student arrival times +- Display attendance records in a structured table +- Delete incorrect attendance entries +- Store attendance records permanently in a database + +The application is publicly accessible over the Internet and secured with HTTPS encryption. + +--- + +## 2. Public Cloud, Cloud Services, Docker Objects, Persistent Volumes and Database Used + +### Public Cloud Platform + +The application is deployed on Microsoft Azure public cloud infrastructure. + +Cloud service used: + +- Microsoft Azure Virtual Machine +- Ubuntu Server 24.04 LTS +- Azure B2ats v2 virtual machine instance +- Public IP address +- Azure for Students subscription + +The Azure virtual machine serves as the hosting environment for the complete Docker deployment. + +--- + +### Docker Architecture + +The application uses Docker Compose to manage multiple containers. + +Docker objects used: + +#### Frontend Container + +Container name: + +attendance-frontend + +Technology: + +- Nginx +- HTML +- CSS +- JavaScript + +Purpose: + +Serves the user interface and allows interaction with the attendance application. + +--- + +#### Backend Container + +Container name: + +attendance-backend + +Technology: + +- Node.js +- Express.js + +Purpose: + +Handles application logic, API requests, and communication with the database. + +--- + +#### Database Container + +Container name: + +attendance-db + +Technology: + +- PostgreSQL 16 + +Purpose: + +Stores attendance records persistently. + +--- + +#### Reverse Proxy Container + +Container name: + +attendance-proxy + +Technology: + +- Nginx + +Purpose: + +- Routes traffic to frontend and backend services +- Handles HTTPS encryption +- Redirects HTTP traffic to HTTPS +- Handles SSL certificate integration + +--- + +#### Database Administration Container + +Container name: + +attendance-adminer + +Technology: + +- Adminer + +Purpose: + +Provides optional web-based database management. + +--- + +### Persistent Volumes + +Persistent Docker volumes used: + +#### PostgreSQL Persistent Volume + +Volume name: + +postgres_data + +Purpose: + +Stores PostgreSQL data files permanently so records remain available after container restart or redeployment. + +--- + +#### Nginx Log Volume + +Volume name: + +nginx_logs + +Purpose: + +Stores web access logs for monitoring incoming Internet traffic. + +--- + +## 3. Cost Analysis for One Year Operation + +Estimated usage assumptions: + +- 1000 users per day +- 50GB total database/storage usage +- lightweight application workload + +### Azure Virtual Machine + +Resource: + +Microsoft Azure Virtual Machine + +Configuration: + +- B2ats v2 +- 2 vCPU +- 1 GB RAM + +price: + +USD 7.74 per month + +Annual cost: + +USD 92.88 per year + +Billing interval: + +Monthly + +--- + +### Storage + +Resource: + +Azure Managed Disk Storage + +Estimated requirement: + +50GB + +Estimated monthly price: + +USD 3–5 per month + +Estimated annual price: + +USD 36–60 per year + +Billing interval: + +Monthly + +--- + +### Domain Name + +Resource: + +DuckDNS + +Price: + +Free + +Billing interval: + +None + +--- + +### SSL Certificate + +Resource: + +Let's Encrypt + +Price: + +Free + +Billing interval: + +None + +--- + +### Estimated Total Annual Cost + +Virtual machine: + +USD 92.88/year + +Storage: + +USD 36–60/year + +Domain: + +USD 0/year + +SSL certificate: + +USD 0/year + +Estimated total: + +USD 128.88–152.88 per year + +--- + +## 4. Description of Uploaded Files + +### docker-compose.yml + +Defines all application containers, networks, persistent volumes, restart policies, and inter-container communication. + +--- + +### prepare-app.sh + +Deployment automation script. + +Functions: + +- starts Docker services +- builds backend container +- initializes containers +- prepares networking +- prepares application deployment + +--- + +### remove-app.sh + +Application removal script. + +Functions: + +- stops Docker containers +- removes application services +- removes associated Docker networks + +--- + +### frontend/index.html + +Main user interface for the application. + +--- + +### frontend/styles.css + +Visual styling and layout for the web application. + +--- + +### frontend/app.js + +Frontend JavaScript functionality for communicating with backend API and updating attendance records dynamically. + +--- + +### backend/Dockerfile + +Defines backend container image configuration. + +--- + +### backend/package.json + +Node.js dependency configuration. + +--- + +### backend/server.js + +Main backend API implementation. + +Handles: + +- student attendance insertion +- attendance retrieval +- attendance deletion +- database communication + +--- + +### db/init.sql + +Initial PostgreSQL database schema definition. + +Creates attendance table structure. + +--- + +### nginx/app.conf + +Nginx reverse proxy configuration. + +Handles: + +- HTTP traffic +- HTTPS traffic +- SSL certificate integration +- reverse proxy routing +- frontend routing +- backend API routing +- Adminer routing + +--- + +### .gitignore + +Prevents sensitive or unnecessary files from being uploaded to Git. + +Excluded examples: + +- .env +- SSL certificates +- SQL backup files +- SSH private keys + +--- + +## 5. Brief Description of Configuration + +Application configuration is managed through Docker Compose and environment variables. + +Configured components include: + +- PostgreSQL credentials +- database name +- domain name +- SSL certificate settings +- Docker networking +- persistent volume mappings +- reverse proxy rules +- restart policies + +Sensitive values are stored in: + +.env + +This file is intentionally excluded from Git for security reasons. + +--- + +## 6. Instructions to View and Use the Application + +Application URL: + +https://easyattend.duckdns.org + +Instructions: + +1. Open a web browser +2. Navigate to the application URL +3. Enter a student name +4. Select arrival time +5. Click "Add student" +6. Attendance record will appear in the attendance table +7. Use the delete button to remove incorrect records + +--- + +## 7. Instructions to Perform Data Backup + +Database backup command: + +```bash +docker exec attendance-db pg_dump -U attendance_user attendance_db > attendance_backup.sql +``` +This creates: + +attendance_backup.sql + +This file contains a full backup of the PostgreSQL database. + +--- +## 8. Instructions to View Access Records from the Internet + +Access logs are available through the Nginx reverse proxy container. + +Command: +```bash +docker logs attendance-proxy +``` +Displayed information includes: + +client IP addresses +timestamps +requested URLs +HTTP response codes +browser user agents + +--- +## 9. Conditions Required to Run prepare-app.sh and remove-app.sh + +Required conditions: + +Ubuntu Linux environment +Docker installed +Docker Compose installed +Internet connection +properly configured .env file +valid domain name configuration +Docker permissions for executing user +complete project file structure present + +Deployment command: +```bash +./prepare-app.sh +``` +Removal command: +```bash +./remove-app.sh +``` +--- + +## 10. External Resources and Generative Model Usage +External Resources : +Microsoft Azure documentation, Let's Encrypt documentation, DuckDNS documentation: + +Generative Model Usage: Claude, OpenAI ChatGPT +Method of usage: +Debugging, architecture planning, troubleshooting, researching + +All implementation, deployment, testing, debugging, and validation actions were manually performed by me. \ No newline at end of file diff --git a/sk1/app.conf.template b/sk1/app.conf.template new file mode 100644 index 0000000..547674f --- /dev/null +++ b/sk1/app.conf.template @@ -0,0 +1,38 @@ +server { + listen 80; + server_name easyattend.duckdns.org; + + location /.well-known/acme-challenge/ { + root /var/www/certbot; + } + + location / { + return 301 https://$host$request_uri; + } +} + +server { + listen 443 ssl; + server_name easyattend.duckdns.org; + + ssl_certificate /etc/letsencrypt/live/easyattend.duckdns.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/easyattend.duckdns.org/privkey.pem; + + location / { + proxy_pass http://frontend:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location /api/ { + proxy_pass http://backend:3000/api/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location /adminer/ { + proxy_pass http://adminer:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/sk1/app.js b/sk1/app.js new file mode 100644 index 0000000..91fe4dc --- /dev/null +++ b/sk1/app.js @@ -0,0 +1,78 @@ +const API_URL = "/api/attendance"; +const form = document.getElementById("attendance-form"); +const nameInput = document.getElementById("student-name"); +const timeInput = document.getElementById("arrival-time"); +const body = document.getElementById("attendance-body"); +const emptyState = document.getElementById("empty-state"); +const message = document.getElementById("message"); +const refreshBtn = document.getElementById("refresh-btn"); + +function setDefaultTime() { + const now = new Date(); + timeInput.value = now.toTimeString().slice(0, 5); +} + +function showMessage(text) { + message.textContent = text; + setTimeout(() => { message.textContent = ""; }, 2500); +} + +async function loadAttendance() { + const response = await fetch(API_URL); + const entries = await response.json(); + body.innerHTML = ""; + emptyState.classList.toggle("hidden", entries.length !== 0); + + entries.forEach((entry, index) => { + const row = document.createElement("tr"); + row.innerHTML = ` +
An attendance app for teachers to record student arrivals and remove incorrect entries.
+Saved in database.
+| # | +Name | +Arrival | +Created | +Action | +
|---|