Next.js 14 frontend for Africa's practical skills online learning platform
This is Repo 3 of 3 in the Hamplard project:
| Repo | Description |
|---|---|
hamplard-contract |
Soroban smart contract — course payments + certificates |
hamplard-backend |
NestJS API — content, progress, users |
hamplard-frontend ← you are here |
Next.js 14 — student and instructor portal |
| Route | Auth | Description |
|---|---|---|
/ |
— | Public course marketplace with search and category filters |
/auth/login |
— | Freighter wallet connect with student/instructor role selection |
/dashboard/courses |
✓ | Student: enrolled courses. Instructor: redirects to instructor dashboard |
/dashboard/courses/:id |
— | Course detail page — overview, curriculum, enroll button |
/dashboard/courses/:id/learn |
✓ | Video player with lesson sidebar, progress tracking, completion |
/dashboard/courses/create |
✓ INSTRUCTOR | Create course form with on-chain registration |
/dashboard/instructor |
✓ INSTRUCTOR | Revenue stats + my courses list |
/dashboard/certificates |
✓ | Student's earned certificates with copy + share links |
/certificates/:id |
— | Public certificate verification page (no login needed) |
/notifications |
✓ | Notification feed with colour-coded types |
Hamplard's foundational token system is documented in:
src/styles/tokens.css(source of truth for CSS variables)design-system-tokens.md(hex/RGB usage notes + WCAG checks)typography-system.md(modular type scale and semantic text roles)
Typography:
- Display headings: Playfair Display (serif)
- Body: DM Sans
- Code/IDs: JetBrains Mono
Public course marketplace (/) — browse, search, and filter active courses by category and level without signing in. The homepage shows a category pill bar with all eight Hamplard skill areas.
Role-aware login (/auth/login) — the login page has a student/instructor toggle. First-time users pick their role here and it is set on their account.
Course learn page (/dashboard/courses/:id/learn) — full-screen layout with a lesson sidebar (modules expanded/collapsed, completed lessons marked with checkmarks) and a main content area with the video player. Students click "Mark complete" after each lesson. Progress percentage updates live.
Certificate verification page (/certificates/:id) — a public, shareable page showing a gold certificate with the student's name, course title, instructor, issue date, and blockchain verification status. Uses server-side rendering for fast sharing.
Instructor course creation — three-step flow: fill in course details → upload thumbnail → register on Stellar via Freighter → submit for admin review. The form generates a unique courseId automatically.
cp .env.example .env.local # fill in contract ID + backend URL
npm install
npm run dev # → http://localhost:3001Install Freighter and switch it to Testnet.
npm run testRun all E2E tests across Chromium, Firefox, and WebKit:
npm run test:e2eOpen the Playwright UI for interactive test authoring and debugging:
npm run test:e2e:uiVisual regression tests use Playwright's toHaveScreenshot to catch accidental layout changes on the homepage and course detail page. Baseline screenshots are stored in e2e/screenshots/.
npx playwright test --project=visualThis runs tests tagged with @visual across three viewports:
- Mobile: 375px × 667px
- Tablet: 768px × 1024px
- Desktop: 1280px × 800px
After making intentional UI changes, regenerate and commit the new baselines:
npx playwright test --update-snapshotsThen commit the updated files in e2e/screenshots/ to the repository.
Note: Baseline screenshots must be committed to the repo before CI can pass. Run
--update-snapshotslocally on the same OS/architecture used by CI (Ubuntu Linux) to avoid platform-specific rendering differences.
Visual regression tests run automatically in GitHub Actions on every push and pull request. If a visual diff is detected, the CI job will fail and upload:
- The Playwright HTML report (with side-by-side diffs)
- Test traces for debugging
MIT TODO: Add and Configure robots.txt
-
Project Discovery
-
Inspect the repository structure.
-
Confirm the project uses Next.js.
-
Confirm the project uses Next.js 14.
-
Confirm the project uses the App Router.
-
Locate the "src/app" directory.
-
Confirm "src/app" contains the application routes.
-
Check whether a "robots.ts" file already exists.
-
Check whether a "robots.txt" file already exists.
-
Check whether another robots implementation exists elsewhere.
-
Search for existing Metadata API usage.
-
Search for existing "MetadataRoute" imports.
-
Search for an existing sitemap implementation.
-
Locate "src/app/sitemap.ts" if present.
-
Review the existing sitemap configuration.
-
Confirm the canonical site domain.
-
Confirm the required sitemap URL.
-
Review the project's route structure.
-
Identify dashboard routes.
-
Identify checkout routes.
-
Identify API routes.
-
Identify authentication routes.
-
Identify Next.js internal routes.
-
Identify public course routes.
-
Identify category routes.
-
Identify the about page.
-
Identify the teach page.
-
Identify the teams page.
-
Review existing route conventions.
-
Review existing tests.
-
Review existing build scripts.
-
Review existing development scripts.
-
Review linting configuration.
-
Review TypeScript configuration.
-
Confirm no custom robots middleware already exists.
-
Confirm no static robots file conflicts with the new route.
-
Check Git working tree status.
-
Confirm the task can be implemented without unrelated changes.
-
Identify the issue number for the PR.
-
Record the required PR closing statement.
-
Define the implementation scope.
-
robots.ts Creation
-
Create a new file at "src/app/robots.ts".
-
Use the Next.js Metadata API.
-
Import "MetadataRoute" from "next".
-
Use the "MetadataRoute.Robots" type.
-
Define the robots function.
-
Ensure the function returns the correct robots metadata structure.
-
Keep the implementation server-side compatible.
-
Avoid client-side directives.
-
Do not add unnecessary dependencies.
-
Do not create a custom API route for robots.txt.
-
Do not manually construct the robots.txt response.
-
Use the App Router MetadataRoute implementation.
-
Keep the file limited to robots configuration.
-
Add appropriate typing.
-
Ensure TypeScript can infer the return structure correctly.
-
Ensure the implementation follows Next.js 14 conventions.
-
Ensure the generated route is "/robots.txt".
-
Ensure no additional route handler is required.
-
Confirm Next.js generates the response automatically.
-
Keep the implementation readable.
-
Keep the implementation minimal.
-
Avoid unnecessary comments.
-
Avoid hard-coded route logic outside the robots configuration.
-
Avoid introducing unrelated metadata changes.
-
Verify the file is located exactly under "src/app".
-
Verify the filename is exactly "robots.ts".
-
Verify the file extension is TypeScript.
-
Verify the implementation exports the robots function correctly.
-
Verify the implementation uses "MetadataRoute.Robots".
-
Confirm the basic implementation compiles.
-
Allow Rules
-
Configure the root path "/" as allowed.
-
Configure "/courses" as allowed.
-
Configure "/courses/*" as allowed.
-
Configure "/categories/*" as allowed.
-
Configure "/about" as allowed.
-
Configure "/teach" as allowed.
-
Configure "/teams" as allowed.
-
Ensure the root public site remains crawlable.
-
Ensure the courses landing page remains crawlable.
-
Ensure course detail pages remain crawlable.
-
Ensure category pages remain crawlable.
-
Ensure the about page remains crawlable.
-
Ensure the teach page remains crawlable.
-
Ensure the teams page remains crawlable.
-
Confirm wildcard syntax is represented correctly.
-
Confirm "/courses/*" covers course detail routes.
-
Confirm "/categories/*" covers category detail routes.
-
Avoid accidentally disallowing public pages.
-
Avoid adding unrelated public routes to the allowlist.
-
Preserve the exact required allowlist.
-
Confirm "/" is not accidentally overridden by a broad disallow.
-
Confirm public pages can still be crawled.
-
Confirm public course content can be discovered.
-
Confirm category content can be discovered.
-
Confirm the allow rules generate valid robots directives.
-
Confirm rules are compatible with search-engine parsing.
-
Confirm wildcard behavior is valid.
-
Ensure no duplicate allow directives are generated unnecessarily.
-
Ensure the final output reflects the intended public routes.
-
Document any framework-specific wildcard representation if necessary.
-
Disallow Rules
-
Configure "/dashboard/*" as disallowed.
-
Configure "/checkout" as disallowed.
-
Configure "/api/*" as disallowed.
-
Configure "/auth/*" as disallowed.
-
Configure "/_next/" as disallowed.
-
Ensure dashboard pages cannot be crawled.
-
Ensure dashboard subroutes cannot be crawled.
-
Ensure checkout is excluded from crawling.
-
Ensure API routes are excluded from crawling.
-
Ensure API subroutes are excluded from crawling.
-
Ensure authentication routes are excluded from crawling.
-
Ensure authentication subroutes are excluded from crawling.
-
Ensure Next.js internal assets are excluded where required.
-
Confirm the dashboard wildcard is represented correctly.
-
Confirm the API wildcard is represented correctly.
-
Confirm the authentication wildcard is represented correctly.
-
Confirm the "/_next/" path is represented correctly.
-
Ensure no public route is accidentally disallowed.
-
Avoid broad disallow rules such as "/".
-
Avoid disallowing "/courses".
-
Avoid disallowing "/categories".
-
Avoid disallowing "/about".
-
Avoid disallowing "/teach".
-
Avoid disallowing "/teams".
-
Confirm the checkout path is specifically excluded.
-
Confirm dashboard paths are excluded before crawling.
-
Confirm API paths are excluded before crawling.
-
Confirm auth paths are excluded before crawling.
-
Confirm internal Next.js paths are excluded.
-
Verify disallow rules match the acceptance criteria.
-
User-Agent Configuration
-
Configure the robots policy for all search-engine crawlers.
-
Use the appropriate wildcard user-agent configuration.
-
Ensure the rules apply to general crawlers.
-
Ensure the rules are not limited to a single search engine.
-
Ensure the generated output contains the intended user-agent directive.
-
Avoid creating unnecessary crawler-specific rules.
-
Avoid duplicate user-agent sections.
-
Confirm the allow rules apply to the intended crawler group.
-
Confirm the disallow rules apply to the intended crawler group.
-
Confirm the output remains standards-compatible.
-
Keep crawler configuration simple.
-
Avoid adding unsupported directives.
-
Avoid adding crawl-delay unless explicitly required.
-
Avoid adding host directives.
-
Avoid adding unrelated SEO configuration.
-
Confirm the user-agent configuration is generated correctly.
-
Confirm the final output is readable.
-
Confirm crawlers can interpret the rules.
-
Confirm the implementation matches Next.js MetadataRoute behavior.
-
Document the intended crawler scope if project documentation requires it.
-
Sitemap Configuration
-
Add the sitemap URL to the robots configuration.
-
Ensure the sitemap URL is absolute.
-
Ensure the URL uses HTTPS.
-
Ensure the hostname is exactly "hamplard.com".
-
Ensure the path is exactly "/sitemap.xml".
-
Ensure the sitemap directive is generated.
-
Ensure the sitemap appears in "/robots.txt".
-
Confirm there are no typos in the domain.
-
Confirm there is no trailing whitespace.
-
Confirm the sitemap URL is not relative.
-
Confirm the sitemap URL is not accidentally duplicated.
-
Check whether an existing sitemap implementation uses the same domain.
-
Keep robots and sitemap configuration consistent.
-
Verify the sitemap directive follows the generated robots syntax.
-
Confirm search engines can identify the sitemap.
-
Confirm the sitemap directive is not placed inside an invalid user-agent rule.
-
Confirm the generated output contains exactly the required sitemap.
-
Avoid adding unrelated sitemap URLs.
-
Verify the sitemap requirement is fully satisfied.
-
Local Development Validation
-
Start the Next.js development server.
-
Confirm the application starts without errors.
-
Open "/robots.txt".
-
Confirm "/robots.txt" returns HTTP 200.
-
Confirm the response is plain text.
-
Confirm the generated content is not HTML.
-
Confirm the user-agent directive exists.
-
Confirm the root allow rule exists.
-
Confirm the courses allow rule exists.
-
Confirm course wildcard behavior is represented.
-
Confirm categories wildcard behavior is represented.
-
Confirm "/about" is allowed.
-
Confirm "/teach" is allowed.
-
Confirm "/teams" is allowed.
-
Confirm dashboard is disallowed.
-
Confirm checkout is disallowed.
-
Confirm API is disallowed.
-
Confirm auth is disallowed.
-
Confirm "/_next/" is disallowed.
-
Confirm the sitemap URL is present.
-
Confirm the sitemap URL is correct.
-
Confirm there are no unexpected directives.
-
Confirm there are no duplicate directives.
-
Confirm there are no TypeScript runtime errors.
-
Confirm hot reload detects changes if applicable.
-
Confirm the generated robots output updates after changes.
-
Test the route after restarting the dev server.
-
Test the route in a clean browser request.
-
Test the route using an HTTP client if available.
-
Record the final generated output for review.
-
Automated Testing
-
Search for existing metadata route tests.
-
Determine the project's preferred testing approach.
-
Add a test for "/robots.txt".
-
Verify the route exists.
-
Verify the route returns successfully.
-
Verify the output contains the user-agent directive.
-
Verify the root path is allowed.
-
Verify "/courses" is allowed.
-
Verify course wildcard paths are allowed.
-
Verify category wildcard paths are allowed.
-
Verify "/about" is allowed.
-
Verify "/teach" is allowed.
-
Verify "/teams" is allowed.
-
Verify "/dashboard/*" is disallowed.
-
Verify "/checkout" is disallowed.
-
Verify "/api/*" is disallowed.
-
Verify "/auth/*" is disallowed.
-
Verify "/_next/" is disallowed.
-
Verify the sitemap URL is included.
-
Verify the exact sitemap URL.
-
Verify no required allow rule is missing.
-
Verify no required disallow rule is missing.
-
Verify the response format.
-
Verify the generated robots configuration is deterministic.
-
Ensure tests do not depend on production infrastructure.
-
Ensure tests do not require external network access.
-
Ensure tests are repeatable.
-
Ensure tests use the project's existing testing conventions.
-
Add regression coverage for future changes.
-
Confirm the tests pass locally.
-
TypeScript & Build Verification
-
Run the project's type-check command.
-
Confirm "robots.ts" passes TypeScript validation.
-
Confirm the "MetadataRoute.Robots" type is valid.
-
Confirm there are no implicit "any" errors.
-
Confirm there are no unused imports.
-
Confirm there are no unused variables.
-
Run the project linter.
-
Fix any lint errors caused by the new file.
-
Run formatting checks.
-
Format the new file according to project standards.
-
Run the production build.
-
Confirm the build completes successfully.
-
Confirm "/robots.txt" is generated correctly by the production build.
-
Confirm the App Router recognizes the metadata route.
-
Confirm no route conflicts occur.
-
Confirm no existing sitemap functionality breaks.
-
Confirm no existing pages break.
-
Confirm no unrelated build warnings are introduced.
-
Review the final build output.
-
Confirm the implementation is production-ready.
-
Final Review & PR
-
Review the complete Git diff.
-
Confirm only intended files were changed.
-
Confirm "src/app/robots.ts" is included.
-
Confirm ".env" files were not modified unnecessarily.
-
Confirm no generated files were accidentally committed.
-
Confirm no dependencies were added unnecessarily.
-
Confirm no unrelated refactoring was included.
-
Confirm the implementation follows Next.js 14.
-
Confirm the implementation uses "MetadataRoute.Robots".
-
Confirm App Router requirements are satisfied.
-
Confirm all public pages are allowed.
-
Confirm all specified private paths are disallowed.
-
Confirm the sitemap URL is correct.
-
Confirm "/robots.txt" works in development.
-
Confirm "/robots.txt" works in production build validation.
-
Confirm automated tests pass.
-
Confirm linting passes.
-
Confirm type checking passes.
-
Confirm build passes.
-
Confirm acceptance criteria are fully satisfied.
-
PR Description
-
Create the pull request.
-
Use a clear PR title.
-
Summarize the robots.txt implementation.
-
Mention that the App Router Metadata API is used.
-
Mention the public routes that remain crawlable.
-
Mention the private routes that are disallowed.
-
Mention the sitemap configuration.
-
Mention "/robots.txt" validation.
-
Mention automated test coverage.
-
Include the required issue-closing syntax.
-
Replace "[issue_id]" with the actual issue number.
-
Ensure the PR description contains "Closes #[issue_id]".
-
Ensure the closing syntax is not accidentally written as plain placeholder text.
-
Verify GitHub recognizes the issue-closing syntax.
-
Include testing performed.
-
Include build/type-check results.
-
Include any relevant screenshots or output if required.
-
Confirm the PR description is concise.
-
Confirm the PR description accurately describes the changes.
-
Confirm no unrelated work is mentioned as completed.
-
Final Acceptance Checklist
-
"src/app/robots.ts" exists.
-
"MetadataRoute.Robots" is used.
-
"/robots.txt" returns the expected content.
-
Dashboard routes are disallowed.
-
API routes are disallowed.
-
Authentication routes are disallowed.
-
Checkout is disallowed.
-
Public pages are allowed.
-
"https://hamplard.com/sitemap.xml" is included.
-
PR description contains "Closes #[issue_id]" and the task is ready for review.