This document serves as a comprehensive guide for AI Agents and developers working on the Google Cloud Creative Studio Platform project. It outlines the architecture, setup, development workflow, and strict guidelines to ensure code quality and consistency.
Creative Studio follows a Modular, Feature-Driven Architecture (inspired by Hexagonal Architecture).
- Structure: Code is organized by feature domain (e.g.,
/images,/users) rather than technical layer. - Cohesion: All code for a single feature is co-located (controllers, services, DTOs).
- Coupling: Modules interact through well-defined interfaces.
The standard development environment uses Docker Compose.
- gcloud CLI: Authenticated and project set.
- Docker & Docker Compose
- uv: Fast Python package installer.
- Backend (
backend/.env):- Set
ENVIRONMENT="local" - Set
USE_CLOUD_SQL_AUTH_PROXY=false(uses local Postgres container). - Set
isLocal = True(critical for local auth).
- Set
- Frontend (
frontend/src/environments/environment.development.ts):- Set
isLocal: true - Configure Firebase credentials.
- Set
From the root directory:
# Authenticate gcloud
gcloud auth application-default login
# Start containers
docker compose up --buildIf the database is fresh, run the bootstrap script to seed templates:
docker exec -t creative-studio-backend sh -c "PYTHONPATH=/app uv run python -m bootstrap.bootstrap"- Hot Reload: Enabled by default in Docker.
- Package Management: Uses
uvandpyproject.toml. - Running Scripts: ALWAYS use
docker composeto run Python scripts (e.g.,docker exec ...).
- Reactivity: Strictly use Angular Signals for state management and computed values.
- API Calls: Implement API calls in a Service. DO NOT use
fetchorHttpClientdirectly inside components.
We use a fully containerized pre-commit pipeline. DO NOT run linters locally on your host machine.
Run once from the root:
cp pre-commit-hook.sh .git/hooks/pre-commit && chmod +x .git/hooks/pre-commitTo format and lint the entire repository at once:
docker compose run --rm pre-commit run --all-files- Backend:
black(formatting),pylint(linting). - Frontend:
gts(ESLint + Prettier). - License:
addlicense(adds headers).
We use pytest and pytest-cov.
Important
PR Requirement: You must achieve at least 80% code coverage across all src/ files.
Verify Coverage Locally:
cd backend
uv run pytest tests -v --cov=src --cov-fail-under=80Run Specific Tests:
uv run pytest tests/users -vTo maintain a pristine codebase, AI Agents MUST follow these rules:
- Docker Enforcement: Always use
docker composeordocker execto run Python scripts or commands that interact with the app environment. Always check if the docker containers are running correctly and in case of finding any errors solve them until the container starts successfully. - Precise Edits: When editing files, ensure you replace only the target content. DO NOT append garbage lines or duplicate code.
- Reactivity First: In Angular, leverage Signals for computed state to avoid reactivity bugs.
- Error Handling: Always wrap async/stream operations in
try/catchand log errors appropriately. - Format Before Commit: Always ensure the code is formatted by using the prechecks leveraging automation for code quality before finishing execution.
- Commiting Changes: Never commit changes, just leave the changes in the files for the user to review and commit.
- Testing: Always run the tests and verify the coverage is above 80% before finishing execution, if it fails or coverage is below 80%, fix it, add the missing tests and run the tests again until it passes and coverage is above 80%.
- Linting: Always run the linter and verify the code is clean before finishing execution, if it fails, fix it and run the pre-commit hook again.
- Documentation: Always update the documentation when making changes to the code, even this file if needed.
- Seniority: Act as a Senior Software Engineer with 10+ years of experience in software development.
- Code Review: Always review the code before finishing execution, if it fails, fix it and run the pre-commit hook again.
- Security: Always review the code for security vulnerabilities and fix them if found.
- Isolation: Always work in isolation, do not modify files outside the scope of the task. Work with docker containers, do not run any gcloud commands locally nor modify any cloud resources.