Skip to content

Project Structure Overview

This document provides a comprehensive overview of the 8531 TeamSite project structure, explaining the purpose and organization of each directory and key file.

/srv/team.8531.ca/
β”œβ”€β”€ .dev/ # Development documentation
β”‚ └── 1. domain-auth-strategy.md # Domain authentication strategy
β”œβ”€β”€ .env.example # Environment variables template
β”œβ”€β”€ .git/ # Git version control
β”œβ”€β”€ .gitignore # Git ignore patterns
β”œβ”€β”€ astro.config.mjs # Astro configuration file
β”œβ”€β”€ node_modules/ # Installed dependencies
β”œβ”€β”€ package.json # Project dependencies and scripts
β”œβ”€β”€ package-lock.json # Locked dependency versions
β”œβ”€β”€ public/ # Static assets
β”‚ β”œβ”€β”€ favicon.svg # Site favicon
β”‚ └── robots.txt # Search engine instructions
β”œβ”€β”€ src/ # Source code
β”‚ β”œβ”€β”€ components/ # Reusable Astro components
β”‚ β”‚ β”œβ”€β”€ AuthButton.astro # Login/logout button component
β”‚ β”‚ └── GoogleDriveFolder.astro # Google Drive folder display component
β”‚ β”œβ”€β”€ content/ # Content collections
β”‚ β”‚ β”œβ”€β”€ config.ts # Content schema and collection configuration
β”‚ β”‚ └── docs/ # Documentation pages
β”‚ β”‚ β”œβ”€β”€ index.md # Homepage documentation
β”‚ β”‚ β”œβ”€β”€ public/ # Publicly accessible content
β”‚ β”‚ β”‚ β”œβ”€β”€ About/ # General information pages
β”‚ β”‚ β”‚ β”œβ”€β”€ Policies/ # Public policy documents
β”‚ β”‚ β”‚ β”œβ”€β”€ Test1/ # Testing and demo content
β”‚ β”‚ β”‚ β”œβ”€β”€ contact.md # Contact information
β”‚ β”‚ β”‚ β”œβ”€β”€ resources.md # General resources
β”‚ β”‚ β”‚ └── test-autogenerate.md # Auto-generation demo
β”‚ β”‚ └── protected/ # Role-protected content
β”‚ β”‚ β”œβ”€β”€ member/ # Member+ access content
β”‚ β”‚ β”‚ β”œβ”€β”€ benefits.md
β”‚ β”‚ β”‚ β”œβ”€β”€ emergency-trusted-contact.md
β”‚ β”‚ β”‚ β”œβ”€β”€ life-insurance-policies.md
β”‚ β”‚ β”‚ β”œβ”€β”€ onboarding.md
β”‚ β”‚ β”‚ └── team-guidelines.md
β”‚ β”‚ β”œβ”€β”€ coreteam/ # CoreTeam+ access content
β”‚ β”‚ β”‚ β”œβ”€β”€ prospecting/
β”‚ β”‚ β”‚ β”œβ”€β”€ setting-appointments/
β”‚ β”‚ β”‚ β”œβ”€β”€ presentations/
β”‚ β”‚ β”‚ β”œβ”€β”€ objections/
β”‚ β”‚ β”‚ β”œβ”€β”€ products/
β”‚ β”‚ β”‚ β”œβ”€β”€ recruiting-inviting/
β”‚ β”‚ β”‚ β”œβ”€β”€ fast-start/
β”‚ β”‚ β”‚ β”œβ”€β”€ promotions/
β”‚ β”‚ β”‚ β”œβ”€β”€ tools-resources/
β”‚ β”‚ β”‚ └── admin/
β”‚ β”‚ β”‚ β”œβ”€β”€ guides/
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ components/
β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ diagrams.mdx
β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ google-drive.mdx
β”‚ β”‚ β”‚ β”‚ β”‚ └── videos.mdx
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ creating-pages.md
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ formatting.md
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ index.md
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ publishing-workflow.md
β”‚ β”‚ β”‚ β”‚ └── using-components.mdx
β”‚ β”‚ β”‚ └── system/
β”‚ β”‚ β”‚ β”œβ”€β”€ architecture.md
β”‚ β”‚ β”‚ β”œβ”€β”€ authentication.md
β”‚ β”‚ β”‚ β”œβ”€β”€ deployment.md
β”‚ β”‚ β”‚ β”œβ”€β”€ development.md
β”‚ β”‚ β”‚ └── security.md
β”‚ β”‚ └── admin/ # Admin-only content (archived)
β”‚ β”œβ”€β”€ data/ # Static data and utilities
β”‚ β”‚ └── pdfs.ts # PDF metadata management utilities
β”‚ β”œβ”€β”€ lib/ # Core utilities and services
β”‚ β”‚ β”œβ”€β”€ auth.ts # JWT verification and authentication
β”‚ β”‚ β”œβ”€β”€ auth-client.ts # Client-side authentication helpers
β”‚ β”‚ β”œβ”€β”€ config.ts # Environment detection and configuration
β”‚ β”‚ β”œβ”€β”€ env.ts # Environment variable validation
β”‚ β”‚ β”œβ”€β”€ folder-utils.ts # Google Drive folder utilities
β”‚ β”‚ β”œβ”€β”€ google-drive.ts # Google Drive API integration
β”‚ β”‚ β”œβ”€β”€ nav.ts # Navigation generation utilities
β”‚ β”‚ └── README-google-drive.md # Google Drive documentation
β”‚ β”œβ”€β”€ layouts/ # Page layout components
β”‚ β”‚ └── Layout.astro # Main site layout wrapper
β”‚ β”œβ”€β”€ pages/ # Astro pages and API routes
β”‚ β”‚ β”œβ”€β”€ api/ # API endpoints
β”‚ β”‚ β”‚ β”œβ”€β”€ auth/
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ login.ts # OAuth login endpoint
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ callback.ts # OAuth callback handler
β”‚ β”‚ β”‚ β”‚ └── logout.ts # Logout endpoint
β”‚ β”‚ β”‚ β”œβ”€β”€ pdfs-dev/ # PDF file access endpoints
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ index.ts # PDF listing and search
β”‚ β”‚ β”‚ β”‚ └── [fileId].ts # Individual PDF download
β”‚ β”‚ β”‚ β”œβ”€β”€ test/ # Testing endpoints
β”‚ β”‚ β”‚ β”‚ └── drive-test.ts # Google Drive testing
β”‚ β”‚ β”‚ └── session.ts # Session verification
β”‚ β”‚ └── index.astro # Homepage
β”‚ β”œβ”€β”€ route-middleware.ts # Authentication middleware
β”‚ β”œβ”€β”€ styles/ # Styling
β”‚ β”‚ └── global.css # Global CSS styles
β”‚ └── utils/ # Utility functions
β”‚ β”œβ”€β”€ shortcodes/
β”‚ β”‚ β”œβ”€β”€ remark-d2-shortcodes.js
β”‚ β”‚ └── remark-video-shortcodes.js
β”œβ”€β”€ vercel.json # Vercel deployment configuration
└── README.md # Main project documentation
  • Static Site Generation: Pre-builds pages at build time
  • Server-Side Rendering: For API routes and dynamic content
  • Islands Architecture: Client-side JavaScript only where needed
  • Content Collections: Type-safe content management
  • Documentation Site: Purpose-built for documentation
  • Automatic Navigation: Generated from content structure
  • Search: Built-in search functionality
  • Theme: Dark/light mode with custom styling
  • JWT-based: RS256 asymmetric encryption
  • Role-based Access Control: Four-tier permission system
  • OAuth Integration: Through auth.8531.ca gateway
  • Middleware: Route-level authentication

