Rocket Docs

React Portal

React Portal

Nice to Have

  • Description: The desire for a customer portal or web interface is an excellent idea for enhancing customer engagement and providing added value. This portal could serve as a central hub for customers to access information, track their projects, and interact with your services.

  • Benefits: Some potential benefits of the customer portal could include:

    • Job status tracking: Customers can check the real-time status of their solar installation projects, increasing transparency and reducing inquiries.
    • Document repository: Provide a secure repository for important project documents, contracts, and warranties.
    • Communication hub: Enable direct communication between customers and your team, including support requests and inquiries.
    • Feedback and reviews: Allow customers to provide feedback and leave reviews, contributing to your online reputation.

Key Features

Progressive Web App (PWA)

  • Description: A Progressive Web App (PWA) is a web application that offers a native app-like experience on mobile devices and desktops. It can be installed on users' devices and accessed from the home screen.

  • Benefits: Key benefits of implementing a PWA include:

    • Offline access: Users can access the app even when they are offline, improving accessibility and user engagement.
    • Fast loading times: PWAs load quickly, reducing bounce rates and enhancing user experience.
    • Cross-platform: PWAs work on various platforms, including Android, iOS, and desktop browsers.
    • Improved SEO: PWAs are indexed by search engines, contributing to better discoverability.

Simple Design

  • Description: Simplicity in design emphasizes user-friendliness and a clean, uncluttered interface. It focuses on presenting essential information and functionality while minimizing complexity.

  • Benefits: A simple design offers several advantages:

    • Enhanced user experience: Users can navigate and interact with the app intuitively, reducing the learning curve.
    • Faster development: Simplicity in design often results in faster development cycles and easier maintenance.
    • Improved performance: A clean design can contribute to faster loading times and better overall performance.

Estimated Job Tracking Dates

  • Description: Providing estimated job tracking dates until confirmation offers transparency to customers regarding when they can expect their solar installation to be completed.

  • Benefits: Benefits of this feature include:

    • Managing expectations: Customers have realistic expectations about project timelines, reducing misunderstandings.
    • Improved communication: Customers can plan accordingly and prepare for the installation process.
    • Trust and transparency: Building trust with customers by keeping them informed about progress.

Fast Target 800ms LCP

  • Description: The 800ms Largest Contentful Paint (LCP) target is a performance metric aimed at providing users with a fast and responsive experience. LCP measures how quickly the largest content element on a page is painted.

  • Benefits: Achieving an 800ms LCP target offers several advantages:

    • Enhanced user satisfaction: Faster loading times lead to a more positive user experience and lower bounce rates.
    • SEO benefits: Google's Page Experience update prioritizes sites with fast LCP times, potentially improving search rankings.
    • Competitive advantage: A fast-loading site can differentiate your service in a competitive market.

Auth0 Authentication

  • Description: Auth0 is a robust and customizable authentication and authorization platform that provides secure user management and authentication for your application.

  • Benefits: Key benefits of Auth0 authentication include:

    • Security: Auth0 handles user authentication securely, reducing the risk of unauthorized access.
    • User-friendly: Auth0 offers social login options, simplifying user onboarding.
    • Customization: You can customize the authentication process to meet your specific needs.

SPA (Single Page Application)

  • Description: A Single Page Application (SPA) is a web application that loads a single HTML page and dynamically updates content as the user interacts with the app.

  • Benefits: SPA architecture offers several advantages:

    • Smooth user experience: SPAs provide a fluid and responsive user interface with no page refreshes.
    • Faster navigation: Users can navigate through the app without waiting for full page reloads.
    • Improved performance: SPAs can load data efficiently, reducing server requests.

Architecture

Authentication Flow

  • User Registration: A user can register on the portal using their email or sign up quickly with their social media account. Upon registration, they will receive a confirmation email to verify their account.

  • Login: Registered users can log in securely using their email and password credentials. Auth0 handles the authentication process, ensuring secure access.

  • Password Reset: Users who forget their passwords can request a password reset. They will receive a password reset email with instructions to create a new password.

  • Automated Emails: Automated emails will include:

    • Account Confirmation Email: Sent after registration to confirm the user's email address.
    • Password Reset Email: Sent when a user requests a password reset.
    • Welcome Email: Sent to newly registered users to provide a warm welcome and an introduction to the portal.
    • Account Notifications: Periodic notifications related to account activity and updates.

Hosting Comparison (Cloudflare Pages vs. Netlify)

  • Cloudflare Pages: Chosen for its robust security features, including DDoS and bot protection, with minimal setup time. Cloudflare Pages offers:

    • Practically unlimited bandwidth.
    • Low Time to First Byte (TTFB) for fast content delivery.
    • Global distribution for redundancy.
    • Integration with Cloudflare's security services for additional protection.
  • Netlify: While Netlify is a solid choice for hosting static sites, the decision to go with Cloudflare Pages aligns with the project's security priorities, especially given the emphasis on DDoS and bot protection.

