- Driving-Test-Center-Application-Project
- Clone the repo
- Verify node version see .nvmrc
- Install dependencies
npm install
- Create a
.env
file in the root directory. The only required environment variable for the development environment is SESS_SECRET:
SESS_SECRET=your_strong_session_secret
- (Optional) For other environment variables, refer to the Docker Compose file for their defaults and options.
Note
This application connects to a MongoDB instance. You can provide a full connection string using MONGODB_URI, which will override other MongoDB-related variables.
- Run a MongoDB container
docker run --name mongodb -p 27017:27017 -d mongo:latest
- Run the app (uses
nodemon
)
npm run dev:start
- This project uses
biome
for linting and formatting files - All files except js and json files are formatted using prettier
Husky
is used as a dev dependency for pre-commit hooks that format and lint staged files see .husky\pre-commit
- To build and run docker container
# env variables are auto detected from .env file
docker compose up -d --build
- To stop the container
docker compose down
- Node.js: The core runtime environment for server-side JavaScript execution.
- Express.js: Web application framework for Node.js, providing robust routing and middleware support.
- MongoDB: NoSQL database for storing user and application data.
- Mongoose: Object Data Modeling (ODM) library for MongoDB and Node.js, providing a schema-based solution for application data models.
- EJS (Embedded JavaScript): Templating engine for generating HTML markup with plain JavaScript.
- HTML/CSS: Standard web technologies for structure and styling.
- JavaScript: Client-side scripting for enhanced interactivity.
The application follows the MVC architectural pattern:
-
Model:
- Represents the data structure and business logic.
- Implemented using Mongoose schemas and models for MongoDB interaction.
- Handles CRUD operations for user data, license applications, and appointments.
-
View:
- Responsible for presenting data to the user.
- Implemented using EJS templates for dynamic content rendering.
- Includes pages for dashboard, login, G2 application, and G application.
-
Controller:
- Manages the flow of data between Model and View.
- Handles user requests, processes data, and sends responses.
- Implemented as Express.js route handlers and middleware.
- Middleware: Used for request processing, authentication, and error handling in Express.js.
- RESTful API: Follows REST principles for API design and resource management.
- Asynchronous Programming: Utilizes async/await and Promises for non-blocking I/O operations.
- Form Validation: Server-side validation for user inputs and data integrity.
- Session Management: For user authentication and maintaining user state.
- pnpm: Package manager for Node.js dependencies.
- Git: Version control system for collaborative development.
- Nodemon: Development tool for auto-restarting the Node.js application during development.
This tech stack and MVC architecture provide a robust, scalable foundation for the driver testing system, allowing for clear separation of concerns and maintainable code structure.
Name: Sarah Johnson Age: 18 Occupation: High School Student
Background: Sarah is a recent high school graduate who is eager to gain her independence through driving. She has completed her learner's permit requirements and is now ready to apply for her G2 license.
Goals:
- To easily navigate the driver testing system and apply for her G2 license
- To track her application progress and receive timely updates
- To eventually progress to a full G license
Challenges:
- Limited experience with government systems and bureaucratic processes
- Anxiety about the testing process and potential for failure
- Balancing test preparation with other responsibilities
Needs:
- Clear, step-by-step guidance through the application process
- Easy-to-understand information about requirements and test expectations
- Ability to practice and prepare for the test within the system
Name: Michael Chen Age: 35 Occupation: Certified Driving Examiner
Background: Michael has been a driving examiner for 7 years. He is detail-oriented and takes his responsibility of ensuring road safety seriously.
Goals:
- To efficiently manage and conduct driving tests
- To provide fair and accurate assessments of drivers' skills
- To maintain a high standard of road safety through thorough examinations
Challenges:
- Managing a high volume of tests each day
- Ensuring consistency in test administration and scoring
- Dealing with nervous or unprepared test-takers
Needs:
- A streamlined system for viewing and managing test schedules
- Easy-to-use tools for recording test results and comments
- Quick access to applicant information and driving history
Name: Alex Rodriguez Age: 42 Occupation: DMV Systems Administrator
Background: Alex has worked in IT for government agencies for over 15 years. They are responsible for managing and maintaining the driver testing system.
Goals:
- To ensure the system runs smoothly and efficiently
- To manage user accounts and access levels
- To generate reports and analyze data for process improvement
Challenges:
- Balancing system updates with minimal downtime
- Managing security and data privacy concerns
- Accommodating changes in regulations and testing requirements
Needs:
- Robust tools for user management and access control
- Flexible reporting and data analysis capabilities
- Ability to easily create and manage appointment slots
- System for monitoring and addressing technical issues
These personas represent the three main user types of the driver testing system: the driver applicant, the examiner, and the administrator. Each has unique goals, challenges, and needs that the system must address to provide a comprehensive and effective solution for driver licensing and testing.
As a new user I want to create an account So that I can access the driver testing system
Given I am on the signup page When I enter a unique username, matching passwords, and select a user type And I submit the form Then my account should be created And I should be redirected to the login page
Given I am on the signup page When I enter a username and mismatched passwords And I submit the form Then I should see an error message And I should remain on the signup page
Given I am on the signup page When I enter an existing username And I submit the form Then I should see an error message And I should remain on the signup page
As a registered user I want to log in to the system So that I can access my account
Given I am on the login page When I enter valid credentials And I submit the form Then I should be logged in And I should be redirected to my dashboard
Given I am on the login page When I enter invalid credentials And I submit the form Then I should see an error message And I should remain on the login page
As a driver user I want to apply for a G2 license So that I can progress in my driving journey
Given I am logged in as a driver When I navigate to the G2 page And I fill in all required fields And I upload two images And I submit the form Then my G2 application should be saved And I should see a confirmation message
Given I am logged in as a driver When I navigate to the G2 page And I fill in some but not all required fields And I submit the form Then I should see validation errors And my entered data should be retained
As a G2 license holder I want to apply for a G license So that I can become a fully licensed driver
Given I am logged in as a driver with a G2 license When I navigate to the G page And I see my pre-filled information And I update allowed fields And I submit the form Then my G application should be saved And I should see a confirmation message
As an examiner I want to view scheduled driving tests So that I can prepare for my upcoming examinations
Given I am logged in as an examiner When I navigate to the examiner page Then I should see a list of all scheduled driving tests
Given I am logged in as an examiner When I navigate to the examiner page And I select to filter by G2 tests Then I should see only G2 scheduled tests
As an examiner I want to record the results of a driving test So that the system can update the driver's status
Given I am logged in as an examiner When I select a scheduled test And I enter comments about the test And I mark the test as passed And I submit the form Then the driver's status should be updated to passed
Given I am logged in as an examiner When I select a scheduled test And I enter comments about the test And I mark the test as failed And I submit the form Then the driver's status should be updated to failed
As an admin I want to create appointment slots So that drivers can book their tests
Given I am logged in as an admin When I navigate to the appointment page And I select a date and time And I submit the form Then a new appointment slot should be created
Given I am logged in as an admin When I navigate to the appointment page And I select a date and time that already exists And I submit the form Then I should see an error message And no new appointment should be created
As an admin I want to view the results of completed tests So that I can initiate the license issuance process
Given I am logged in as an admin When I navigate to the test results page Then I should see a list of all completed tests with pass/fail status
Given I am logged in as an admin When I navigate to the test results page And I select to filter by passed tests Then I should see only the tests that were passed