CLAUDE.md TemplatesClaude Code Template

CLAUDE.md Template: Angular Material + FastAPI + Redis Starter

CLAUDE.md Template for Angular Material + FastAPI + Redis stack. A copyable Claude Code starter to scaffold a robust full-stack project.

claude-md-templateangular-materialfastapiredisclaude-codefull-stackstarterfrontendbackend

Target User

Developers and AI engineers building full-stack apps with Angular Material, FastAPI, and Redis

Use Cases

  • Scaffold Angular Material frontend + FastAPI backend with Redis cache
  • Provide a disciplined CLAUDE.md Template for Claude Code to generate consistent code blocks

Markdown Template

CLAUDE.md Template: Angular Material + FastAPI + Redis Starter

# CLAUDE.md
Project role: Full-stack engineer for Angular Material + FastAPI + Redis stack
Architecture rules:
- Frontend uses Angular Material components and communicates with FastAPI backend via REST endpoints
- Backend uses FastAPI with async endpoints and Pydantic models
- Redis is used as a cache and session store; do not store secrets in Redis
- The primary datastore is assumed to be PostgreSQL via SQLAlchemy; migrations via Alembic
- All code must live in a clean monorepo with frontend and backend folders
File structure rules:
- frontend/ contains the Angular app with a conventional src/app structure
- backend/ contains a FastAPI app with a clean api/models/schemas layout
- tests/ covers unit and integration tests
- infra/ contains deployment configuration (Docker, docker-compose)
Authentication rules:
- Use OAuth2 with JWT for API authentication
- Use HttpOnly cookies for session management on the frontend when feasible
- Protect private endpoints with a current_user dependency
Database rules:
- Redis: cache layer only; no secrets stored here
- PostgreSQL: use SQLAlchemy models and Alembic migrations
Validation rules:
- FastAPI endpoints validate input with Pydantic models
- Angular forms validate on the client side with reactive forms
Security rules:
- Always use HTTPS
- Enable CSRF protection for state-changing operations
- Apply rate limiting and proper CORS configuration
- Do not log sensitive data
Testing rules:
- Unit tests for FastAPI endpoints using pytest + httpx
- Integration tests for cache and data flow
- Frontend tests using Angular testing utils
Deployment rules:
- Docker Compose starts frontend, backend, and Redis
- Use environment variables for config and secrets (SECRETS should be injected securely)
- CI/CD checks for type safety, linting, and test coverage
Things Claude must not do:
- Do not modify production secrets or credentials
- Do not bypass authentication mechanisms
- Do not remove required migrations or break backward compatibility

Overview

This CLAUDE.md template is a copyable CLAUDE.md file starter for a full-stack project using Angular Material for the UI, FastAPI for the backend, and Redis for caching. It is designed for developers building scalable, maintainable apps with a clean separation of concerns.

Direct answer: Use this template to generate a complete code block for Claude Code that can scaffold the frontend, backend, and cache strategy in a consistent way.

When to Use This CLAUDE.md Template

  • You want a reproducible starter for an Angular Material UI paired with a FastAPI backend and Redis cache.
  • You need a copiable Claude Code instruction set to generate scaffold code across frontend, backend, and cache layers.
  • You require a consistent file structure and security baseline for rapid delivery.

Copyable CLAUDE.md Template

