Skip to content

Samiur-UTI/campaign-dashboard-backend

Repository files navigation

# Campaign Dashboard Backend

Welcome to the **Campaign Dashboard Backend** repository! This project is a [NestJS](https://nestjs.com/) application that serves as the backend for managing campaigns, projects, and user accounts.

## Features

- **NestJS Framework**: Efficient, scalable server-side application framework.
- **PostgreSQL Integration**: Uses PostgreSQL as the database.
- **TypeORM**: Powerful ORM for managing database operations.
- **Authentication**: Includes JWT-based authentication.
- **Seeding**: Seed campaigns for testing pagination and search functionalities.

## Getting Started

Follow these steps to set up and run the project locally.

### Prerequisites

Ensure you have the following installed:

- **Node.js** (version 16 or higher)
- **npm** or **yarn** for package management
- **Docker** (optional but recommended for setting up PostgreSQL and pgAdmin)

### Installation

1. **Clone the Repository**:
   ```bash
   git clone https://github.com/Samiur-UTI/campaign-dashboard-backend.git
   cd campaign-dashboard-backend
  1. Install Dependencies: Using npm:

    npm install

    Or using yarn:

    yarn install
  2. Set Up Environment Variables:

    • Rename the env.example file to .env:
      mv env.example .env
    • Open the .env file and configure the following environment variables:
      POSTGRES_USER=your_username
      POSTGRES_PASSWORD=your_password
      POSTGRES_DB=your_database
      PGADMIN_DEFAULT_EMAIL=admin@example.com
      PGADMIN_DEFAULT_PASSWORD=admin_password
      API_PREFIX=/api/v1
      PORT=5000
      JWT_SECRET=example
  3. Set Up PostgreSQL and pgAdmin:

    • Using Docker Compose:
      docker-compose up -d
    • Alternatively, start PostgreSQL and pgAdmin manually using your preferred setup.
  4. Run Database Migrations:

    npm run migration:run
  5. Start the Application:

    • Development mode:
      npm run start:dev
    • Production mode:
      npm run start:prod

    The API will be available at http://localhost:5000/api/v1.

Seeding Data

To seed the database with test campaigns, use the following command:

npm run seed:campaigns

Scripts

Here are the available npm scripts:

  • npm run start: Start the application in production mode.
  • npm run start:dev: Start the application in development mode with hot reloading.
  • npm run build: Build the application for production.
  • npm run lint: Lint the codebase.
  • npm run migration:generate: Generate a new database migration.
  • npm run migration:run: Run pending database migrations.
  • npm run migration:revert: Revert the last applied migration.
  • npm run seed:campaigns: Seed the database with sample campaigns.

Folder Structure

/campaign-dashboard-backend
├── dist                 # Compiled application files
├── src                  # Source files
│   ├── config           # Configuration files
│   ├── migrations       # TypeORM migrations
│   ├── modules          # Application modules (auth, campaign, user, etc.)
│   ├── seed             # Data seeding scripts
│   └── main.ts          # Application entry point
├── docker-compose.yml   # Docker Compose file for PostgreSQL and pgAdmin
├── env.example          # Example environment configuration
├── package.json         # Project metadata and dependencies
├── tsconfig.json        # TypeScript configuration
├── tsconfig.build.json  # TypeScript build configuration

Contributing

We welcome contributions! Please fork the repository and create a pull request with your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Feedback

If you have any feedback, suggestions, or issues, please open an issue or contact us directly.


Happy coding! 🎉

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published