Staging Environment

  • The staging environment will be hosted on the "dev" branch, which is automatically built and deployed by Cloudflare Pages.

  • This staging site will not be accessible to the public. It will be used for internal testing and quality assurance.

  • The team will audit the staging site by using it as end users would, ensuring that all features work as expected before promoting changes to the live site.

CI/CD Pipeline

  • The CI/CD pipeline includes the following stages:
    1. Build with SAST (Static Application Security Testing): The code undergoes SAST analysis to identify and mitigate security vulnerabilities in the codebase.
    2. Local Testing: Developers test their code changes locally on their machines to ensure that it functions correctly and passes all tests.
    3. Feature Branches: Developers create feature branches by cloning the "dev" branch and branching from it. They work on their features or fixes in isolation.
    4. Merging to Dev: Once a feature is ready, it undergoes testing and approval. If it passes, it is merged into the "dev" branch for live testing.
    5. Promotion to Main: After thorough testing on the "dev" branch, changes are merged into the "main" branch for production deployment.

Certainly, let's enhance your architecture plan by specifying the libraries, frameworks, and APIs mentioned in your example code and providing explanations for certain design choices:

Application

React

  • Library: React is chosen as the frontend library for its ease of building web applications, component-based architecture, and a vast community of plugins and libraries.

  • React Router: React Router is used for client-side routing, enabling navigation without full page refreshes.

Progressive Web App (PWA)

  • Tools and Libraries:

    • Workbox: Workbox is a JavaScript library for creating PWAs. It provides service worker functionality for caching, background sync, and offline access.

    • Manifest File: A manifest file (manifest.json) is used to specify PWA metadata, including app name, icons, and other settings.

  • Importance: PWAs offer enhanced user experiences, including offline access, faster loading times, and the ability to install the app on the user's device like a native app.

Optimization Techniques

  • Inlining Critical CSS and JS:

    • Importance: Inlining critical CSS and JS reduces the number of server requests required to render a page. Critical resources are embedded directly into the HTML document, allowing the page to render faster, especially for initial loads.

    • Speed Improvement: When critical CSS and JS are inlined, the browser doesn't need to wait for separate requests to complete before rendering the page. This "above-the-fold" content can be displayed almost immediately, improving the perceived site speed.

  • Image Pipeline:

    • Importance: An image pipeline, which generates responsive images and uses the WebP format with JPG as a fallback, helps optimize image delivery. It ensures that images are appropriately sized for different devices and network conditions, reducing bandwidth usage and improving load times.
  • Tailwind CSS:

    • Importance: Tailwind CSS is a utility-first CSS framework that streamlines frontend development by providing a set of pre-defined CSS classes. It speeds up development by allowing developers to compose styles with classes, reducing the need for custom CSS.

    • Component Style Design:

      • Tailwind CSS follows a component-style design system, making it easy to create consistent and reusable UI components. This approach saves development time by promoting code reusability.
    • Minimal CSS Output:

      • Tailwind CSS generates minimal CSS output, including only the styles that are actually used on the page. This results in smaller CSS files and faster load times for your site.

Example

This is a very basic example just to get it up and running quickly.

app.js

import React from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import { Auth0Provider } from "@auth0/auth0-react"; // Import Auth0Provider
import Header from "./Header";
import JobStatus from "./JobStatus";
import Updates from "./Updates";
import Footer from "./Footer";
function App() {
return (
<Auth0Provider
domain="YOUR_AUTH0_DOMAIN"
clientId="YOUR_AUTH0_CLIENT_ID"
redirectUri={window.location.origin}
>
<Router>
<div>
<Header />
<Switch>
<Route exact path="/" component={JobStatus} />
<Route path="/updates" component={Updates} />
</Switch>
<Footer />
</div>
</Router>
</Auth0Provider>
);
}
export default App;

Job status code

import React, { useEffect, useState } from "react";
import axios from "axios";
function JobStatus() {
const [jobStatus, setJobStatus] = useState(null);
useEffect(() => {
// Fetch job status from ServiceM8 API
axios
.get("/api/servicem8/jobstatus")
.then((response) => {
setJobStatus(response.data);
})
.catch((error) => {
console.error("Error fetching job status:", error);
});
}, []);
return (
<div>
<h2>Job Status</h2>
{jobStatus ? (
<div>
<p>Status: {jobStatus.status}</p>
{/* Display more status details */}
</div>
) : (
<p>Loading job status...</p>
)}
</div>
);
}
export default JobStatus;

