mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 04:17:17 +01:00
* docs: archive point-in-time records, drop broken guide symlinks Status reports, progress trackers, audits, session summaries, completed migration plans and the 2025 roadmap move to docs/archive/ (same relative path), with a README saying they describe the day they were written. .ai-guides/ held only symlinks into a docs/guides/ai/ that no longer exists, tests/unit/docs/ held a stray copy of an old getting-started page, and docs/operations/PORT_MANAGEMENT_README.md duplicated port-management.md; all three are deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: correct drifted paths, links and versions in current docs Fix in place the reference docs agents use: point paths at where the code lives now (src/stores/auth.ts, src/lib/supabase/*, scripts/dev/*, docs/reference/api/CONVENTIONS.md, the squashed baseline migration), rewrite the development, features, operations and API index pages to list documents that exist, say plainly where something is gone (/api/metrics, the CSP report route, .envrc in the repo, Loki's `migrate` script), and correct the Next.js major. docs-truth findings: 468 -> 2 (both "Next 30/90 Days" headings in the legal overview, a checker false positive). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD --------- Co-authored-by: Claude <noreply@anthropic.com>
9.9 KiB
9.9 KiB
created_date, last_modified_date, last_modified_summary
| created_date | last_modified_date | last_modified_summary |
|---|---|---|
| 2025-09-25 | 2025-09-25 | Created comprehensive codebase organization guide reflecting the cleaned up project structure |
📁 Codebase Organization
Overview
This document describes the organization and structure of the OrangeCat codebase after a comprehensive cleanup and reorganization. The structure follows industry best practices for maintainability, scalability, and developer experience.
🏗️ Project Root Structure
orangecat/
├── 📁 src/ # Main source code
├── 📁 scripts/ # Organized utility scripts
│ ├── 📁 db/ # Database operations
│ ├── 📁 deployment/ # Deployment utilities
│ ├── 📁 dev/ # Development tools
│ ├── 📁 test/ # Testing utilities
│ └── 📁 maintenance/ # Cleanup and optimization
├── 📁 tests/ # All test files (unified structure)
├── 📁 docs/ # Comprehensive documentation
├── 📁 public/ # Static assets
├── 📁 supabase/ # Supabase configuration
├── 📁 __mocks__/ # Test mocks (Vitest)
├── 📁 coverage/ # Test coverage reports
└── 📄 Standard config files # package.json, tsconfig.json, etc.
📁 Source Code Structure (src/)
Core Architecture
src/
├── 📁 app/ # Next.js 13+ App Router
│ ├── 📁 api/ # API routes (Next.js)
│ ├── 📁 (authenticated)/ # Protected routes
│ └── 📁 auth/ # Authentication pages
├── 📁 components/ # React components
│ ├── 📁 auth/ # Authentication components
│ ├── 📁 bitcoin/ # Bitcoin-related components
│ ├── 📁 dashboard/ # Dashboard components
│ ├── 📁 funding/ # Funding components
│ ├── 📁 layout/ # Layout components
│ ├── 📁 ui/ # Reusable UI components
│ └── 📁 __tests__/ # Component tests
├── 📁 services/ # Business logic services
│ ├── 📁 profile/ # Profile management
│ ├── 📁 supabase/ # Supabase services
│ ├── 📁 bitcoin/ # Bitcoin services
│ ├── 📁 projects/ # Campaign services
│ └── 📁 __tests__/ # Service tests
├── 📁 hooks/ # Custom React hooks
│ └── 📁 __tests__/ # Hook tests
├── 📁 lib/ # Utility libraries
├── 📁 stores/ # State management (Zustand)
│ └── 📁 __tests__/ # Store tests
├── 📁 utils/ # Utility functions
│ └── 📁 __tests__/ # Utility tests
├── 📁 types/ # TypeScript type definitions
├── 📁 config/ # Configuration files
├── 📁 middleware/ # Next.js middleware
└── 📄 profileService.ts # Re-export for clean imports
Architecture Principles
- Feature-Based Organization: Components and services are organized by business domain
- Separation of Concerns: Clear separation between UI, business logic, and utilities
- Testing Colocation: Tests are located alongside the code they test
- Clean Imports: Use of path aliases (@/) for clean, consistent imports
📁 Scripts Organization
The scripts directory is organized by purpose for easy maintenance:
Database Scripts (scripts/db/)
- Schema management and migrations
- Profile creation and management
- Data validation and cleanup
- Supabase configuration
Deployment Scripts (scripts/deployment/)
- Production deployment utilities
- Environment setup
- Deployment verification
- Monitoring and validation
Development Scripts (scripts/dev/)
- Development server management
- API key management
- Environment synchronization
- Development utilities
Testing Scripts (scripts/test/)
- Test execution utilities
- Test data generation
- Test environment setup
Maintenance Scripts (scripts/maintenance/)
- Bundle analysis and optimization
- Console log cleanup
- Performance monitoring
- Code quality checks
📁 Testing Structure
All tests are unified under the tests/ directory:
tests/
├── 📁 auth/ # Authentication tests
├── 📁 security/ # Security tests
├── 📁 e2e/ # End-to-end tests
├── 📁 setup/ # Test setup utilities
├── 📄 setup.ts # Global test setup
├── 📄 teardown.ts # Global test teardown
└── 📄 utils.ts # Test utilities
Test Categories
- Unit Tests: Located in
__tests__/subdirectories within each feature - Integration Tests: Located alongside the code they test
- E2E Tests: In
tests/e2e/directory - Security Tests: In
tests/security/directory
📁 Documentation Structure
Comprehensive documentation organized by purpose:
docs/
├── 📄 README.md # Main documentation entry point
├── 📁 architecture/ # System architecture
├── 📁 development/ # Development guides
├── 📁 operations/ # Deployment and operations
├── 📁 security/ # Security documentation
├── 📁 design-system/ # UI/UX design system
├── 📁 components/ # Component documentation
├── 📁 features/ # Feature documentation
├── 📁 api/ # API documentation
└── 📁 templates/ # Documentation templates
📁 Configuration Files
Consolidated Configuration
- vitest.config.ts: Vitest configuration
- vitest.setup.ts: Comprehensive test environment setup
- tsconfig.json: TypeScript configuration with path mapping
- next.config.js: Next.js configuration
- tailwind.config.ts: Tailwind CSS configuration
Configuration Principles
- Single Source of Truth: No duplicate configuration files
- Environment-Specific: Proper separation of dev/prod configs
- Type Safety: Full TypeScript support for configuration
- Performance: Optimized for development and production
🧹 Code Quality Standards
Import Strategy
- Use path aliases (
@/) for all internal imports - Avoid relative imports (
../../../) when possible - Group imports by type (external, internal, relative)
- Use index files for clean public APIs
File Organization
- One component per file (except for tightly coupled components)
- Single responsibility principle for all modules
- Consistent naming conventions (kebab-case for files, PascalCase for components)
- Proper TypeScript typing throughout
Code Style
- ESLint + Prettier for consistent formatting
- TypeScript strict mode enabled
- No
anytypes (except in rare, well-documented cases) - Comprehensive error handling
🚀 Development Workflow
Getting Started
- Setup: Follow the Development Setup guide
- Environment: Copy
config/production.env.templateto.env.local - Dependencies: Run
pnpm install - Development: Use
pnpm run devfor development server
Code Organization Guidelines
- New Features: Create feature branch with descriptive name
- File Placement: Follow the established directory structure
- Tests: Write tests alongside new code
- Documentation: Update relevant documentation
- Reviews: Follow the contributing guidelines
Best Practices
- Keep files under 400 lines when possible
- Use feature flags for experimental features
- Implement proper error boundaries
- Follow accessibility guidelines
- Maintain performance budgets
🔍 Finding Files
Quick Navigation
- Components:
src/components/[feature]/ - Services:
src/services/[domain]/ - Types:
src/types/[domain].ts - Tests:
src/[module]/__tests__/ortests/[category]/ - Documentation:
docs/[category]/[topic].md
Search Strategy
- Use IDE search for exact file names
- Check feature directories for related functionality
- Look in
docs/for documentation - Search by component/service name in the appropriate directory
📝 Maintenance Guidelines
Keeping Organized
- Regular Cleanup: Remove unused files and dependencies
- Update Documentation: Keep docs in sync with code changes
- Review Structure: Periodically review and optimize organization
- Archive Old Files: Move deprecated code to appropriate locations
Adding New Code
- Follow the established directory structure
- Add tests for new functionality
- Update relevant documentation
- Use consistent naming conventions
- Follow the project's coding standards
🎯 Benefits of This Structure
For Developers
- Easy Navigation: Clear, logical file organization
- Fast Onboarding: Well-documented structure and guidelines
- Consistent Patterns: Standardized approach across the codebase
- Quality Assurance: Comprehensive testing and documentation
For Maintenance
- Scalability: Structure supports growth and new features
- Debugging: Easy to locate and fix issues
- Refactoring: Clear boundaries for code changes
- Team Collaboration: Consistent structure across team members
For Production
- Reliability: Comprehensive testing and validation
- Performance: Optimized build and runtime configuration
- Security: Security-first approach with proper isolation
- Deployability: Clean deployment pipeline with proper environments
📚 Next Steps: Review the Contributing Guide for detailed development workflows and the Architecture Overview for system design details.