Skip to content

Annan Raddad - #11

Open
RaddadZ wants to merge 15 commits into
MewsSystems:mainfrom
RaddadZ:main
Open

Annan Raddad#11
RaddadZ wants to merge 15 commits into
MewsSystems:mainfrom
RaddadZ:main

Conversation

@RaddadZ

@RaddadZ RaddadZ commented Apr 2, 2026

Copy link
Copy Markdown

Annan Raddad

I focused on pragmatic development, security, and coding standards over feature richness. I refactored where necessary to align with framework conventions, wrapped critical operations in transactions to prevent race conditions, and added database indexes for performance. I included an example implementation of structured logging, tracing on the import pipeline, and unit tests for validation. For the most part, trade‑offs are intentional, not overlooked. I've used devcontainers to develop and test the project.

Commits are separated by business logic, and I tried to keep them as readable and as small as possible.

In consecutive 3‑hour blocks:

In distributed extra 3 hours:

Task Report

The commit log is mostly a representation of the time I spent from the first commit, and it shows that I started with minor refactoring, then the implementation of RE‑001, followed by RE‑002, then more polishing before implementing RE‑003.

I took the full 3 hours, with most of my time spent on RE‑001, RE‑003, and RE‑005, along with their related polish work.

Lastly, I spent some time creating example implementations of structured logging and unit tests, which I think must be done to show production‑level readiness for a project I (virtually) own.

To Be Improved Notes

Security & hardening

  • Restrict CORS from AllowAnyOrigin to known frontend origins; add request‑validation middleware and rate‑limiting on POST /staff/login to prevent brute‑force.
  • Replace hardcoded staffAccessCode with a secrets manager, introduce a Staff table with per‑user credentials plus audit trails for room‑cleanliness changes, and implement proper email sending (e.g., SendGrid, SES) instead of showing codes to staff.
  • Harden file upload security with server‑configurable MAX_FILE_SIZE, binary content sniffing beyond the .csv extension, and a health‑check endpoint for orchestrators.
  • Use a durable store (Redis or DB table with TTL) instead of in‑memory verification codes, and migrate from SQLite to PostgreSQL or similar in production since SQLite is single‑writer.

Code quality & design

  • Replace exceptions‑for‑control‑flow (e.g., NotFoundException) with result types or similar; use FluentValidation for declarative, testable rules instead of custom extension methods.
  • Organize code by adding an Api prefix to namespaces, pluralizing controller names, and placing DTOs in a dedicated folder.
  • Avoid down‑migration‑script gaps and keep SQL queries optimized (e.g., prefer cursor‑based pagination over LIMIT/OFFSET and tighten queries where possible).

UX & observability

  • Add a dedicated housekeeping page with filters (dirty‑only, floor grouping) and ensure every staff action that changes room state is logged for audit and traceability.

Delivery & operations

  • No deployment pipeline yet; add CI/CD for build, test, migration, and deployment automation.
  • Documentation is limited; update setup, architecture, API, deployment, and runbook docs.

Quick Look

image image

RaddadZ added 13 commits April 2, 2026 10:54
… handling

- Change database services from Singleton to Scoped lifetime for proper connection management
- Make EnsureDb async Task instead of async void
- Await EnsureDb call with proper scope disposal
- Add global exception handler for production environments
…ions and rooms

- Add ValidationException for structured error handling
- Create ReservationExtensions with validation for booking rules (RE-001):
  - Room number format validation
  - Email domain validation
  - Start date must not be in past
  - Start date must be before end date
  - Duration constraints (1-30 days)
- Create RoomExtensions with validation and move static methods from Room model
- Update ReservationController to validate reserv
- Wrap overlap check and INSERT in a single transaction for atomicity
- Query for existing reservations with date range overlap before inserting
- Throw ValidationException if room is already booked for selected dates
- Handle ValidationException in controller and return 409 Conflict
- Use strict inequality for date comparison to allow same-day checkout/checkin
- Ensure database connection is open before starting transaction
…authorization

- Replace manual cookie checking with ASP.NET Core Cookie Authentication
- Add [Authorize] and [AllowAnonymous] attributes to controller endpoints
- Configure authentication middleware with secure cookie settings
- Update StaffController to use SignInAsync/SignOutAsync for login/logout
- Return 401/403 status codes instead of redirecting for API endpoints
- Set cookie security based on environment (secure in production
… staff dashboard

- Add pagination support to GetReservations endpoint with from date filter
- Return pagination metadata in response headers (X-Total-Count, X-Page, X-Page-Size)
- Create database indexes on Reservations table for query performance
- Expose pagination headers in CORS configuration
- Implement offset-based pagination in ReservationRepository with configurable page size (1-100)
- Add staff login page with access code authentication
…igration system

- Implement versioned database migrations using PRAGMA user_version
- Add IsDirty boolean column to Rooms table in migration v3
- Create PATCH endpoint for Room with JsonPatchDocument support
- Add RoomPatch model with IsDirty field and whitelist allowed patch paths
- Block check-in if room is dirty with validation in ReservationController
- Set room to dirty automatically on check-in in ReservationRepository
- Add Set
…nd error reporting

- Add ImportOptions configuration model with MaxFileSizeBytes and MaxRows limits
- Create POST /api/rooms/import endpoint with multipart/form-data support
- Implement streaming CSV parser with header detection and row limit enforcement
- Validate file size, extension, room number format, state, and IsDirty fields
- Check for duplicates against existing rooms and within CSV batch
- Add BulkCreateRooms method in
…ter expired

- Add AuthContext.tsx with AuthProvider and useAuth hook
- Mount AuthProvider in index.tsx wrapping the app
- Move Logout button to Layout.tsx top bar (visible when authenticated)
- Auto-redirect /staff/login → /staff if already authed
- Call logout() on 401 in checkAuth to clear expired HttpOnly cookie
- Remove per-page checkAuth/logout calls in favor of shared context
- Add xUnit test project with coverlet and test SDK packages
- Create ReservationValidationTests covering email, date, duration, and room number validation
- Create RoomValidationTests covering room number format, length, and door number rules
- Add .gitignore for test project bin/obj/user files
- Reference main api project for testing Extensions and Models
…erations

- Add Serilog with console sink configured from appsettings
- Replace Console.WriteLine with Log.Fatal for startup errors
- Add UseSerilogRequestLogging middleware for HTTP request logging
- Inject ILogger<RoomController> and add structured logging for all room operations
- Log warnings for validation failures, not found errors, and invalid formats
- Log information for successful creates, updates, deletes with structured
Copilot AI review requested due to automatic review settings April 2, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/src/components/CheckInDialog.tsx Outdated
Comment thread ui/src/staff/StaffLoginPage.tsx Outdated
RaddadZ added 2 commits April 2, 2026 21:11
…fLoginPage per copilot comment

- Replace inline HTTPError handling with shared handleApiError utility
- Use handleApiError in CheckInDialog catch block for check-in failures
- Use handleApiError in StaffLoginPage catch block for login failures
- Remove duplicate error parsing logic and HTTPError import from StaffLoginPage
…ollow-ups

- Document initial polish decisions (scoped DI, DB seeding, exception middleware)
- Record guest booking implementation (validation, Zod parsing, date handling)
- Capture double-booking prevention with transaction-based overlap checks
- Detail auth framework refactor to cookie authentication with role-based authorization
- Document staff dashboard with pagination, filtering, and auth context
- Record check-in flow with verification codes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants