Instruction file imported from agency-ai-solutions/nextjs-firebase-ai-coding-template (
.cursor/rules/ADR.mdc). Copyright stays with the author.
Architecture Decision Log
Index
| ID | Title | Date | Status | Supersedes | Superseded by |
|---|---|---|---|---|---|
| 0004 | Event-Driven Broker Architecture with Firestore | 2025-01-27 | Accepted | — | — |
| 0002 | Monorepo Structure with Frontend and Backend | 2025-01-27 | Accepted | — | — |
| 0001 | Full-Stack Firebase Template Architecture | 2025-01-27 | Accepted | — | — |
New ADR Entry Template (copy for each new decision)
Replace placeholders, keep section headers. Keep prose concise.
## ADR-XXXX — \<Short, specific title>
<a id="adr-XXXX"></a>
**Date**: YYYY-MM-DD
**Status**: Proposed | Accepted | Superseded
**Owner**: <Name>
### Context
<1–3 sentences: what changed or what forces drive this decision now>
### Alternatives
<Quick bullet list of alternatives considered, and why they were rejected.>
### Decision
\<Single clear decision in active voice; make it testable/verifiable>
### Consequences
* **Pros**: \<benefit 1>, \<benefit 2>
* **Cons / risks**: \<cost 1>, \<risk 1>
* **Supersedes**: ADR-NNNN (if any)
* **Superseded by**: ADR-MMMM (filled later if replaced)
### (Optional) Compliance / Verification
\<How we’ll check this is honored: tests, checks, fitness functions, runbooks>
ADR-0001 — Full-Stack Firebase Template Architecture
Date: 2025-01-27 `
Status: Accepted
Owner: AI Agent
Context
Modern web applications require both frontend and backend components with real-time data synchronization. Firebase provides a comprehensive platform for building full-stack applications, but setting up the architecture with best practices requires significant boilerplate code.
Alternatives
- Separate repositories: Frontend and backend in different repos, harder to coordinate changes
- Backend-only template: Covers only server-side concerns, developers must handle frontend integration
- Frontend-only template: Limited to client-side Firebase SDK, missing serverless functions capabilities
- Full-stack monorepo template: Single template with both Next.js frontend and Python Firebase Functions
Decision
Create a comprehensive full-stack Firebase template with:
- Next.js 14 frontend with TypeScript and Material-UI
- Python Firebase Functions backend with broker architecture pattern
- Shared Firebase project configuration
- Integrated testing strategy for both frontend and backend
- Single repository with clear separation of concerns
Consequences
- Pros: Complete starting point for Firebase projects, coordinated development, shared configuration
- Cons / risks: More complex initial setup, larger template size, requires knowledge of both frontend and backend
- Supersedes: —
- Superseded by: —
Compliance / Verification
Template includes working examples for both frontend and backend. Firebase configuration shared between components. Documentation covers full development workflow.
ADR-0002 — Monorepo Structure with Frontend and Backend
Date: 2025-01-27
Status: Accepted
Owner: AI Agent
Context
Full-stack Firebase applications need coordinated development between frontend (Next.js) and backend (Firebase Functions). The question was how to organize the code structure to support both independent development and shared configuration.
Alternatives
- Separate repositories: Independent versioning but coordination overhead and duplicate configuration
- Nested backend in frontend: Simple structure but mixes concerns and complicates deployment
- Side-by-side monorepo: Clear separation with shared root configuration
Decision
Implement side-by-side monorepo structure:
/front/- Next.js frontend application with its own package.json and dependencies/back/- Python Firebase Functions backend with its own requirements.txt and structure- Root-level Firebase configuration (
firebase.json,firestore.rules,storage.rules) - Shared documentation in root README.md with component-specific READMEs
Consequences
- Pros: Clear separation of concerns, independent tooling, shared Firebase configuration, coordinated documentation
- Cons / risks: Slightly more complex initial setup, need to manage two different development environments
- Supersedes: —
- Superseded by: —
Compliance / Verification
Directory structure clearly separates frontend and backend. Firebase CLI recognizes backend functions source in configuration. Both components can be developed independently.
ADR-0004 — Event-Driven Broker Architecture with Firestore
Date: 2025-01-27
Status: Accepted
Owner: AI Agent
Context
Modern full-stack applications require consistent data state between frontend and backend components. Traditional request-response patterns create tight coupling and require complex state synchronization logic. Real-time applications need immediate UI updates when data changes, regardless of the source of the change.
Alternatives
- Direct API communication: Backend returns data directly to frontend, requires manual state management
- Event streaming with external broker: Use services like Redis Pub/Sub or RabbitMQ, adds infrastructure complexity
- WebSocket connections: Real-time but requires connection management and doesn't persist data
- Firestore as event-driven broker: Leverages built-in real-time capabilities and acts as single source of truth
Decision
Implement event-driven broker architecture where Firestore serves as both the data store and event broker:
- All data mutations flow through Firestore exclusively
- Backend functions save data to Firestore without returning responses to frontend
- Frontend subscribes to Firestore collections/documents using hooks for real-time updates
- Firestore acts as the single source of truth for both backend and frontend
- UI updates automatically through Firestore real-time listeners
Consequences
- Pros: Eliminates data synchronization issues, automatic real-time updates, reduced coupling between frontend and backend, simplified state management, leverages Firebase's built-in capabilities
- Cons / risks: Increased Firestore read operations, requires proper security rules design, potential data consistency challenges with complex operations, network dependency for all data access
- Supersedes: —
- Superseded by: —
Compliance / Verification
Backend functions must only perform Firestore writes without returning data responses. Frontend components must use Firestore hooks (useFirestore, real-time listeners) for all data access. No direct API data responses to frontend. All data mutations trigger UI updates through Firestore change events.