Codebase Overview
Name: starter-oracle-shatab
Type: Backend API Server
Purpose: A boilerplate backend for News Portal - a news/media platform
Language: TypeScript
Runtime: Node.js (>=18)
Architecture
Tech Stack
- Framework: Express.js
- Database: Oracle (via TypeORM)
- Authentication: JWT (JSON Web Tokens)
- Real-time: WebSocket (ws library)
- File Storage: AWS S3 + local uploads
- Documentation: Swagger/OpenAPI
- Scheduling: node-cron
- Validation: Zod
- Caching: Node-cache
Directory Structure
src/
├── app.ts # Express app configuration
├── server.ts # Server entry point
├── data-source.ts # TypeORM data source config
├── config/
│ ├── index.ts # Environment config
│ └── swaggerConfig.ts # Swagger setup
├── app/
│ ├── entities/ # TypeORM entity definitions
│ ├── modules/ # Feature modules (News, Auth, Users, etc.)
│ ├── route/ # Express router
│ ├── middleware/ # Express middleware
│ ├── helper/ # Utility functions
│ ├── interface/ # Repository interfaces
│ ├── DB/ # Database connection
│ └── error/ # API error handling
└── shared/
└── catchAsync.ts # Async handler wrapper
Core Features
1. Entity Models (Database Tables)
The application uses TypeORM with Oracle and defines these main entities:
| EntityDescription |
News | Articles with title, description, images, tags, location (division/district/upazila), scheduling |
Admins | Admin users with role-based access control |
Bulletins | News bulletins/categories |
Ads | Advertisements |
Videos | Video content |
Polls | Voting polls linked to parties |
Party | Political parties for voting |
Category | Content categorization |
Comments | User comments on news |
Menofestos | Manifestos |
EResultImages | Election result images |
2. Module Structure (by feature)
Each module follows MVC-like pattern:
modules/
├── Auth/
│ ├── auth.controller.ts # Login, token generation
│ ├── auth.router.ts # Routes
│ └── auth.validation.ts # Zod validation
├── News/
├── Users/
├── Advertise/
├── Videos/
├── Poll/
└── Ramadan/
3. Authentication Flow
- Login via
/api/v1/auth/login with email/password - JWT token generated (30-day expiry)
- Token verification via
auth middleware - Role-based access:
super_admin bypasses role checks
4. Key Middleware
auth.ts - JWT authentication and role checkingcheckClient.ts - Client identificationglobalErrorHandler.ts - Centralized error handlingvalidateRequest.ts - Zod request validation
5. Cron Jobs
Automatically publishes scheduled news when scheduledTime arrives (runs every minute).
API Routes
All routes are under /api/v1/:
/api/v1/
├── users - User management
├── auth - Authentication (login, tokens)
├── news - News CRUD operations
├── advertise - Advertisements
├── videos - Video content
├── poll - Polling system
└── ramadan - Ramadan-specific content
Plus:
/api/token - Token generation endpoint/api-docs - Swagger documentation/media, /uploads - Static file serving
Database Configuration
Dual configuration approach:
data-source.ts - Simple config with hardcoded values (dev placeholder)app/DB/database.config.ts - Environment-based config with Oracle connection
Uses Oracle database with SID/service_name mypdb/XE, port 1521.
Key Dependencies
- TypeORM - ORM for Oracle database
- OracleDB - Official Oracle driver
- JWT + bcryptjs - Authentication and password hashing
- AWS SDK + multer-s3 - S3 file uploads
- node-cron - Scheduled tasks
- Zod - Request validation
- Swagger - API documentation
This is a production-ready news media backend with multi-module content management, designed for News Portal's news, video, polling, and advertising needs.
===================================================
TypeScript backend starter boilerplate built with:
- Express.js for APIs/server
- TypeORM for database access
- Oracle Database via
oracledb - Authentication, file upload, Swagger docs, cron jobs, caching, WebSocket support, etc.
It is structured as a production-ready backend template for scalable REST APIs.
1. High-Level Architecture
Your project follows a layered backend architecture:
Client
↓
Express Routes
↓
Controllers
↓
Services
↓
Database Layer (TypeORM + OracleDB)
Typical flow:
HTTP Request
→ Route
→ Controller
→ Service
→ Repository/Entity
→ Oracle Database
→ Response
2. package.json Breakdown
Project Metadata
{
"name": "starter-oracle-shatab",
"version": "1.0.0"
}
Defines:
- package name
- versioning
- npm publishing metadata
Main Entry
"main": "dist/server.js",
"types": "dist/server.d.ts"
After build:
src/server.ts
↓
dist/server.js
types exposes TypeScript declarations when used as a package.
Files
When publishing to npm, only dist/ is included.
Good practice.
3. Scripts Explained
Start Production Server
"start": "node ./dist/server.js"
Runs compiled JavaScript.
Production flow:
Development Mode
"dev": "ts-node-dev --respawn --transpile-only src/server.ts"
What happens:
- watches file changes
- restarts automatically
- runs TS directly without build
Flags
| FlagMeaning |
--respawn | restart process on crash/change |
--transpile-only | skips type checking for speed |
Very common dev setup.
Build
Interesting part.
Normally people use:
But here:
Likely:
- faster TypeScript compiler wrapper
- experimental/native TS compiler
- using:
"@typescript/native-preview"
This suggests you're experimenting with Microsoft's new native TS compiler.
Fallback build:
Lint
"lint": "eslint src --ignore-path .eslintignore --ext .ts"
Checks code quality and style.
4. Database Layer
Core Database Packages
"oracledb": "^6.3.0",
"typeorm": "^0.3.27",
"reflect-metadata": "^0.1.13"
Architecture
TypeORM
↓
OracleDB Driver
↓
Oracle Database
TypeORM Purpose
TypeORM allows:
- Entities
- Repositories
- Migrations
- Query Builder
- Relations
- Decorators
Example:
@Entity()
class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
email: string;
}
Instead of raw SQL everywhere.
reflect-metadata
Required because TypeORM uses decorators.
Without it:
won't work.
Usually imported once in server.ts:
import "reflect-metadata";
5. Migration System
These scripts are currently disabled/commented conceptually:
"migration:generate"
"migration:run"
"migration:revert"
They use:
Meaning migrations run directly in TypeScript.
Migration Flow
Generate migration
npm run migration:generate
Compares entities vs database.
Run migration
Executes pending schema changes.
Revert
Rollback last migration.
6. API Layer Packages
Express
Main HTTP server framework.
Likely structure:
src/
├── app/
├── routes/
├── controllers/
├── services/
├── middlewares/
└── server.ts
CORS
Allows frontend apps to access backend APIs.
Example:
Compression
Gzip compression for responses.
Improves performance.
Morgan
HTTP request logger.
Example log:
7. Authentication & Security
JWT
Token-based authentication.
Typical flow:
Login
→ Generate JWT
→ Client stores token
→ Client sends Authorization header
→ Middleware verifies token
bcryptjs
Password hashing.
Example:
const hashed = await bcrypt.hash(password, 10)
Never store plain passwords.
8. Validation
Zod
Modern schema validation library.
Example:
const schema = z.object({
email: z.string().email(),
})
Used for:
- request validation
- DTO validation
- environment validation
Excellent choice.
9. File Upload System
Multer
Handles multipart/form-data uploads.
AWS S3
"@aws-sdk/client-s3"
"multer-s3"
Means uploads likely go directly to S3.
Flow:
Client Upload
→ Multer
→ multer-s3
→ AWS S3 Bucket
Scalable approach.
10. API Documentation
Swagger
"swagger-jsdoc"
"swagger-ui-express"
Auto-generates API docs.
Usually exposed at:
Allows frontend developers to test APIs visually.
11. Background Jobs & Scheduling
node-cron
Runs scheduled tasks.
Examples:
- cleanup jobs
- sending emails
- nightly syncs
- report generation
Example:
cron.schedule("0 0 * * *", () => {
console.log("Runs daily")
})
12. Caching
node-cache
In-memory caching.
Useful for:
- OTP caching
- temporary session data
- API response cache
Example:
cache.set("user_1", userData)
13. Email System
Nodemailer
Used for:
- OTP emails
- password reset
- notifications
Typical flow:
Backend
→ SMTP
→ User Email
14. Real-Time Communication
ws
Native WebSocket support.
Used for:
- live notifications
- chats
- dashboards
- realtime updates
15. Development Tooling
ts-node
Runs TS directly.
ts-node-dev
Hot reload dev server.
tsx
Modern TS runtime alternative.
TypeScript
Core language.
16. Interesting Design Decisions
OracleDB Instead of PostgreSQL/MySQL
This project is enterprise-oriented.
Oracle is common in:
- banking
- telecom
- government
- ERP systems
TypeORM + Oracle
This combo indicates:
- enterprise backend
- relational-heavy systems
- strong schema modeling
Native TypeScript Preview
This is advanced/experimental:
"@typescript/native-preview"
Very few starter projects use this yet.
17. Expected Folder Structure
Based on dependencies, likely something like:
src/
├── app/
│ ├── config/
│ │ └── database.config.ts
│ ├── modules/
│ │ ├── user/
│ │ ├── auth/
│ │ └── ...
│ ├── middlewares/
│ ├── utils/
│ ├── services/
│ └── routes/
├── server.ts
└── types/
18. Typical Request Lifecycle
Example:
Flow:
Route
→ Validation Middleware (Zod)
→ Controller
→ Service
→ TypeORM Repository
→ OracleDB
→ JWT Generation
→ Response
19. Strengths of This Boilerplate
✅ Type-safe
✅ Enterprise-ready
✅ OracleDB support
✅ Swagger docs
✅ JWT auth ready
✅ File uploads ready
✅ WebSocket support
✅ Cron jobs
✅ Scalable architecture
✅ Production-oriented setup
20. Potential Improvements
You could later add:
- Prisma support
- Redis caching
- Docker
- CI/CD
- Unit testing
- Role-based access control
- Rate limiting
- Helmet security
- OpenTelemetry logging
- Queue system (BullMQ)
21. One Important Observation
Your description says:
"Express, Prisma, TypeScript"
But dependencies actually use:
So the description is outdated/inconsistent.
You should update:
to something like:
"A starter backend boilerplate with Express, TypeScript, OracleDB, TypeORM, and common backend utilities."
22. Overall Summary
This is a:
Enterprise-grade TypeScript backend starter template focused on OracleDB systems using Express + TypeORM architecture.
It is designed for:
- scalable APIs
- enterprise apps
- authentication systems
- real-time systems
- file-heavy systems
- modular backend architecture
and is much more advanced than a beginner Express starter.