|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## MOST IMPORTANT: Always read the LLM context files in `/llms/` before making any code changes or refactor proposals. |
| 6 | + |
| 7 | +## MOST IMPORTANT: NO WRITE COMMENTS in the codebase. Use PR comments instead. |
| 8 | + |
| 9 | +## Project Overview |
| 10 | + |
| 11 | +This is **angular.fun** - a modern Angular 20+ blog application with Supabase backend. The project is currently a monolithic structure in `/src` but is being refactored into a multi-project workspace with micro-frontends and shared libraries. |
| 12 | + |
| 13 | +### Current Architecture |
| 14 | + |
| 15 | +- **Main App**: `/src/app` - Monolithic structure containing both reader and admin functionality |
| 16 | +- **Reader**: `/src/app/reader` - Public blog with SSG/SSR capabilities |
| 17 | +- **Admin**: `/src/app/admin` - Admin panel with CSR for content management |
| 18 | +- **Shared**: `/src/app/shared` - Common components, services, models, and stores |
| 19 | + |
| 20 | +### Target Architecture (Multi-Project Workspace) |
| 21 | + |
| 22 | +- **projects/web**: Public blog with hybrid rendering (SSG for articles, SSR for home) |
| 23 | +- **projects/admin**: Pure CSR admin panel for Firebase Hosting |
| 24 | +- **projects/code-samples-mfe**: Micro-frontend for code samples via Native Federation |
| 25 | +- **projects/shared**: Shared library with UI components, patterns, data-access, and models |
| 26 | + |
| 27 | +## Common Development Commands |
| 28 | + |
| 29 | +### Development |
| 30 | + |
| 31 | +```bash |
| 32 | +npm start # Start main app (development mode) |
| 33 | +npm run start:local # Start with local Supabase configuration |
| 34 | +npm run start:local:docker # Open Docker for local development |
| 35 | +npm run start:local:backend # Start local Supabase instance |
| 36 | +``` |
| 37 | + |
| 38 | +### Building |
| 39 | + |
| 40 | +```bash |
| 41 | +npm run build # Build for production |
| 42 | +npm run build:stats # Build with bundle analysis stats |
| 43 | +npm run analyze # Analyze bundle size with webpack-bundle-analyzer |
| 44 | +``` |
| 45 | + |
| 46 | +### Testing |
| 47 | + |
| 48 | +```bash |
| 49 | +npm test # Run unit tests with Karma |
| 50 | +npm run e2e # Run E2E tests with Playwright |
| 51 | +npm run e2e:local # Run E2E tests against local environment |
| 52 | +``` |
| 53 | + |
| 54 | +### Supabase Management |
| 55 | + |
| 56 | +```bash |
| 57 | +npx supabase start # Start local Supabase |
| 58 | +npx supabase stop # Stop local Supabase |
| 59 | +npm run schema:pull # Pull remote schema from cloud Supabase |
| 60 | +npm run db:createSeed # Create database seed file |
| 61 | +npm run db:seed # Initialize database with seed data |
| 62 | +``` |
| 63 | + |
| 64 | +### Project-Specific Commands |
| 65 | + |
| 66 | +```bash |
| 67 | +ng serve admin # Serve admin project (when refactored) |
| 68 | +ng serve web # Serve web project (when refactored) |
| 69 | +ng build shared # Build shared library |
| 70 | +ng serve code-samples-mfe # Serve code samples micro-frontend |
| 71 | +``` |
| 72 | + |
| 73 | +## Key Technologies & Stack |
| 74 | + |
| 75 | +- **Frontend**: Angular 20, NgRx Signals, Tailwind CSS, DaisyUI, Quill Editor, Highlight.js |
| 76 | +- **Backend**: Supabase (PostgreSQL, Authentication, Storage, Functions) |
| 77 | +- **Testing**: Playwright for E2E, Karma/Jasmine for unit tests |
| 78 | +- **Build**: Angular CLI with esbuild, SSR/SSG capabilities |
| 79 | +- **State Management**: NgRx SignalStore throughout all applications |
| 80 | + |
| 81 | +## Code Architecture Patterns |
| 82 | + |
| 83 | +### State Management |
| 84 | + |
| 85 | +- Use NgRx SignalStore for all state management |
| 86 | +- Feature-scoped stores in individual feature directories |
| 87 | +- Shared stores in `/src/app/shared/stores` -> refactor to `/projects/shared/src/data-access/stores` in new architecture |
| 88 | + |
| 89 | +### Component Structure |
| 90 | + |
| 91 | +- Standalone components using Angular's modern APIs |
| 92 | +- Feature-based organization with lazy-loaded routes |
| 93 | +- UI components are pure and stateless (inputs/outputs only) |
| 94 | +- Business logic encapsulated in services and stores |
| 95 | + |
| 96 | +### Data Access |
| 97 | + |
| 98 | +- **Public/Reader**: Uses PostgREST endpoints for SSG/SSR compatibility |
| 99 | +- **Admin**: Uses `@supabase/supabase-js` browser client |
| 100 | +- **Authentication**: Supabase Auth with role-based access control |
| 101 | +- **Storage**: Supabase Storage CDN for images and assets |
| 102 | + |
| 103 | +### Routing |
| 104 | + |
| 105 | +- Lazy-loaded feature modules |
| 106 | +- Route-level providers for feature isolation |
| 107 | +- Functional guards for authentication (`authAdminGuard`) |
| 108 | + |
| 109 | +## Development Guidelines |
| 110 | + |
| 111 | +### File Organization |
| 112 | + |
| 113 | +- The legacy monolith remains under `/src` until migration is complete — **do not modify** unless explicitly approved. |
| 114 | +- The target workspace lives under `/projects` and `/projects/shared`. |
| 115 | + |
| 116 | +**Apps** |
| 117 | + |
| 118 | +- `projects/web` — feature-first, standalone, lazy: |
| 119 | + - `app/` (bootstrap, root routes) |
| 120 | + - `features/<feature-name>/` (routes, components, stores, services) |
| 121 | + - `layout/` (shell, navigation, footer) |
| 122 | + - `core/` (app-level providers: http, interceptors, guards) |
| 123 | +- `projects/admin` — CSR-only, same structure as `web`. |
| 124 | +- `projects/code-samples-mfe` — remote MFE, only required features and mfe routing. |
| 125 | + |
| 126 | +**Shared library** |
| 127 | + |
| 128 | +- `projects/shared/` |
| 129 | + - `ui/` (pure presentational components; no business logic) |
| 130 | + - `pattern/` (composable building blocks, form controls, table abstractions) |
| 131 | + - `data-access/` (clients, repositories, query functions; PostgREST for web SSR/SSG, supabase-js for admin) |
| 132 | + - `models/` (types, DTOs, schema definitions) |
| 133 | + - `utils/` (pure functions, pipes, directives) |
| 134 | + |
| 135 | +**General rules** |
| 136 | + |
| 137 | +- Standalone + lazy everywhere; **no cross-feature TS imports**. |
| 138 | +- Promote reusable logic “upwards” (from feature → pattern/ui/data-access). |
| 139 | +- Keep guards/interceptors/providers at route-level or in `core/` per app. |
| 140 | +- Tailwind/DaisyUI configuration shared where possible; design tokens in `shared`. |
| 141 | + |
| 142 | +See the [architecture.txt](llms/private/architecture.txt) document for authoritative rules and dependency boundaries. |
| 143 | + |
| 144 | +### Styling |
| 145 | + |
| 146 | +- Use Tailwind CSS with DaisyUI components |
| 147 | +- Custom color palette: primary (#12372A), secondary (#436850), tertiary (#ADBC9F), quaternary (#FBFADA) |
| 148 | +- Monitor CSS bundle size with budget limits in angular.json |
| 149 | + |
| 150 | +### Type Safety |
| 151 | + |
| 152 | +- Strict TypeScript configuration enabled |
| 153 | +- Supabase types generated in `/src/app/types/supabase/` -> refactor to `/projects/shared/src/models/supabase/` |
| 154 | +- Use proper interfaces for all data models |
| 155 | + |
| 156 | +### Environment Configuration |
| 157 | + |
| 158 | +- `environment.ts` - Production |
| 159 | +- `environment.development.ts` - Development |
| 160 | +- `environment.local.ts` - Local Supabase instance |
| 161 | + |
| 162 | +## Supabase Integration |
| 163 | + |
| 164 | +### Supabase Configuration |
| 165 | + |
| 166 | +- projects/web uses PostgREST for SSG/SSR compatibility |
| 167 | +- rest uses `@supabase/supabase-js` for browser client |
| 168 | + |
| 169 | +### Database Schema |
| 170 | + |
| 171 | +- Posts, Comments, Tags, PostTags, Profiles tables |
| 172 | +- Row Level Security (RLS) policies for data protection |
| 173 | +- Migrations managed in `/supabase/migrations/` |
| 174 | + |
| 175 | +### Authentication |
| 176 | + |
| 177 | +- Email/password authentication |
| 178 | +- Role-based access (admin, user roles) |
| 179 | +- Protected admin routes with functional guards |
| 180 | + |
| 181 | +### Local Development |
| 182 | + |
| 183 | +- Use Docker for local Supabase instance |
| 184 | +- Access Supabase Studio at http://localhost:54323 |
| 185 | +- Seed data available via scripts in `/scripts/` |
| 186 | + |
| 187 | +## Testing Strategy |
| 188 | + |
| 189 | +### E2E Tests (Playwright) |
| 190 | + |
| 191 | +- Tests in `/e2e/` directory |
| 192 | +- Configured for multiple browsers (Chromium, Firefox, WebKit) |
| 193 | +- Helper utilities in `/e2e/helpers/` |
| 194 | +- Local and CI configurations available |
| 195 | + |
| 196 | +### Unit Tests |
| 197 | + |
| 198 | +- Colocated spec files with components/services |
| 199 | +- Karma + Jasmine test runner -> refactor to use Vitest in the future |
| 200 | +- Focus on business logic and component behavior |
| 201 | + |
| 202 | +## Build & Deployment |
| 203 | + |
| 204 | +### Bundle Optimization |
| 205 | + |
| 206 | +- Lazy loading for all features |
| 207 | +- Bundle analysis with webpack-bundle-analyzer |
| 208 | +- Performance budgets enforced in angular.json |
| 209 | +- Tree-shaking enabled for optimal bundle sizes |
| 210 | + |
| 211 | +### Target Deployments |
| 212 | + |
| 213 | +- **Web**: Google Cloud Run (SSG/SSR) |
| 214 | +- **Admin**: Firebase Hosting (CSR) |
| 215 | +- **Code Samples MFE**: Firebase Hosting (MFE) |
| 216 | +- **Assets**: Supabase Storage CDN |
| 217 | + |
| 218 | +## Migration Status |
| 219 | + |
| 220 | +The project is currently migrating from monolithic structure to multi-project workspace: |
| 221 | + |
| 222 | +- Current: Single app in `/src` |
| 223 | +- Target: Separate projects in `/projects/` with shared libraries |
| 224 | +- Architecture guidance available in `/llms/private/architecture.txt` |
| 225 | + |
| 226 | +## LLM Context Files |
| 227 | + |
| 228 | +Always read these files before making refactor proposals or code edits: |
| 229 | + |
| 230 | +- [llms/**/architecture.txt](llms/private/architecture.txt) |
| 231 | +- [llms/**/llm-full.txt](llms/private/llm-full.txt) |
| 232 | +- [llms/**/app-description.txt](llms/private/app-description.txt) |
| 233 | + |
| 234 | +These documents are authoritative for: |
| 235 | + |
| 236 | +- Workspace and folder structure |
| 237 | +- Angular 20 style and coding conventions |
| 238 | +- Target apps, rendering modes, and deployment |
0 commit comments