How obiwan00/question-answer works
Project type and purpose
• This is a full-stack monorepo (Nx) application:
• Frontend: Angular 14 SPA with Angular Material, HTTP APIs + WebSocket chats
• Backend: NestJS 9 REST + WebSocket (Socket.io) server, TypeORM & PostgreSQL
• Shared “api-interfaces” library for DTOs/models
File structure
• Top level:
• apps/client → Angular application
• apps/server → NestJS application
• libs/api-interfaces → shared TypeScript interfaces (Answer, Chat, Message, Tag, Topic, User)
• Client follows Angular’s modular MVC: core/auth/layout/services, feature modules (topic, answer, chat), shared/components
• Server follows NestJS modular MVC: modules (User, Topic, Answer, Tag, Chat), controllers, services, DTOs, entities, WebSocket gateway
• TypeORM config, migrations and seeds under apps/server/src/typeorm
• CI/config: Nx workspace files, tsconfigs, lint and prettier rules
README insights
• “Simplified clone of StackOverflow with chats per topic”
• Communication: REST for CRUD operations, Socket.io for chat messages
• Monorepo managed with Nx—allows generating apps/libs, running affected tests, visualizing dependency graph
a. Main components
• Client (Angular SPA)
• Server (NestJS REST & WebSocket)
• Database (PostgreSQL via TypeORM)
• Shared Interfaces (api-interfaces)
• Nx Dev Tools (build/test orchestrator)
b. Relationships & interactions
• Client ↔ Server (HTTP REST for auth, topics, answers, tags)
• Client ↔ Server (WebSocket/Socket.io for chat messages)
• Server ↔ Database (TypeORM entities ↔ PostgreSQL)
• Client & Server ← shared DTOs via libs/api-interfaces
c. Architectural patterns & design principles
• Frontend: modular feature-based Angular architecture (core vs shared vs feature modules)
• Backend: modular NestJS architecture (per-feature modules, controllers, services, middleware/guards)
• Layered separation: presentation (controllers/components), business logic (services), persistence (TypeORM repositories/entities)
• Single source of truth for API contracts via shared DTO library
• WebSocket gateway pattern for real-time chat
d. Key technologies
• Angular 14, Angular Material, RxJS, Socket.io-client
• NestJS 9, TypeORM, Socket.io-server
• PostgreSQL
• Nx (monorepo toolkit)
Detail level
• High-level modules on both sides (Auth, Topic, Answer, Tag, Chat)
• Middleware/guards (e.g. AuthGuard) intercepting REST calls
• TypeORM layer (entities, migrations) connecting to PostgreSQL
• Socket gateway handling chat namespace