Technology Stack
2KRIKA is built with modern, production-ready technologies chosen for reliability, performance, and developer experience.
Core Technologies
Runtime & Language
| Technology | Version | Purpose |
|---|---|---|
| Node.js | v22 | JavaScript runtime |
| TypeScript | ^5.8.3 | Type-safe JavaScript |
| pnpm | 10.7.1 | Fast, efficient package manager |
Why TypeScript? - Type safety catches bugs at compile time - Better IDE support and autocomplete - Self-documenting code - Easier refactoring
Framework
| Technology | Version | Purpose |
|---|---|---|
| NestJS | ^11.0.20 | Progressive Node.js framework |
| Express | (via NestJS) | HTTP server |
Why NestJS? - Built-in dependency injection - Modular architecture - TypeScript-first - Excellent documentation - Large ecosystem
Databases
SQL Database
| Technology | Version | Purpose |
|---|---|---|
| PostgreSQL | 8+ | Primary relational database |
| Sequelize | ^6.37.7 | SQL ORM |
| sequelize-cli | ^6.6.2 | Migration management |
| pg | ^8.15.6 | PostgreSQL client |
Data Stored: - Users and authentication - Services and categories - Orders and payments - Accounts and transactions - Configurations
Development Alternative: SQLite (sqlite3 ^5.1.7) for quick local setup
NoSQL Database
| Technology | Version | Purpose |
|---|---|---|
| MongoDB | ^8.17.0 | Document database |
| Mongoose | ^8.17.0 | MongoDB ODM |
Data Stored: - Chat messages - Real-time communication data
Why MongoDB for Chat? - Flexible schema for different message types - High write throughput - Natural fit for real-time data
Caching
| Technology | Version | Purpose |
|---|---|---|
| Redis | 5+ | In-memory cache |
| @redis/client | ^5.0.1 | Redis Node.js client |
Use Cases: - Session storage - Rate limiting - Notification count caching - Temporary data storage
Validation & Schema
| Technology | Version | Purpose |
|---|---|---|
| Zod | ^3.24.3 | Schema validation |
Why Zod? - TypeScript-first - Composable schemas - Excellent error messages - Zero dependencies
Example:
Real-Time Communication
| Technology | Version | Purpose |
|---|---|---|
| Socket.io | ^4.8.1 | WebSocket library |
| @nestjs/websockets | ^11.1.4 | NestJS WebSocket support |
Features: - Real-time chat - Order status updates - Notifications
State Management
| Technology | Version | Purpose |
|---|---|---|
| XState | ^5.20.1 | State machine library |
Why XState? - Explicit state transitions - Prevents invalid states - Visualizable workflows - Predictable behavior
Used For: - Order workflow management - Complex business processes
Authentication & Security
| Technology | Version | Purpose |
|---|---|---|
| jsonwebtoken | ^9.0.2 | JWT implementation |
| bcryptjs | ^3.0.2 | Password hashing |
Security Features: - JWT-based authentication - Bcrypt password hashing - Role-based access control (RBAC) - Permission system
File Handling
| Technology | Version | Purpose |
|---|---|---|
| Multer | (via NestJS) | File upload middleware |
Storage: - Local filesystem - Easily extendable to S3/Cloud Storage
| Technology | Version | Purpose |
|---|---|---|
| Nodemailer | ^7.0.3 | Email sending |
Features: - Welcome emails - Order notifications - Account verification - Password reset
Payment Processing
| Technology | Version | Purpose |
|---|---|---|
| Axios | ^1.12.2 | HTTP client |
Gateway: Paystack (easily extendable to other providers)
Features: - Payment initialization - Webhook handling - Payment verification - Refunds
API Documentation
| Technology | Version | Purpose |
|---|---|---|
| Swagger | 11.1.6 | API documentation |
| @nestjs/swagger | 11.1.6 | NestJS Swagger integration |
Access: /docs/swagger-ui
Features: - Interactive API testing - Auto-generated from code - Request/response schemas
Testing
| Technology | Version | Purpose |
|---|---|---|
| Jest | ^29.7.0 | Test framework |
| ts-jest | ^29.3.2 | TypeScript Jest transformer |
| @faker-js/faker | ^9.8.0 | Test data generation |
Test Types: - Unit tests - Integration tests - Repository tests - Use case tests
Code Quality
| Technology | Version | Purpose |
|---|---|---|
| ESLint | ^9.27.0 | Linting |
| Prettier | ^3.5.3 | Code formatting |
| TypeScript ESLint | ^8.32.1 | TypeScript linting |
Utilities
| Technology | Version | Purpose |
|---|---|---|
| @paralleldrive/cuid2 | ^2.2.2 | Unique ID generation |
| decimal.js | ^10.6.0 | Precise decimal arithmetic |
| reflect-metadata | ^0.2.2 | Metadata reflection (required by NestJS) |
| rxjs | ^7.8.2 | Reactive programming |
Why Decimal.js? - Financial calculations require precision - Avoids floating-point errors - Essential for money operations
Scheduled Tasks
| Technology | Version | Purpose |
|---|---|---|
| @nestjs/schedule | ^6.0.0 | Cron jobs |
Use Cases: - Auto-reject expired orders - Auto-complete valid orders - Periodic cleanup tasks
HTTP Client
| Technology | Version | Purpose |
|---|---|---|
| @nestjs/axios | ^4.0.1 | HTTP client module |
| Axios | ^1.12.2 | Promise-based HTTP client |
Development Tools
| Technology | Version | Purpose |
|---|---|---|
| ts-node | ^10.9.2 | TypeScript execution |
| @nestjs/cli | ^11.0.6 | NestJS CLI tools |
| nodemon | (via NestJS) | Auto-restart on changes |
Deployment
| Technology | Version | Purpose |
|---|---|---|
| Docker | - | Containerization |
| Docker Compose | - | Multi-container orchestration |
Container Features: - Multi-stage builds - Production-optimized - Alpine-based (small image size)
Architecture Decisions
Why PostgreSQL?
- ACID compliance: Critical for financial transactions
- Relational data: Users, orders, services have clear relationships
- Mature ecosystem: Battle-tested, reliable
- Complex queries: Advanced joins and aggregations
Why MongoDB for Chat?
- Flexible schema: Different message types
- Horizontal scaling: Growing message volume
- Document model: Natural fit for messages
Why Redis?
- Speed: In-memory operations
- Simple data structures: Key-value, lists, sets
- TTL support: Auto-expiring data
Why Sequelize?
- Mature ORM: Well-documented
- Migration support: Database version control
- TypeScript support: Type-safe queries
- Multi-dialect: Works with PostgreSQL, MySQL, SQLite
Version Requirements
| Technology | Minimum Version | Recommended |
|---|---|---|
| Node.js | 22.0.0 | Latest v22.x |
| PostgreSQL | 12.0 | Latest stable |
| MongoDB | 6.0 | Latest stable |
| Redis | 6.0 | Latest stable |
| pnpm | 8.0 | 10.7.1+ |