Display the updates

import React, { useEffect, useState } from "react";
import axios from "axios";
import { useAuth0 } from "@auth0/auth0-react"; // Import useAuth0
function Updates() {
const { isAuthenticated } = useAuth0(); // Check if the user is authenticated
const [updates, setUpdates] = useState([]);
useEffect(() => {
if (isAuthenticated) {
// Fetch updates only if the user is authenticated
const fetchUpdates = async () => {
try {
const response = await axios.get("/api/servicem8/updates");
setUpdates(response.data);
} catch (error) {
console.error("Error fetching updates:", error);
}
};
// Poll for updates every 30 seconds (adjust as needed)
const intervalId = setInterval(fetchUpdates, 30000);
// Clean up the interval when the component unmounts
return () => clearInterval(intervalId);
}
}, [isAuthenticated]); // Include isAuthenticated in the dependency array
return (
<div>
<h2>Updates</h2>
{isAuthenticated ? (
<ul>
{updates.map((update) => (
<li key={update.id}>{update.message}</li>
))}
</ul>
) : (
<p>Please log in to view updates.</p>
)}
</div>
);
}
export default Updates;

Great! Since you're using GitLab, you can leverage its built-in issue tracking, version control, and CI/CD capabilities to streamline your development and documentation processes. Here are some GitLab-specific recommendations to enhance your project documentation and issue management:

Documentation

GitLab Wiki

  • GitLab's built-in Wiki feature to create and maintain documentation in a structured manner.

GitLab Pages

  • Utilize GitLab Pages to host project's documentation microsite. You can easily publish documentation in a user-friendly format, and it will be accessible to team members and stakeholders.

Issue Templates

  • Create custom issue templates for different types of tasks or bug reports. This helps standardize the information provided in issues, making it easier to understand and address them.

Milestones

  • Use GitLab milestones to group related issues and tasks together. Milestones can represent specific project phases, sprints, or release cycles.

Labels

  • Define a labeling system for issues to categorize them by priority, type, or area of the project. For example, labels like "bug," "feature," "enhancement," "critical," or "documentation" can help with issue management.

Discussions

  • Encourage discussions on issues and merge requests. GitLab provides a discussion feature that allows team members to provide feedback, ask questions, and collaborate on solutions directly within the issue or merge request.

Code Snippets

  • Use GitLab's code snippets feature to share code examples or configuration snippets related to the project.

Continuous Integration and Deployment (CI/CD)

GitLab CI/CD Configuration

  • Maintain a well-documented .gitlab-ci.yml file in the project's repository. This file defines the CI/CD pipeline and should include stages for building, testing, and deploying the application.

  • Document the specific commands and scripts used in the CI/CD pipeline, including environment variables and deployment targets.

Deployment Environments

  • Leverage GitLab's environments feature to define different deployment environments (e.g., staging, production). Document the configuration and setup for each environment, including deployment scripts and variables.

Release Tags

  • Use GitLab's release tagging feature to create version releases. Each release can include release notes, which serve as a concise summary of changes in that version.

Security and Compliance

Data Protection and Compliance

  • Data Protection Officer (DPO): Appoint a Data Protection Officer responsible for ensuring compliance with data protection regulations, such as GDPR. The DPO should oversee data handling and privacy-related issues.

  • Data Minimization: Implement data minimization practices to collect only the necessary user data required for portal functionality. Avoid collecting sensitive or unnecessary information.

  • Data Encryption: Ensure that data in transit and at rest is encrypted using strong encryption algorithms, including HTTPS for data in transit and encryption for data storage.

  • User Data Compliance: Regularly audit and update data handling processes to maintain compliance with user data regulations, including GDPR, CCPA, or any other relevant local regulations.

Tracking and Cookies

  • User Consent Management: Implement a robust user consent management system that allows users to control the types of cookies and tracking they accept. Provide clear and granular options for consent.

  • Cookie Policy: Include a detailed cookie policy on the portal that explains the purpose of each cookie, its lifespan, and how users can manage or opt out of cookies.

