Travlr Getaways is a full-stack web application built to provide a seamless travel booking experience for customers and an administrative interface for managing trips, customers, and bookings. This project demonstrates the use of the MEAN stack (MongoDB, Express, Angular, and Node.js) to deliver a feature-rich, secure application.
- Module Eight Journal
- Features
- Technologies Used
- Setup Instructions
- Screenshots
- API Documentation
- Testing
- Acknowledgments
This project utilized two distinct types of frontend development:
- Express HTML with Handlebars: The customer-facing website leverages server-side rendering with Handlebars for dynamic content generation. This approach is ideal for quickly rendering static content, ensuring a lightweight and efficient frontend.
- Angular SPA: The admin interface is built as a single-page application (SPA) using Angular. Unlike traditional web applications, the SPA offers a dynamic and rich user experience by rendering content on the client side. Features such as conditional rendering and state management make the SPA ideal for interactive applications like managing CRUD operations.
The backend relies on a NoSQL MongoDB database, chosen for its schema flexibility and ability to scale horizontally. MongoDB's JSON-like structure aligns naturally with the frontend's data consumption, enabling faster development and seamless integration with Mongoose for schema validation and queries.
JSON (JavaScript Object Notation) serves as a data exchange format between the frontend and backend. While JSON resembles JavaScript objects in syntax, it is purely a data format and does not include functions or methods. In this project, JSON was critical for passing structured data between the Angular frontend and the Express backend.
Throughout the development process, several instances of code refactoring enhanced functionality and efficiency:
- Reusable Components in Angular: The
TripCardComponent
andTripListingComponent
were refactored to modularize the UI. This approach reduced code duplication and ensured consistent behavior across the application. - API Services: The
TripDataService
centralized all API calls, simplifying maintenance and improving code readability.
The benefits of reusable components include:
- Scalability: Easier to add new features.
- Consistency: UI and functionality are uniform across the application.
- Maintainability: Streamlined debugging and future enhancements.
Testing was a crucial part of ensuring the application worked correctly:
- Backend Testing: Using Postman, API endpoints were tested for both success and error scenarios. Authentication was validated by providing JWTs in the
Authorization
header for secure routes. - Frontend Testing: Angular components and services were manually tested for:
- Conditional rendering of admin-only features (e.g., "Add Trip" and "Edit Trip" buttons).
- Successful interaction with the backend to perform CRUD operations.
- Security Testing: Authentication layers were tested to ensure only valid users could access admin routes. Invalid tokens and expired JWTs were handled gracefully to prevent unauthorized access.
Understanding methods and endpoints in a full stack application involves:
- Methods: HTTP methods (GET, POST, PUT, DELETE) define the type of interaction with the database.
- Endpoints: Define specific API routes for resource manipulation (e.g.,
/api/trips
). - Security: JWT-based authentication ensures that sensitive routes are accessible only to authorized users.
This course has been instrumental in advancing my professional skills and aligning with my career goals as a full stack developer. I've gained hands-on experience in:
- Developing Full Stack Applications: Building and integrating both frontend and backend components using industry-standard tools like the MEAN stack.
- Implementing Security Features: Understanding the importance of JWT-based authentication and how to secure endpoints for authorized access.
- Database Management: Leveraging MongoDB for efficient and scalable data storage while using Mongoose for schema validation.
- Building SPAs: Creating dynamic, responsive, and feature-rich single-page applications using Angular.
Key skills developed during this course include:
- Modular Programming: Refactoring components and services for maintainability and scalability.
- API Development and Testing: Designing and securing RESTful APIs, as well as validating functionality using tools like Postman.
- Frontend-Backend Communication: Establishing seamless data transfer and synchronization between client and server.
Overall, this course has significantly enhanced my ability to develop complex applications and provided me with a solid foundation in full stack development, making me a more marketable and confident candidate for roles in the tech industry. I feel prepared to tackle real-world challenges and contribute meaningfully to any development team.
- Explore and search travel packages by location, price, and duration.
- View detailed itineraries for booked trips.
- User account creation and login functionality.
- Authentication: Secure login for administrators.
- CRUD Operations:
- Add, update, and delete trips.
- View and manage customer accounts.
- Conditional rendering of features based on admin login status.
- Angular (SPA development)
- Bootstrap (Styling and responsive design)
- Angular Router (Routing between components)
- Node.js (Server-side environment)
- Express.js (Web framework)
- Mongoose (MongoDB ODM)
- JSON Web Tokens (JWT) (Authentication)
- MongoDB (NoSQL database)
- Postman (API testing)
- Angular CLI (Frontend testing and development)
- Install Node.js and npm.
- Install MongoDB and ensure it is running locally or accessible via a connection string.
git clone <repository-url> cd travlr
npm install
cd app_admin npm install
Create a .env
file in the root of the project:
MONGO_URI=<your-mongodb-connection-string> JWT_SECRET=<your-secret-key> PORT=3000
Run the following script to seed initial data into the MongoDB database:
node seed.js
npm start
cd app_admin ng serve
- Frontend: http://localhost:4200
- Backend API: http://localhost:3000
- POST /api/login: Authenticate admin users and retrieve a JWT.
- GET /api/trips: Retrieve all trips (requires JWT).
- POST /api/trips: Add a new trip (requires JWT).
- PUT /api/trips/:id: Update a trip by ID (requires JWT).
- DELETE /api/trips/:id: Delete a trip by ID (requires JWT).
- Use Postman or a similar tool.
- Authenticate using:
- Email:
[email protected]
- Password:
password123
- Email:
- Include the JWT in the
Authorization
header for protected routes:Authorization: Bearer <your-jwt-token>
- Test RESTful API routes using Postman:
- Test positive cases (e.g., valid JWT, correct data).
- Test negative cases (e.g., invalid JWT, missing fields).
- Manually test:
- Admin login/logout functionality.
- CRUD operations for trips (Add, Update, Delete).
- Ensure customer-facing pages display trips dynamically from the database.
This project was completed as part of CS 465: Full Stack Development at Southern New Hampshire University. Special thanks to the instructors, especially Prof. Chipman, and course materials for guidance throughout the project.