How him7797/ainews works
1. Overall shape
- This repository is a two-part product: an Expo mobile client at the root src/ tree and a separate TypeScript server under server/.
- The product intent is an RSS/news aggregation app with onboarding and authenticated feed access, supported by a backend that fetches, parses, sanitizes, caches, and serves content.
2. Mobile client boundary
- The root app is an Expo Router application using file-based navigation in src/app/.
- The main screens are:
- auth/sign-in for authentication
- onboarding/ for first-run setup
- index.tsx for the primary landing/home experience
- _layout.tsx defines the navigation shell that wraps these routes.
3. Client-side domain modules
- src/services/authService.ts and src/services/feedService.ts are the main client-to-server integration points.
- src/lib/storage.ts handles local persistence, likely for tokens, onboarding state, or user preferences.
- src/lib/notifications.ts indicates the client also owns local notification behavior.
- UI composition is split into reusable components such as OnboardingCarousel and TopicPill, which suggests onboarding is interactive and preference-driven.
4. Client data flow
- The client likely follows this sequence: sign-in → persist session locally → onboarding topic selection → fetch personalized feed data.
- Local storage and notification helpers sit on the edge of that flow, keeping state on-device while the feed service talks to the backend.
5. Server boundary and entrypoint
- server/src/index.ts is the runtime entrypoint for the backend API.
- server/src/router.ts centralizes request routing, while server/src/middleware/requireAuth.ts enforces protected endpoints.
- server/src/config.ts is the configuration boundary, and server/src/db.ts is the database access layer.
6. Feed ingestion and processing pipeline
- The backend separates feed handling into distinct stages:
- fetcher.ts retrieves remote content
- parser.ts converts raw feed content into structured data
- sanitizer.ts removes unsafe or unwanted content
- aggregator.ts combines or deduplicates items into API-ready results
- cache.ts stores frequently used results for faster responses
- This is the core server-side data flow and is the most important pipeline to capture in an architecture diagram.
7. Authentication and persistence
- The server has its own auth layer in server/src/auth.ts, backed by the database.
- Migrations in server/migrations/001_create_users.sql show a relational schema with at least a users table.
- The presence of requireAuth indicates authenticated API routes are a first-class boundary, not an afterthought.
8. Database and operational scripts
- server/scripts/migrate.ts and the SQL migrations imply schema evolution is managed separately from runtime request handling.
- The backend therefore has a clear split between application code and database lifecycle management.
9. Testing layers
- The server has both unit tests and integration tests under server/tests/, with API coverage in integration/api.test.ts.
- The client has at least one unit test under tests/unit/test_storage.ts.
- Server testing uses Vitest, while the root project also includes Jest and ESLint config, showing multiple quality gates across app and server boundaries.
10. Build, CI, and repository workflow
- GitHub Actions in .github/workflows/ci.yml and Husky pre-push hooks enforce validation before merge.
- The .specify/ and specs/ directories are not runtime subsystems; they are the project’s specification and task-planning layer, documenting features like onboarding, CI checks, and RSS aggregation.
- This means the repo has a strong separation between product behavior definitions and implementation/runtime code.
11. What to draw in a diagram
- The cleanest architecture diagram would show:
- the Expo mobile app on the left
- the TypeScript API server in the middle
- remote RSS/content sources on the right feeding the server
- a database and cache behind the server
- local client storage/notifications as device-side concerns
- The key runtime flows are authentication, onboarding/preferences, and feed retrieval/aggregation.
Main entry points: router.ts Router · fetcher.ts Fetcher · _layout.tsx App shell · index.tsx Onboarding
Components 30
Expo app
Mobile client and on-device behavior
- App shell · Navigation shell and route composition
src/app/_layout.tsx - Sign in · Authentication screen
src/app/auth/sign-in.tsx - Onboarding · First-run setup flow
src/app/onboarding/index.tsx - Topics · Topic selection step
src/app/onboarding/topics.tsx - Home · Primary feed landing screen
src/app/index.tsx - Auth service · Client authentication and session handling
src/services/authService.ts - Feed service · Client feed retrieval from backend
src/services/feedService.ts - Storage · On-device persistence for session and preferences
src/lib/storage.ts - Notifications · Local notification behavior on device
src/lib/notifications.ts - Carousel · Interactive onboarding UI
src/components/OnboardingCarousel.tsx - Topic pill · Topic selection control
src/components/TopicPill.tsx - Device · Mobile runtime boundary
API server
TypeScript backend and data pipeline
- API entry · Backend process entrypoint
server/src/index.ts - Router · Central request routing
server/src/router.ts - Auth guard · Protected route enforcement
server/src/middleware/requireAuth.ts - Auth · Backend authentication logic
server/src/auth.ts - Config · Runtime configuration boundary
server/src/config.ts - Database · Relational data store
server/src/db.ts - Fetcher · Retrieves remote feed content
server/src/fetcher.ts - Parser · Converts raw feeds into structured items
server/src/parser.ts - Sanitizer · Removes unsafe or unwanted content
server/src/sanitizer.ts - Aggregator · Combines and deduplicates feed items
server/src/aggregator.ts - Cache · Stores frequently used results
server/src/cache.ts - URL helper · Server-side URL handling helper
server/src/lib/url.ts - API server · Backend request/response boundary
Specs
Specification and planning artifacts
- Onboarding spec · Feature specification and tasks
specs/001-onboarding-flow/spec.md - RSS spec · RSS/news aggregator specification
specs/003-rss-news-aggregator/spec.md
Automation
CI and repository workflow
- CI workflow · GitHub Actions validation pipeline
.github/workflows/ci.yml - Pre-push · Local validation hook before push
.husky/pre-push
Other components
- RSS sources · Remote RSS and content providers
Connections 32
- App shell → Sign in: routes · Navigation shell exposes sign-in route
- App shell → Onboarding: routes · Navigation shell exposes onboarding flow
- App shell → Home: routes · Navigation shell exposes home screen
- Onboarding → Carousel: uses · Onboarding screen composes carousel UI
- Topics → Topic pill: uses · Topic selection uses pill component
- Sign in → Auth service: calls · Sign-in screen authenticates through client service
- Home → Feed service: calls · Home screen loads feed data through service
- Auth service → API server: requests · Client auth requests go to backend
- Feed service → API server: requests · Client feed requests go to backend
- Auth service → Storage: persists · Session data is stored on device
- Onboarding → Storage: persists · Onboarding state and preferences are stored locally
- Home → Notifications: triggers · Feed experience can drive local notifications
- API entry → Router: loads · Runtime starts request router
- Router → Auth guard: guards · Protected endpoints use auth middleware
- Router → Auth: delegates · Authentication routes delegate to auth layer
- Auth → Database: reads/writes · Auth state is backed by the database
- Auth guard → Database: verifies · Auth checks consult persisted user data
- Router → Fetcher: orchestrates · Feed endpoints trigger ingestion pipeline
- Fetcher → RSS sources: retrieves · Fetcher pulls remote RSS/content
- Fetcher → Parser: passes · Raw content is parsed into structured items
- Parser → Sanitizer: passes · Parsed items are cleaned before exposure
- Sanitizer → Aggregator: feeds · Sanitized items are combined and deduplicated
- Aggregator → Cache: stores · Aggregated results are cached
- Aggregator → Database: reads/writes · Aggregated data can be persisted or hydrated
- Fetcher → URL helper: uses · Fetcher relies on URL helper for remote requests
- Device → Storage: contains · Local persistence lives on the device
- Device → Notifications: contains · Notifications are device-side behavior
- Onboarding spec → Onboarding: describes · Specification documents onboarding behavior
- RSS spec → Feed service: describes · Specification documents feed retrieval behavior
- CI workflow → API entry: validates · CI covers backend build and tests
- CI workflow → App shell: validates · CI covers client build and tests
- Pre-push → CI workflow: mirrors · Local hook mirrors repository validation