Project Structure
Project Structure
Version 1.0
Estimated duration 18 weeks (part-time) / 9
weeks (full-time)
Team size 3 people
Audience Founding engineering team
Contents
1 Product Overview 3
1.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 The Solution: GlobeLens AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Actors & Permissions Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Project Roadmap 4
2.1 Phase 0 — Foundations & Planning (Weeks 1–2) . . . . . . . . . . . . . . . . . . 4
2.2 Phase 1 — Core Backend & Auth (Weeks 3–6) . . . . . . . . . . . . . . . . . . . 5
2.3 Phase 2 — Article Page & Core Features (Weeks 7–10) . . . . . . . . . . . . . . . 5
2.4 Phase 3 — Advanced Features (Weeks 11–14) . . . . . . . . . . . . . . . . . . . . 6
2.5 Phase 4 — Admin, Polish & Launch (Weeks 15–18) . . . . . . . . . . . . . . . . . 6
4 Technology Stack 8
4.1 Frontend — Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 Frontend — Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.3 Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.4 AI & Intelligence Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.5 Infrastructure & DevOps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.6 Collaboration Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 Data Model 9
5.1 Core design principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.2 Key tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.3 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7 API Design 12
7.1 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
7.2 Endpoint groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1
GlobeLens AI — Build Plan & Technical Specifications v1.0
2
GlobeLens AI — Build Plan & Technical Specifications v1.0
1 Product Overview
• Redundancy fatigue. Readers waste time on identical content spread across outlets.
• Trust uncertainty. There is no quick way to gauge how many credible sources corroborate
a claim.
• Context collapse. Stories appear without their history, making it hard to understand how
a situation evolved.
3
GlobeLens AI — Build Plan & Technical Specifications v1.0
The project is divided into five phases. Each phase has a clear deliverable that the entire team
reviews before the next phase begins.
Phase 0 deliverables
• • OpenAPI specification (all endpoints, request/response schemas)
• • Finalised PostgreSQL schema with migration files
• • Scraping architecture decision (RSS vs. Playwright per source)
• • Wireframes for all screens in Figma (low-fidelity first)
• • Design system tokens (colours, spacing, typography)
• • [Link] monorepo initialised with ESLint, Prettier, TypeScript
• • GitHub repository with branching strategy (main/staging/feature)
• • Docker Compose for local development (API + DB + Redis + Elasticsearch)
• • GitHub Actions CI pipeline (lint + test + build)
• • React Native + Expo project initialised
Critical rule for Phase 0: The OpenAPI spec is Person A’s most important output
and is due by end of Week 1. Persons B and C cannot make final interface or mobile
decisions until they know the exact shape of every API response. Person B works from a
[Link] mock file until the real API is ready.
4
GlobeLens AI — Build Plan & Technical Specifications v1.0
5
GlobeLens AI — Build Plan & Technical Specifications v1.0
MVP milestone. At end of Week 10, pause and show the product to 5–10 real users. Run
structured interviews: can they find a story, read the article, understand where information
comes from, and read the timeline? Their feedback will reprioritise Phase 3.
6
GlobeLens AI — Build Plan & Technical Specifications v1.0
• App Store (iOS) and Google Play Store submission and review
• Production environment hardening: secrets in environment variables, no hardcoded keys
• Backup strategy: daily PostgreSQL snapshots, 30-day retention
• Grafana + Loki dashboards: scraping success rate, AI processing latency, API p95
• Disaster recovery runbook documented
7
GlobeLens AI — Build Plan & Technical Specifications v1.0
Core skills required: React Native + Expo, Expo Router, Firebase FCM, GitHub Actions,
Docker, Railway or AWS, Sentry, Grafana, Loki.
Key responsibility beyond coding: Keeping the staging environment stable and the CI/CD
pipeline green. No broken builds on main for more than two hours.
Daily standup 15-minute async text update on Slack: done / doing / blocked
Weekly review 60 minutes synchronous: merge PRs, update Kanban, review API changes
PR review Every PR requires one review before merge. Rotate reviewers weekly.
Branching main (production) ← staging ← feature/xxx
Deployment Staging: automatic on merge to staging. Production: manual trigger only.
ADRs Every significant architectural decision gets a one-page Architecture Decision
Record in Notion.
4 Technology Stack
Technology Rationale
[Link] 15 (App Router) SSR for SEO-critical news content; file-based routing; BFF API
routes
TypeScript Mandatory for a 3-person team. Catches API contract mismatches
at compile time.
Tailwind CSS Consistent utility-first styling; no CSS conflicts across teammates
React Query Server state management, background refetch, stale-while-
revalidate for live news
Zustand Lightweight client state (auth session, UI preferences, topic selec-
tions)
Mapbox GL JS Interactive country map with cluster markers for Dual-View feature
8
GlobeLens AI — Build Plan & Technical Specifications v1.0
Technology Rationale
React Native + Expo Cross-platform iOS/Android; shares business logic with web
Expo Router File-based routing mirrors [Link] — same mental model for the whole
team
Firebase FCM Push notifications for topic alerts; works on both iOS and Android
react-native-maps Map view on mobile (wraps Apple Maps / Google Maps natively)
Technology Rationale
[Link] + Fastify High-throughput REST API; faster than Express; excellent TypeScript
support
PostgreSQL Primary relational database; JSONB support for storing synthesis output
Redis API response caching, rate limiting, session store, BullMQ broker
BullMQ Job queue for scraping, AI processing, and notification dispatch
Elasticsearch Full-text search with geo, date, and topic filters
Playwright Headless browser scraping for dynamic news pages (CNN, Al Jazeera)
RSS parser Lightweight ingestion for sources that publish RSS feeds
Technology Rationale
Anthropic Claude API (Sonnet) Article synthesis, bias detection, fact-checking, comment
moderation
Structured outputs (JSON mode) Forces Claude to return machine-parseable JSONB with
paragraph/source maps
Prompt versioning in PostgreSQL All prompts stored with a version number, enabling A/B
quality testing
BullMQ AI processing queue Prevents synchronous Claude calls on user requests; all
processing is async
Redis caching for synthesis Synthesised articles cached with TTL; Claude is not
called on every page load
9
GlobeLens AI — Build Plan & Technical Specifications v1.0
Technology Rationale
Tool Use
raw_articles id (UUID PK), source_id (FK), url (unique), url_hash (for deduplication),
title, body_text, published_at, scraped_at, processing_status (enum:
pending/clustered/synthesised/failed).
topics id (UUID PK), name, slug (unique), lat (decimal), lng (decimal), country_code
(ISO 3166-1 alpha-2).
articles id (UUID PK), topic_id (FK), headline, summary (1-sentence), body_jsonb
(JSONB: array of {text, source_ids[]}), reliability_score (numeric 0–
5), bias_data (JSONB), is_promoted (boolean), created_at, updated_at.
article_sources
Join table: article_id + raw_article_id.
sources id (UUID PK), name (e.g. “BBC”), base_url, rss_url, credibility_weight
(numeric 0–1, hand-tuned), scraping_method (enum: rss/playwright).
timelines topic_id (FK), raw_article_id (FK), position (integer), published_at.
Unique constraint on (topic_id, raw_article_id).
comments id (UUID PK), article_id (FK), user_id (FK), body (text), is_blocked
10
GlobeLens AI — Build Plan & Technical Specifications v1.0
• All primary keys are UUIDs (version 4), never auto-incrementing integers.
This is the most technically complex and most business-critical part of GlobeLens. It must be
built and proven working before the frontend is wired to real data.
2. Clustering: Group pending raw articles by topic using a two-step approach: (a) extract
named entities and keywords using Claude or a lightweight NLP library; (b) group articles
that share ≥2 named entities and were published within a 48-hour window into the same topic
cluster. Create or update a topics record and update raw_articles.processing_status
to clustered.
3. AI Synthesis: For each updated cluster, send all clustered article bodies to Claude with
the active synthesis prompt. Claude returns structured JSON:
• headline: string
4. Timeline update: Insert all raw articles for this topic into the timelines table, ordered
by published_at. This gives users the full chronological history of a story.
11
GlobeLens AI — Build Plan & Technical Specifications v1.0
5. Indexing: Write the synthesised article to Elasticsearch. Fields indexed: headline, summary,
topic name, country code, geo-coordinates, published date. Invalidate the Redis cache key
for any cached response containing this topic.
6. Notification dispatch: Query users who follow this topic. Enqueue one notification job
per user. Notification worker calls Firebase Cloud Messaging. Record sent notifications in
the notifications table.
where wi is the credibility_weight of source i (hand-tuned value between 0 and 1), and the
sum is capped at 5. Example weights: BBC = 0.9, Reuters = 0.95, tabloid = 0.25. This formula
is explainable to users and can be recalibrated without any database migration.
Important: Prioritise RSS feeds — they are explicitly published for consumption and
carry no scraping risk. For HTML scraping, check each site’s [Link] before adding it
as a source. Respect Crawl-delay directives. Consider reaching out to 2–3 major outlets
for formal data partnerships; this also provides a credibility story for the product.
7 API Design
7.1 Conventions
• All endpoints are prefixed /api/v1/.
• HTTP status codes are used semantically (200, 201, 400, 401, 403, 404, 422, 429, 500).
These eight diagrams must be completed in Phase 0 and reviewed by all three team members
before any code is written. They are the team’s shared contract.
1. System architecture diagram (Excalidraw or [Link]). Shows all services: web app,
mobile app, API server, scraper workers, AI processor, PostgreSQL, Redis, Elasticsearch,
Firebase, Sentry, Grafana. Include directional data-flow arrows.
2. Database ERD ([Link]). All tables, all columns with types, all foreign key rela-
tionships, all unique constraints. This is the most reviewed document of the project. A bad
12
GlobeLens AI — Build Plan & Technical Specifications v1.0
3. User flow — General Person (Figma or Whimsical). Shows both guest and authenticated
paths. Entry → optional onboarding → home feed → article → branches: comment / fact-
check / map / follow topic / timeline.
6. OpenAPI specification (Stoplight or YAML file in the repository). Every endpoint with
request body schema, response schema, auth requirements, and at least one example per
endpoint. This is Person A’s deliverable, due by end of Week 1.
7. React component tree (Figma component panel or a diagram). Defines the component hi-
erarchy: Layout → Page → Section → Card → Atom. Determines what lives in /components
(shared) versus /app/[page] (page-specific).
8. Wireframes for all screens (Figma). Low-fidelity first to validate flow, then high-fidelity
for hand-off. Screens: Home (Standard), Home (Map), Article, Search, Fact-checker, Topic
onboarding, Profile, Notifications, Admin dashboard (all sub-screens).
Person B: Produce low-fidelity wireframes for all screens by end of Week 1. Design
decisions made now cost nothing. The same decisions made during Week 10 cost days of
refactoring.
Person C: Set up the GitHub repository with the agreed branching strategy, ESLint,
Prettier, TypeScript strict mode, and a working Docker Compose that boots all services
locally. Every person must be able to run the full stack on their machine by end of Week 1.
• The body_jsonb structure in articles — this is the most novel part of the schema and must
be agreed upon before synthesis is coded.
• The timelines table design — confirm the ordering and pagination approach.
• The prompt_versions table — confirm how active prompts are selected at runtime.
Write the first Alembic (Python) or Knex ([Link]) migration file together as a group exercise.
13
GlobeLens AI — Build Plan & Technical Specifications v1.0
• Use a job queue from day one. Never call the scraper or Claude API synchronously inside
an HTTP request handler. Every slow operation goes through BullMQ.
• Cache synthesised articles in Redis. A synthesised article rarely changes. Cache it with
a TTL of 5–15 minutes. Invalidate on update. Claude is never called at request time.
• Paginate all list endpoints. No endpoint returns an unbounded collection. Default limit:
20. Maximum limit: 100.
• Store raw and synthesised content separately. Raw articles must never be deleted or
overwritten. You will want to re-run the AI pipeline with improved prompts against historical
data. This is only possible if the originals are untouched.
• Design the reliability score as a formula, not a stored procedure. The weights can
be updated in the sources table without any code deployment. The score is recalculated on
the next synthesis run.
• Use environment variables for all secrets. No API keys, database credentials, or Claude
API keys ever appear in source code or are committed to the repository. Use a .[Link]
file with placeholder values.
2. Claude API cost runaway. A synthesis call on a 10-article cluster can cost non-trivial
amounts at scale. Set hard budget alerts in the Anthropic console from day 1. Cache
aggressively. Consider using a cheaper model (Haiku) for the first-pass clustering step and
Sonnet only for final synthesis.
3. Mobile being an afterthought. Every feature built in Phase 1 must be mirrored in React
Native during that same phase. Teams that defer mobile to the end always underestimate
the work and ship a degraded mobile experience or miss their deadline.
14
GlobeLens AI — Build Plan & Technical Specifications v1.0
3. Feature specifications: one page per feature, each containing: description, user story,
acceptance criteria, out-of-scope notes, and open questions.
5. Data dictionary: every table and every column with type, constraints, and plain-English
description.
6. Non-functional requirements:
7. Architecture Decision Records (ADRs): one page per major decision. Format: Context
→ Decision → Rationale → Consequences.
8. Glossary: define all domain terms (raw article, synthesised article, topic cluster, reliability
score, etc.) so all three team members use the same vocabulary.
Use this checklist at the start of the project to confirm every person’s local environment is
correctly configured.
□ Anthropic API key added to .env and a test synthesis call returns successfully
15
GlobeLens AI — Build Plan & Technical Specifications v1.0
□ Each person has been added to: GitHub org, Linear workspace, Figma team, Notion workspace
16
GlobeLens AI — Build Plan & Technical Specifications v1.0
Authentication
POST /auth/register Create a new user account
POST /auth/login Return access + refresh to-
ken pair
POST /auth/refresh Exchange refresh token for
new access token
POST /auth/logout Invalidate refresh token
Articles
GET /articles Paginated feed (supports
geo, topic, date filters)
GET /articles/:id Single synthesised article
with body JSONB
GET /articles/:id/timeline Ordered list of raw articles
for the topic
GET /articles/:id/sources Source attribution data for
the article
Search
GET /search Full-text search
(?q=&from=&to=&country=&topic=)
Comments
GET /articles/:id/comments All comments for an article
(paginated)
POST /articles/:id/comments Post a comment (auth re-
quired)
DELETE /comments/:id Delete own comment or ad-
min delete
Fact-checker
POST /factcheck Submit a URL; returns cred-
ibility assessment (auth re-
quired)
Admin
GET /admin/stats Platform statistics
GET / PATCH / DELETE /admin/users/:id User management
PATCH /admin/comments/:id Block or unblock a comment
17
POST / DELETE /admin/sources Add or remove a scraping
source
PATCH /admin/articles/:id/promote Promote or demote an arti-