Security Considerations

  • Cross-Site Scripting (XSS) Mitigation: In addition to setting security headers, implement input validation, output encoding, and parameterized queries to prevent XSS attacks.

  • Content Security Policy (CSP): Create a strong CSP to restrict the sources from which content can be loaded, preventing the execution of malicious scripts from unauthorized sources.

  • Server Security: Ensure that the backend server, whether it's ExpressJS or any other, is securely configured, and all unnecessary services and ports are closed. Follow best practices for server hardening.

  • VPN Tunneling: Establish outbound VPN tunneling using secure protocols like WireGuard to secure communication between the portal and backend services. Implement network segmentation to isolate sensitive data.

  • DDoS and Bot Protection: Continuously monitor and configure Cloudflare and Netlify to provide effective protection against Distributed Denial of Service (DDoS) attacks and mitigate the impact of malicious bots.

  • Rate Limiting: Implement rate limiting on API endpoints to prevent abuse and malicious attacks on downstream ServiceM8 API. Define and enforce rate limits based on acceptable usage patterns.

  • Incident Response Plan: Develop a comprehensive incident response plan that outlines procedures for detecting, reporting, and mitigating security incidents. Ensure all team members are aware of their roles in case of a security breach.

  • Regular Security Audits: Conduct regular security audits, penetration testing, and vulnerability assessments to identify and address security weaknesses. Schedule these audits periodically or after significant updates.

  • Security Training: Train your development and operations teams in secure coding practices and security awareness to reduce the risk of security vulnerabilities during development and maintenance.

Understood, if you'll be integrating only Servicem8 with the app and you'd like to streamline the project kickoff phase to one week, we can adjust the timeline accordingly. Here's a revised project timeline:

Project Timeline

Phase 1: Streamlined Planning and Preparation

  • Week 1: Project Kickoff and Requirements Gathering
    • Define project objectives, scope, and requirements.
    • Assemble the project team and assign roles and responsibilities.
    • Conduct initial research on Servicem8 integration and CRM solution.
    • Develop a simplified project plan, including timelines, deliverables, and milestones.
    • Begin requirements gathering sessions.
    • Document high-level features and functionalities for the solar installation portal.
    • Identify key design considerations.

Phase 2: Development with Optimizations

  • Week 2-3: Design Prototyping and Frontend Development

    • Collaborate with designers or design team to create wireframes and design prototypes for the solar installation portal.
    • Gather feedback and iterate on design concepts.
    • Begin frontend development of the solar installation portal using React, incorporating design elements.
  • Week 4-7: Frontend Development and Performance Optimization

    • Integrate the finalized design prototypes into the development process.
    • Implement the PWA features for offline access and faster loading times.
    • Simultaneously, optimize the frontend code for performance, including achieving the target 800ms LCP.
    • Implement inlining of critical CSS and JavaScript for faster rendering.
    • Set up an image pipeline for responsive images and use WebP with JPG fallback.

Phase 3: Backend Development and Authentication

  • Week 8-10: Backend Development and Authentication
    • Develop the backend using ExpressJS or a similar technology.
    • Implement Auth0 authentication and user management.
    • Set up automated emails for user registration, confirmation, and password reset.

Phase 4: Integration and Testing

  • Week 11-12: Servicem8 Integration and Testing

    • Begin integrating Servicem8 with the solar installation portal.
    • Test data flow and integration to ensure seamless communication.
    • Implement job tracking features related to Servicem8 data.
  • Week 13-14: Job Tracking and Estimated Dates

    • Develop functionality for displaying job tracking and estimated dates until confirmation.
    • Conduct extensive testing of these features.

Phase 5: Deployment and User Testing

  • Week 15: Staging Deployment
    • Deploy the application to a staging environment hosted on the "dev" branch.
    • Conduct user testing and quality assurance to ensure the portal meets user expectations.
    • Continue design testing and refinement.

Phase 6: Production Deployment and Launch

  • Week 16: Production Deployment

    • Deploy the finalized and optimized portal to the production environment on the "main" branch.
    • Monitor the production environment for any issues or performance concerns.
    • Ensure that the design is fully integrated and refined.
  • Week 17-18: Launch and User Onboarding

    • Officially launch the solar installation portal for end-users.
    • Onboard users and provide training or support as needed.
    • Begin promoting the portal as a selling point to potential customers.

Phase 7: Ongoing Maintenance and Enhancements

  • Week 19-Onward: Post-Launch Support and Design Enhancements
    • Provide ongoing support for users and address any reported design-related issues.
    • Plan and implement design enhancements and additional features based on user feedback and evolving business needs.

Budget

Development Allocation:

  • A maximum budget of £19,000 has been allocated for development efforts. This budget encompasses all aspects of software development, including coding, testing, and implementation.

Design Expenditure:

  • A budget of £500 has been designated for the design phase. This allocation is intended for outsourcing the creation of straightforward dashboard-style pages.

Budget Flexibility:

  • It is recognized that the budget may undergo adjustments based on project dynamics and evolving requirements.

Optimization Potential:

  • Further optimizations to the project timeline may result in cost-efficiency gains, with corresponding adjustments to the budget.

Overall Financial Range:

  • The overall budget range for this project is set between £15,500 and £19,500, providing both a clear guideline and some flexibility for financial management.
Edit this page on GitHub