Skip to content

Merge pull request #39 from Watergirll/main#1

Open
Watergirll wants to merge 62 commits into
Watergirll:mainfrom
DriveFlow-CRM:main
Open

Merge pull request #39 from Watergirll/main#1
Watergirll wants to merge 62 commits into
Watergirll:mainfrom
DriveFlow-CRM:main

Conversation

@Watergirll

Copy link
Copy Markdown
Owner

✨ Implement Appointment Management Endpoints: Availability, Creation, and Update

📌 Overview

This PR introduces three new endpoints to enhance the appointment management system for students:

1. GET /api/student/files/{fileId}/available-slots?date=YYYY-MM-DD

Retrieves available appointment slots for a specific date, considering:

  • Teaching category's session duration
  • Instructor's availability and existing appointments
  • Vehicle's availability (if assigned)

Returns:

  • Session duration
  • List of available time slots

2. POST /api/student/files/{fileId}/appointments

Creates a new appointment. Validates:

  • File ownership and required assignments (instructor, teaching category)
  • Appointment date is in the future
  • Time format and logical correctness
  • Session duration matches teaching category
  • Instructor availability and scheduling conflicts
  • Vehicle availability (if assigned)

3. PUT /api/student/appointments/update/{appointmentId}

Updates an existing appointment. Includes all validations from the POST endpoint, plus:

  • Appointment ownership verification

✅ Key Features

  • Consistent Validation Logic: Ensures only valid, conflict-free appointments are created or updated.
  • Ownership Checks: Validates that the student owns the file and appointment.
  • Session Duration Matching: Aligns each appointment's duration with the teaching category’s specified session time.
  • Conflict Prevention: Avoids double-booking instructors or vehicles.
  • Maintainable Code Structure: Reuses logic and patterns consistent with existing endpoints.

🔍 Additional Details

  • Error Handling: Provides structured and meaningful error responses.
  • Slot Calculation Logic: Dynamically calculates available time slots based on multiple constraints (instructor schedule, existing appointments, vehicle status).
  • Scalability: Logic is modular and can support future feature additions (e.g., cancellation rules, appointment reminders).

🧪 Testing

  • Unit tests for all endpoints, covering:
    • Success cases
    • Validation failures
    • Edge cases (e.g., back-to-back appointments, daylight saving changes)
  • Integration tests for:
    • Data interactions
    • Error propagation
    • Security checks (ownership)

📎 Notes

  • Designed to be extensible (e.g., support for group sessions, instructor overrides)
  • All code adheres to current architectural conventions and coding standards

Let me know if you'd like an overview of a specific part of the implementation.

GtJohnny and others added 30 commits May 12, 2025 12:05
CRUD on Instructor Availability
Introduced ExamForm and SessionForm models, controllers, and DTOs to support standardized exam forms per teaching category and per-lesson session forms for instructors. Added related database migrations, updated ApplicationDbContext, and included tests for the new functionality. Also added docker-compose for development and updated project structure.
Add exam and session form management with migrations
SeedData.cs now seeds not only default roles and users, but also test data for all major entities including geography, autoschools, licenses, teaching categories, exam forms and items, vehicles, files, payments, instructor availabilities, and appointments. This enables a fully populated test environment for development and testing. Also removed TEST_RESULTS.md.
Feat(seed): add incremental test data for SessionForm (AutoSchool, TeachingCategory, ExamForm, ExamItems, Vehicle, File, Availability, Appointment)
Introduces endpoints to retrieve a detailed session form view and to list a student's session forms with filtering, sorting, and pagination. Adds supporting DTOs for paged results and mistake breakdowns. Includes comprehensive integration and unit tests for new endpoints and access control.
Add session form history API and detailed view endpoints
whos-gabi and others added 30 commits January 23, 2026 23:18
feat: add optional fileId parameter to studen session form
fix: remove temporary ResetDb code from Program.cs
fix: restrict /api/forms/seed route to SuperAdmin only
feat: add fileId to fetchInstructorAssignedFiles response
feat: refactor session forms, add studentId to instructor files
Link ExamForm to License, add LicenseId to appointments
Linked properly license to examform
- Add POST /api/ai/chat/stream endpoint for SSE streaming
- Create AiStreamingService to proxy requests to OpenRouter API
- Build student context server-side (keeps API key secure)
- Remove old /api/ai/context/student endpoint (no longer needed)
- Add ChatRequest and ChatMessage DTOs
- Register services in DI container
- Add OpenRouter env vars to sample.env

The frontend now communicates through this proxy endpoint,
sending conversation history. The backend prepends fresh
student context on every request and streams AI responses
back via Server-Sent Events.

Security: OpenRouter API key never exposed to frontend
…roxy

feat(ai): add AI chat streaming proxy endpoint
Introduces extensive positive and negative unit tests for controllers and system API flows under DriveFlow.Tests. Enhances AuthController with account lockout handling and logging for failed logins. Updates CORS configuration to support dynamic origins and credentials. Adds rate limiting for token refresh endpoint and improves database seeding comments. Skips DB migrations in test environments for compatibility.
- Use SetIsOriginAllowed(_ => true) to allow any origin
- Supports AllowCredentials() for JWT Bearer token auth
- Works with Netlify preview deployments (dynamic URLs)
- Expose headers needed for SSE streaming

This fixes CORS issues when frontend is on Netlify and
backend is on VPS with different domains.

Co-authored-by: Cursor <cursoragent@cursor.com>
fix(cors): allow all origins with credentials support
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.

4 participants