omnivore/docs/architecture/c4-context.md
Timothy Atapagra c53bb77721 feat(api-nest): Complete NestJS authentication system with web integration
## Major Accomplishments

###  Authentication System (ARC-003) - COMPLETED
- **Full NestJS Auth Module**: Complete authentication system with JWT, OAuth, and RBAC
- **Type-Safe API Responses**: Comprehensive DTO system with Swagger documentation
- **Web Integration**: Successfully integrated web frontend with NestJS API endpoints
- **Security Hardening**: Fixed authentication vulnerabilities and implemented proper patterns

###  Database Integration (ARC-003B) - COMPLETED
- **Entity Mapping**: Complete TypeORM entities for User, Profile, Personalization, Roles
- **Migration System**: Hybrid approach using existing Postgrator system
- **Schema Compatibility**: Both Express and NestJS APIs access same database

###  Development Environment Optimization
- **Performance Boost**: 25-50x faster cold starts (30-60s → 1.2s)
- **Turbopack Integration**: Next.js 13.5+ experimental bundler enabled
- **Sentry Disabled**: Clean development logs and faster builds
- **Docker Optimization**: Streamlined development workflow

## Technical Details

### Authentication Features Implemented
- JWT token generation and validation
- Email/password login and registration
- OAuth structure (Google, Apple) - ready for testing
- Role-based access control (RBAC)
- Comprehensive error handling with typed responses
- CORS configuration for web frontend

### Web Frontend Integration
- Updated API endpoints to /api/v2 prefix
- Fixed authentication flow with proper JSON responses
- Eliminated backend redirects (anti-pattern)
- Client-side navigation based on API responses
- CORS and CSP optimizations

### Performance Improvements
- Turbopack bundler: 20-40x faster cold starts
- SWC minification: Rust-based compilation
- Filesystem caching: Persistent across restarts
- Smart code splitting: Vendor, Radix UI, Phosphor icons
- Import optimization: Tree-shaking for icon libraries

## Testing Status
-  Email/password login: Working
-  User registration: Working
-  Google OAuth: Ready for testing
-  Apple OAuth: Ready for testing
-  Email verification: Pending email service integration

## Next Phase Recommendations
1. **Vite Migration**: Consider migrating from Next.js to Vite for 50-100x performance gains
2. **GraphQL Setup**: Begin ARC-004 for GraphQL module implementation
3. **OAuth Testing**: Complete Google/Apple authentication testing
4. **Email Service**: Integrate email verification system

## Files Changed
- Complete NestJS authentication system (100+ files)
- Web frontend integration and optimization
- Docker development environment
- Performance optimizations and Sentry configuration
- Comprehensive documentation and migration tracking

This commit represents a major milestone in the Express-to-NestJS migration,
establishing a solid foundation for continued development.
2025-10-09 13:10:32 -04:00

2.8 KiB

C4 Level 1: System Context

The Omnivore platform helps readers capture, organize, and consume content across web, mobile, and email entry points. It integrates background processing and third-party services to enrich content and deliver personalized experiences.

graph TB
  subgraph OmnivorePlatform[Omnivore Platform]
    API[(Node.js GraphQL + REST API)]
    Workers[Background Workers & BullMQ Queues]
    WebApp[Next.js Web Client]
    MobileClients[iOS & Android Apps]
    BrowserExtension[Browser Extension]
    DB[(PostgreSQL)]
    Cache[(Redis)]
  end

  WebUser["Reader (Web)"] --> WebApp
  MobileUser["Reader (Mobile)"] --> MobileClients
  BrowserClipper["Browser Clipper User"] --> BrowserExtension
  EmailContributor["Email/Newsletter Sender"] --> API
  AutomationUser["Integrations / Automations"] --> API
  SupportTeam["Support & Ops"] --> API

  WebApp --> API
  MobileClients --> API
  BrowserExtension --> API
  API --> DB
  API --> Cache
  Workers --> DB
  Workers --> Cache
  API -->|Queues tasks| Workers
  ExternalContent["External Content Sources (Web, RSS, YouTube, PDF, Email)"] --> Workers
  ThirdPartyServices["3rd-party Services (Auth providers, Email, Analytics, Storage)"] --> API

Observations

  • The single API process fronts both GraphQL (Apollo) and numerous REST endpoints, acting as the integration hub for all clients.
  • Background work (content parsing, enrichment, notifications) relies on BullMQ workers backed by Redis and Puppeteer-powered scraping.
  • PostgreSQL is the system of record; Redis is used for queues and transient state.
  • Multiple ingestion channels (browser extension, email, integrations) all fan into the same API/queue pipeline.

Built vs. Missing

Area Current State Gaps / Risks
Core API Express + Apollo server with modular routers and services Lacks enforced domain boundaries, limited typing, manual lifecycle management
Background Processing ContentWorker orchestrates parsing with Puppeteer, queue handlers in queue-processor Error handling dispersed, scaling knobs manual, no central scheduler
Clients Next.js web app, native mobile apps, browser extension present Feature parity varies; API changes must avoid breaking older clients
Observability Prometheus middleware, Winston logging, Sentry hooks (mostly disabled) Sentry disabled, metrics limited to HTTP layer, tracing partial
Documentation Scattered markdown, implicit architecture knowledge No consolidated C4 views or migration guardrails (addressed by this doc set)
Deployment Dockerfiles per service, docker-compose for dev, App Engine references Need unified self-hosting story and production-ready container orchestration guidance

This context view orients contributors before diving into container- and component-level discussions.