Reusable UI components:

  • AuthButton.astro: Handles login/logout UI with role-aware display
  • GoogleDriveFolder.astro: Displays files from any Google Drive folder

All site documentation organized by access level:

  • public/: Everyone can access (Guest+)
  • protected/member/: Team members and above
  • protected/coreteam/: Core team and admins
  • protected/admin/: Administrators only

Core application logic:

  • auth.ts: Server-side authentication utilities
  • google-drive.ts: Google Drive API service
  • config.ts: Environment and configuration management
  • nav.ts: Dynamic navigation generation

Serverless API endpoints:

  • auth/: Authentication endpoints
  • pdfs-dev/: Google Drive file access
  • test/: Development testing utilities

Page templates and wrappers:

  • Layout.astro: Main site layout with header, footer, navigation

Main Astro configuration:

  • Integrations: Starlight, Vercel, Tailwind, MDX
  • Output Mode: Server-side rendering for APIs
  • Aliases: Import path shortcuts
  • Security: CSP and header configuration

Project metadata and scripts:

  • Dependencies: Production libraries
  • Dev Dependencies: Development tools
  • Scripts: Build, dev, test commands
  • Type: Module (ESM)

Deployment configuration:

  • Build Settings: How to build the project
  • Routes: API routing configuration
  • Headers: Security and CORS headers
  • Functions: Serverless function settings
  1. Route Middleware (route-middleware.ts)

    • Validates JWT tokens
    • Enforces role-based access
    • Handles unauthenticated requests
  2. Auth Client (auth-client.ts)

    • Client-side helpers
    • Token management
    • Login/logout flows
  3. Auth Button (AuthButton.astro)

    • UI component for authentication
    • Role-aware display
    • Dropdown with user info
  1. Service Layer (google-drive.ts)

    • Google API client
    • File listing and downloading
    • Metadata parsing
  2. API Endpoints (/api/pdfs-dev/)

    • File listing with pagination
    • Individual file access
    • Search and filtering
  3. Display Component (GoogleDriveFolder.astro)

    • Reusable folder display
    • Preview/download buttons
    • Responsive grid layout
  1. Collections (content/config.ts)

    • Type-safe content schemas
    • Role and status validation
    • Custom frontmatter fields
  2. Navigation (nav.ts)

    • Dynamic menu generation
    • Role-based filtering
    • Status-aware visibility
  1. User clicks login
  2. Redirect to auth.8531.ca
  3. Google OAuth authentication
  4. JWT token generation
  5. Redirect back with token
  6. Route middleware validates token
  7. Content filtered by role
  1. Astro builds static pages
  2. Middleware validates access
  3. Starlight renders documentation
  4. Navigation filtered by role
  5. API endpoints handle dynamic requests
  1. Component mounts with folder ID
  2. API call to /api/pdfs-dev/
  3. Service fetches from Google Drive
  4. Files displayed in grid
  5. Preview/download via direct links
  • RS256 JWTs: Asymmetric encryption
  • HTTP-only Cookies: Prevent XSS
  • SameSite: CSRF protection
  • Short-lived Tokens: 1-hour expiration
  • Role-based Access: Four-tier system
  • Content Status: Draft/review/published/archived
  • File Access: Validated per request
  • API Protection: All endpoints authenticated
  • HTTPS Only: Production enforcement
  • Security Headers: X-Frame-Options, CSP
  • CORS: Environment-specific policies
  • Input Validation: TypeScript + Zod schemas
  • Static Generation: Pre-built pages
  • Code Splitting: Automatic bundling
  • Asset Optimization: Minification, compression
  • Image Optimization: Responsive formats
  • Edge Caching: Vercel’s global CDN
  • API Caching: 5-minute response cache
  • Lazy Loading: Client-side components
  • Tree Shaking: Unused code removal
  • Vercel Analytics: Built-in metrics
  • Web Vitals: Core performance metrics
  • Error Tracking: Centralized logging
  • API Monitoring: Response times, error rates
  1. Create .md file in appropriate directory
  2. Add frontmatter with role/status
  3. Write content (use ## for headings)
  4. Test with different roles
  5. Deploy when ready
  1. Plan feature and access requirements
  2. Create components in /src/components/
  3. Add API routes if needed
  4. Update types and schemas
  5. Test thoroughly
  6. Document changes
  • Dependencies: Regular updates and audits
  • Security: Periodic reviews and patches
  • Content: Review and archive outdated
  • Performance: Monitor and optimize

This structure provides a scalable, maintainable foundation for the 8531 TeamSite with clear separation of concerns and comprehensive documentation.