# CLAUDE.md
Project role: Full-stack engineer for Angular Material + FastAPI + Redis stack
Architecture rules:
- Frontend uses Angular Material components and communicates with FastAPI backend via REST endpoints
- Backend uses FastAPI with async endpoints and Pydantic models
- Redis is used as a cache and session store; do not store secrets in Redis
- The primary datastore is assumed to be PostgreSQL via SQLAlchemy; migrations via Alembic
- All code must live in a clean monorepo with frontend and backend folders
File structure rules:
- frontend/ contains the Angular app with a conventional src/app structure
- backend/ contains a FastAPI app with a clean api/models/schemas layout
- tests/ covers unit and integration tests
- infra/ contains deployment configuration (Docker, docker-compose)
Authentication rules:
- Use OAuth2 with JWT for API authentication
- Use HttpOnly cookies for session management on the frontend when feasible
- Protect private endpoints with a current_user dependency
Database rules:
- Redis: cache layer only; no secrets stored here
- PostgreSQL: use SQLAlchemy models and Alembic migrations
Validation rules:
- FastAPI endpoints validate input with Pydantic models
- Angular forms validate on the client side with reactive forms
Security rules:
- Always use HTTPS
- Enable CSRF protection for state-changing operations
- Apply rate limiting and proper CORS configuration
- Do not log sensitive data
Testing rules:
- Unit tests for FastAPI endpoints using pytest + httpx
- Integration tests for cache and data flow
- Frontend tests using Angular testing utils
Deployment rules:
- Docker Compose starts frontend, backend, and Redis
- Use environment variables for config and secrets (SECRETS should be injected securely)
- CI/CD checks for type safety, linting, and test coverage
Things Claude must not do:
- Do not modify production secrets or credentials
- Do not bypass authentication mechanisms
- Do not remove required migrations or break backward compatibility

Recommended Project Structure

angular-material-fastapi-redis-claude-md-template/
  frontend/
    src/
      app/
        components/
        services/
        app.module.ts
        app.component.ts
      index.html
      styles.css
  backend/
    app/
      main.py
      api/
      models/
      schemas/
      core/
    requirements.txt
  infra/
    docker-compose.yml
  README.md
  docker-front.Dockerfile
  docker-back.Dockerfile

Core Engineering Principles

  • Separation of concerns: UI, API, and cache layers must remain decoupled
  • Explicit contracts: define Pydantic models, API schemas, and UI interfaces
  • Idempotent operations: endpoints should be safe to retry
  • Observability: structured logging and metrics for both frontend and backend
  • Performance awareness: cache aggressively with Redis, but invalidate when data changes

Code Construction Rules

  • Frontend Angular: use Material components, router guards, and lazy loading modules
  • Backend FastAPI: keep routers small, use dependency injection, and async handlers
  • Data flow: request DTOs -> domain models -> persistence
  • Validation: Pydantic for requests/responses; strong typing across layers
  • Security: sanitize inputs, verify tokens, and sanitize responses
  • Testing: unit tests for endpoints, integration tests for Redis cache, and UI tests
  • Deployment: Dockerized services, reproducible builds, and immutable images
  • Do not hardcode secrets or credentials in code or config files

Security and Production Rules

  • Always enable HTTPS in all environments
  • Use HTTPS-only cookies for authentication where possible
  • Validate and sanitize all user input to prevent injection attacks
  • Configure proper CORS policies and rate limiting
  • Monitor and rotate keys; never embed secrets in CLAUDE.md templates

Testing Checklist

  • Unit tests for FastAPI endpoints with pytest + httpx
  • Integration tests for Redis cache invalidation and data flow
  • Frontend unit and e2e tests with Angular testing utilities
  • End-to-end tests for the full stack with docker-compose

Common Mistakes to Avoid

  • Using Redis as the primary datastore
  • Ignoring input validation on either side
  • Exposing sensitive data in API responses
  • Skipping migrations or failing to seed data in production

FAQ

What is this CLAUDE.md Template for?
It provides a copyable CLAUDE.md file starter for a full-stack Angular Material frontend, FastAPI backend, and Redis cache.
Which stack does this template cover?
Angular Material for the frontend, FastAPI for the backend, and Redis for caching.
How do I use the CLAUDE.md code block?
Copy the code block starting with # CLAUDE.md into CLAUDE.md in your project and customize as needed.
How can I test the setup?
Run frontend and backend locally with Docker Compose, then run unit and integration tests as described in the template.
Do's and don'ts for Claude Code with this stack
Do: follow file structure, validate data, and implement Redis caching correctly. Don't: store secrets in code or skip authentication.