The Authors platform is a sophisticated real-time collaborative storytelling application where multiple users contribute words to create shared narratives. Built with Firebase for real-time synchronization and featuring time-based rounds, golden opportunities, and user streak tracking.
authors/
├── index.html # Main application file
├── firestore.rules # Production Firestore security rules
├── firestore-dev.rules # Development Firestore security rules
└── authors-docs.md # This documentation
The application operates on precise time slots:
Math.floor(serverTime / SLOT_MS)Special rounds with enhanced word limits:
roundIndex % GOLDEN_EVERY_ROUNDS === 0const firebaseConfig = {
apiKey: "AIzaSyDj2rrUF-sL0rptPcGeBpTV336SHKvabwo",
authDomain: "authors-fd830.firebaseapp.com",
projectId: "authors-fd830",
storageBucket: "authors-fd830.firebasestorage.app",
messagingSenderId: "1020775470059",
appId: "1:1020775470059:web:46cdd53ca979167dfc3fae"
};
rounds/
├── {roundIndex}/
│ ├── round: number
│ ├── words: string[]
│ ├── author: string
│ ├── createdAt: timestamp
│ └── golden: boolean
users/
├── {userUID}/
│ ├── displayName: string
│ ├── lastRound: number
│ ├── streak: number
│ └── hotQuillAwardedAt?: timestamp
meta/
└── timeSync/
└── ts: timestamp
async function syncServerTime() {
const syncDoc = doc(db, 'meta', 'timeSync');
await setDoc(syncDoc, { ts: serverTimestamp() });
const snapshot = await getDoc(syncDoc);
const serverTime = snapshot.data().ts.toMillis();
const networkDelay = (Date.now() - clientTimeBefore) / 2;
serverTimeOffset = serverTime - (clientTimeBefore + networkDelay);
}
Word submissions use Firestore transactions to prevent race conditions:
await runTransaction(db, async (transaction) => {
const roundDoc = doc(db, 'rounds', String(roundIndex));
const roundSnapshot = await transaction.get(roundDoc);
if (roundSnapshot.exists()) {
throw new Error('Slot taken - try next round');
}
transaction.set(roundDoc, {
round: roundIndex,
words: validatedWords,
author: username,
createdAt: serverTimestamp(),
golden: golden
});
});
Advanced fluid typography using CSS custom properties:
:root {
--bp-sm: 640; --bp-md: 768; --bp-lg: 1024; --bp-xl: 1366;
--font-sm: 6; --font-md: 4.5; --font-lg: 3.5; --font-xl: 2.8;
}
@media (min-width: 640px) {
:root {
--font-size-1: calc(
calc(var(--min-f-d) * 1px) +
var(--f-range-d) * ((100vw - calc(var(--breakpoint) * 1px)) / var(--b-range-d))
);
}
}
Consistent with homepage design:
function validateWords(input, maxWords) {
if (!input || !input.trim()) {
throw new Error('Please enter some words');
}
const cleaned = input.trim().replace(/\s+/g, ' ');
const words = cleaned.split(' ').filter(w => w.length > 0);
if (words.length > maxWords) {
throw new Error(`Too many words! Maximum ${maxWords} allowed`);
}
for (const word of words) {
if (word.length > MAX_WORD_LENGTH) {
throw new Error(`Word "${word}" is too long`);
}
}
return words;
}
Automatic daily story reset:
async function checkMidnightReset() {
const now = new Date();
const currentHour = now.getHours();
const currentMinute = now.getMinutes();
if (currentHour === 0 && currentMinute <= 5 && lastResetDate !== today) {
// Clear database and reset state
const roundsQuery = query(collection(db, 'rounds'));
const snapshot = await getDocs(roundsQuery);
const batch = writeBatch(db);
snapshot.docs.forEach((doc) => {
batch.delete(doc.ref);
});
await batch.commit();
}
}
Real-time connection monitoring:
Developer tools accessible via ?dev=1 URL parameter:
Automatic test user creation:
if (window.location.hostname === 'localhost') {
if (!localStorage.getItem('authors_username')) {
localStorage.setItem('authors_username', 'TestUser_' + Math.floor(Math.random() * 1000));
}
}
Production rules enforce data integrity:
// Only authenticated users can write
allow write: if request.auth != null;
// Validate round data structure
allow create: if resource.data.keys().hasAll(['round', 'words', 'author', 'createdAt', 'golden'])
&& resource.data.words is list
&& resource.data.words.size() <= 7;
// Firebase listener error handling
}, (error) => {
console.error('Rounds listener error:', error);
updateConnectionStatus(false);
});
The Authors platform demonstrates exceptional technical sophistication with real-time collaboration, robust data handling, and thoughtful user experience design. Minor improvements in code organization and testing would elevate it to production-enterprise standards.