Skip to content

Getting Started

Thant Htoo Aung edited this page Feb 23, 2026 · 1 revision

Getting Started

This guide will help you set up and run the DevCom Social Media API on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v20.x or higher)
  • MongoDB (v7.0 or higher) - or use Docker
  • npm or yarn
  • Git

Installation

1. Clone the Repository

git clone https://github.com/your-username/DevCom_Node.git
cd DevCom_Node

2. Install Dependencies

npm install

3. Environment Setup

Create a .env file in the root directory:

cp .env.example .env

Edit .env with your configuration:

# Server Configuration
PORT=3000
NODE_ENV=development

# Database
MONGO_URI=mongodb://localhost:27017/devcom

# JWT
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRES_IN=7d

# Cloudinary (for image uploads - optional)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=100

4. Start MongoDB

Option A: Using Docker (Recommended)

docker-compose up -d mongodb

Option B: Local MongoDB

Make sure MongoDB is running on your system:

# macOS
brew services start mongodb-community

# Linux
sudo systemctl start mongod

# Windows
# Start MongoDB service from Services panel

5. Run the Application

Development Mode:

npm run dev

The server will start on http://localhost:3000

Production Mode:

npm run build
npm start

Verify Installation

  1. Check the health endpoint:
curl http://localhost:3000/health

Expected response:

{
  "success": true,
  "message": "Server is running",
  "timestamp": "2024-01-01T00:00:00.000Z"
}
  1. Test the API by registering a user:
curl -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Test User",
    "email": "test@example.com",
    "password": "password123"
  }'

Project Structure

src/
├── app.ts                 # Express app configuration
├── server.ts              # Server entry point
├── config/                # Configuration files
├── modules/               # Feature modules
│   ├── auth/             # Authentication
│   ├── user/             # User management
│   ├── post/             # Posts
│   ├── comment/          # Comments
│   ├── reaction/         # Reactions
│   ├── feed/             # Global feed
│   └── tag/              # Tags
├── common/                # Shared utilities
├── routes/                # Route definitions
└── database/              # Database models

Next Steps

Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running: mongosh --eval "db.adminCommand('ping')"
  • Check your MONGO_URI in .env
  • Verify MongoDB is accessible on the specified port

Port Already in Use

If port 3000 is already in use, change the PORT in your .env file.

TypeScript Errors

Make sure all dependencies are installed:

npm install

Build Errors

Clear the build directory and rebuild:

rm -rf dist
npm run build

Need help? Open an issue on GitHub or check the Troubleshooting Guide.