Project Structure Overview
Project Structure Overview
Section titled β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.
π Directory Structure
Section titled βπ Directory Structureβ/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ποΈ Architecture Overview
Section titled βποΈ Architecture OverviewβAstro Framework
Section titled βAstro Frameworkβ- 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
Starlight Documentation
Section titled βStarlight Documentationβ- Documentation Site: Purpose-built for documentation
- Automatic Navigation: Generated from content structure
- Search: Built-in search functionality
- Theme: Dark/light mode with custom styling
Authentication Layer
Section titled βAuthentication Layerβ- JWT-based: RS256 asymmetric encryption
- Role-based Access Control: Four-tier permission system
- OAuth Integration: Through auth.8531.ca gateway
- Middleware: Route-level authentication
π Key Directories Explained
Section titled βπ Key Directories Explainedβ/src/components/
Section titled β/src/components/βReusable UI components:
- AuthButton.astro: Handles login/logout UI with role-aware display
- GoogleDriveFolder.astro: Displays files from any Google Drive folder
/src/content/docs/
Section titled β/src/content/docs/β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
/src/lib/
Section titled β/src/lib/β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
/src/pages/api/
Section titled β/src/pages/api/βServerless API endpoints:
- auth/: Authentication endpoints
- pdfs-dev/: Google Drive file access
- test/: Development testing utilities
/src/layouts/
Section titled β/src/layouts/βPage templates and wrappers:
- Layout.astro: Main site layout with header, footer, navigation
π§ Configuration Files
Section titled βπ§ Configuration Filesβastro.config.mjs
Section titled βastro.config.mjsβMain Astro configuration:
- Integrations: Starlight, Vercel, Tailwind, MDX
- Output Mode: Server-side rendering for APIs
- Aliases: Import path shortcuts
- Security: CSP and header configuration
package.json
Section titled βpackage.jsonβProject metadata and scripts:
- Dependencies: Production libraries
- Dev Dependencies: Development tools
- Scripts: Build, dev, test commands
- Type: Module (ESM)
vercel.json
Section titled βvercel.jsonβDeployment configuration:
- Build Settings: How to build the project
- Routes: API routing configuration
- Headers: Security and CORS headers
- Functions: Serverless function settings
π― Key Features Implementation
Section titled βπ― Key Features ImplementationβAuthentication System
Section titled βAuthentication Systemβ-
Route Middleware (
route-middleware.ts)- Validates JWT tokens
- Enforces role-based access
- Handles unauthenticated requests
-
Auth Client (
auth-client.ts)- Client-side helpers
- Token management
- Login/logout flows
-
Auth Button (
AuthButton.astro)- UI component for authentication
- Role-aware display
- Dropdown with user info
Google Drive Integration
Section titled βGoogle Drive Integrationβ-
Service Layer (
google-drive.ts)- Google API client
- File listing and downloading
- Metadata parsing
-
API Endpoints (
/api/pdfs-dev/)- File listing with pagination
- Individual file access
- Search and filtering
-
Display Component (
GoogleDriveFolder.astro)- Reusable folder display
- Preview/download buttons
- Responsive grid layout
Content Management
Section titled βContent Managementβ-
Collections (
content/config.ts)- Type-safe content schemas
- Role and status validation
- Custom frontmatter fields
-
Navigation (
nav.ts)- Dynamic menu generation
- Role-based filtering
- Status-aware visibility
π Data Flow
Section titled βπ Data FlowβAuthentication Flow
Section titled βAuthentication Flowβ- User clicks login
- Redirect to auth.8531.ca
- Google OAuth authentication
- JWT token generation
- Redirect back with token
- Route middleware validates token
- Content filtered by role
Content Rendering Flow
Section titled βContent Rendering Flowβ- Astro builds static pages
- Middleware validates access
- Starlight renders documentation
- Navigation filtered by role
- API endpoints handle dynamic requests
Google Drive File Access
Section titled βGoogle Drive File Accessβ- Component mounts with folder ID
- API call to
/api/pdfs-dev/ - Service fetches from Google Drive
- Files displayed in grid
- Preview/download via direct links
π‘οΈ Security Architecture
Section titled βπ‘οΈ Security ArchitectureβAuthentication Security
Section titled βAuthentication Securityβ- RS256 JWTs: Asymmetric encryption
- HTTP-only Cookies: Prevent XSS
- SameSite: CSRF protection
- Short-lived Tokens: 1-hour expiration
Content Security
Section titled βContent Securityβ- Role-based Access: Four-tier system
- Content Status: Draft/review/published/archived
- File Access: Validated per request
- API Protection: All endpoints authenticated
Infrastructure Security
Section titled βInfrastructure Securityβ- HTTPS Only: Production enforcement
- Security Headers: X-Frame-Options, CSP
- CORS: Environment-specific policies
- Input Validation: TypeScript + Zod schemas
π Performance Considerations
Section titled βπ Performance ConsiderationsβBuild Performance
Section titled βBuild Performanceβ- Static Generation: Pre-built pages
- Code Splitting: Automatic bundling
- Asset Optimization: Minification, compression
- Image Optimization: Responsive formats
Runtime Performance
Section titled βRuntime Performanceβ- Edge Caching: Vercelβs global CDN
- API Caching: 5-minute response cache
- Lazy Loading: Client-side components
- Tree Shaking: Unused code removal
Monitoring
Section titled βMonitoringβ- Vercel Analytics: Built-in metrics
- Web Vitals: Core performance metrics
- Error Tracking: Centralized logging
- API Monitoring: Response times, error rates
π Development Workflow
Section titled βπ Development WorkflowβAdding New Content
Section titled βAdding New Contentβ- Create
.mdfile in appropriate directory - Add frontmatter with role/status
- Write content (use
##for headings) - Test with different roles
- Deploy when ready
Adding New Features
Section titled βAdding New Featuresβ- Plan feature and access requirements
- Create components in
/src/components/ - Add API routes if needed
- Update types and schemas
- Test thoroughly
- Document changes
Maintenance Tasks
Section titled βMaintenance Tasksβ- 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.