{"id":19718932,"url":"https://github.com/dev-mayanktiwari/mlogs-backend","last_synced_at":"2026-04-10T04:41:50.561Z","repository":{"id":259012571,"uuid":"876103259","full_name":"dev-mayanktiwari/mlogs-backend","owner":"dev-mayanktiwari","description":"The real power behind MLOGS, the backend repository for it.","archived":false,"fork":false,"pushed_at":"2025-01-03T10:52:55.000Z","size":1010,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T15:46:01.986Z","etag":null,"topics":["backend","expressjs","jwt","mongodb","nodejs","postgres","prisma","rest-api","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-mayanktiwari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-21T12:06:09.000Z","updated_at":"2025-01-03T10:52:59.000Z","dependencies_parsed_at":"2024-11-09T11:20:27.326Z","dependency_job_id":"fb6d184a-8310-43cc-aff1-030e448a0811","html_url":"https://github.com/dev-mayanktiwari/mlogs-backend","commit_stats":null,"previous_names":["dev-mayanktiwari/mlogs-final"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-mayanktiwari%2Fmlogs-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-mayanktiwari%2Fmlogs-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-mayanktiwari%2Fmlogs-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-mayanktiwari%2Fmlogs-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-mayanktiwari","download_url":"https://codeload.github.com/dev-mayanktiwari/mlogs-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241039461,"owners_count":19898692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","expressjs","jwt","mongodb","nodejs","postgres","prisma","rest-api","zod"],"created_at":"2024-11-11T23:01:46.030Z","updated_at":"2025-12-30T19:37:57.764Z","avatar_url":"https://github.com/dev-mayanktiwari.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MLOGS: Custom Blog Application for Everyone\r\n\r\n- [Project Overview](#project-overview)\r\n- [Getting Started](#getting-started)\r\n- [Dependency Graph](#dependency-graph)\r\n- [Development](#development)\r\n  - [Manual Setup](#manual-setup)\r\n  - [Setup using Docker](#setup-using-docker)\r\n- [Testing](#testing)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n## Project Overview\r\n\r\nMLOGS is a platform that puts you in control of your content and your data. Unlike typical blogging services, MLOGS is designed for flexibility, whether you're sharing personal stories, tutorials, or professional insights. With a focus on user-friendly design, scalability, and custom features, mlogs is built to grow alongside you.\r\n\r\nWhy MLOGS?\r\n\r\n- **Complete Ownership**: Host it yourself or use our hosting, with full control over your data and content.\r\n\r\n- **Flexible \u0026 Customizable**: Tailor your blog's appearance, user experience, and features to match your brand.\r\n\r\n- **Engaging \u0026 Interactive**: Built-in support for comments, likes, and sharing tools to keep your audience engaged.\r\n\r\n- **Developer-Friendly**: Designed with a modular architecture, allowing you to expand and scale with ease.\r\n\r\n### Built With\r\n\r\n- [Node.js](https://nodejs.org/en)\r\n- [Typescript](https://www.typescriptlang.org/)\r\n- [Prisma.io](https://prisma.io/?ref=cal.com)\r\n- [Express](https://expressjs.com/)\r\n- [Zod](https://zod.dev/)\r\n\r\n## Getting Started\r\n\r\nTo get a local copy up and running, please follow these simple steps.\r\n\r\n### Prerequisites\r\n\r\nHere is what you need to be able to run MLOGS.\r\n\r\n- Node.js (Version: \u003e=20.x)\r\n- PostgreSQL (Version: \u003e=13.x)\r\n- NPM\r\n\r\n### Dependency Graph\r\n\r\n![Backend Dependency Graph](./public/backend-dependency-graph.svg)\r\n\r\n## Development\r\n\r\n### Manual Setup\r\n\r\n1. Clone the repo into a public GitHub repository (or fork https://github.com/dev-mayanktiwari/mlogs-final).\r\n\r\n   ```sh\r\n   git clone https://github.com/dev-mayanktiwari/mlogs-final\r\n   ```\r\n\r\n   \u003e If you are on Windows, run the following command on `gitbash` with admin privileges: \u003cbr\u003e \u003e `git clone -c core.symlinks=true https://github.com/dev-mayanktiwari/mlogs-final` \u003cbr\u003e\r\n\r\n2. Go to the project folder\r\n\r\n   ```sh\r\n   cd mlogs-final\r\n   ```\r\n\r\n3. Install packages with npm\r\n\r\n   ```sh\r\n   npm install\r\n   ```\r\n\r\n4. Set up your `.env` file\r\n\r\n   - Duplicate `.env.example` to `.env`\r\n   - Use `openssl rand -base64 32` to generate a key and add it under `ACCESS_TOKEN_SECRET` and `REFRESH_TOKEN_SECRET` in the `.env` file.\r\n   - Set the `ACCESS_TOKEN_EXPIRY` to 3600000 (1 hour) and the `REFRESH_TOKEN_EXPIRY` to 604800000 (7 days)\r\n\r\n5. Setup Node\r\n   If your Node version does not meet the project's requirements as instructed by the docs, \"nvm\" (Node Version Manager) allows using Node at the version required by the project:\r\n\r\n   ```sh\r\n   nvm use\r\n   ```\r\n\r\n   You first might need to install the specific version and then use it:\r\n\r\n   ```sh\r\n   nvm install \u0026\u0026 nvm use\r\n   ```\r\n\r\n   You can install nvm from [here](https://github.com/nvm-sh/nvm).\r\n\r\n6. Database Setup\r\n   You can configure the database for `mlogs` using either a managed service like Aiven or by setting up a local instance. Follow the instructions below for each approach.\r\n\r\n   Option 1: Managed Database on Aivenc(or any other servive)\r\n   Using Aiven simplifies database setup, security, and scaling. Here’s how to get started:\r\n\r\n   1. **Create an Account on Aiven (or any other service)**\r\n\r\n      - Sign up at [Aiven.com](https://aiven.io/) and start a free trial if needed.\r\n\r\n   2. **Create a Database Instance**\r\n\r\n      - Choose your preferred database type (e.g., PostgreSQL, MySQL).\r\n      - From your Aiven dashboard, select **Create Service**.\r\n      - Configure the instance with the desired name, region, and plan, then create the database.\r\n\r\n   3. **Get Connection Details**\r\n\r\n      - After creation, navigate to your database’s **Connection Information**.\r\n      - Copy the connection URL, which includes the host, port, user, password, and database name.\r\n\r\n   4. **Configure Your Project**\r\n\r\n      - Add the database URL to your project’s `.env` file:\r\n\r\n      ```plaintext\r\n      DATABASE_URL=\"your-aiven-database-url\"\r\n      ```\r\n\r\n   5. **Run Migrations** (if applicable)\r\n\r\n      - Run migrations using\r\n\r\n      ```sh\r\n      npx prisma migrate dev --name init\r\n      ```\r\n\r\n   Option 2: Local Database Setup\r\n   For development purposes, you can also set up a local database. Here’s how to do it with PostgreSQL:\r\n\r\n   1. **Install PostgreSQL**\r\n\r\n      - Download and install PostgreSQL from [https://www.postgresql.org/download/](https://www.postgresql.org/download/).\r\n\r\n   2. **Start the PostgreSQL Service**\r\n      - Make sure the PostgreSQL service is running. Use the following commands:\r\n\r\n   ```bash\r\n   sudo service postgresql start  # on Linux\r\n   brew services start postgresql # on macOS with Homebrew\r\n   ```\r\n\r\n   3. **Create a Database and User**\r\n\r\n      - Open the PostgreSQL command line (using `psql`) and set up your database and user:\r\n\r\n      ```sql\r\n      CREATE DATABASE mlogs;\r\n      CREATE USER yourusername WITH ENCRYPTED PASSWORD 'yourpassword';\r\n         GRANT ALL PRIVILEGES ON DATABASE mlogs TO yourusername;\r\n      ```\r\n\r\n   4. **Configure Your Project**\r\n\r\n      - Add your local database connection details to the `.env` file:\r\n\r\n      ```plaintext\r\n      DATABASE_URL=\"postgresql://yourusername:yourpassword@localhost:5432/mlogs\"\r\n      ```\r\n\r\n   5. **Run Migrations** (if applicable)\r\n      - Run migrations to set up your local database schema.\r\n\r\n7. Log Database Setup (Optional)\r\n\r\n   To enable logging in the `mlogs` application, you can set up a MongoDB database to store logs. Follow the steps below to configure MongoDB either through a managed service (MongoDB Atlas) or locally using Docker.\r\n\r\n   Setup using MongoDB Atlas (Cloud-based)\r\n\r\n   1. **Create an Account on MongoDB Atlas**\r\n\r\n      - Go to [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) and sign up for a free account.\r\n\r\n   2. **Create a New Cluster**\r\n\r\n      - After logging in, create a new cluster. Select your preferred cloud provider and region.\r\n\r\n   3. **Create a MongoDB User**\r\n\r\n      - Go to the \"Database Access\" section, and create a user with a username and password. Remember to keep these credentials safe.\r\n\r\n   4. **Get the Connection String**\r\n\r\n      - Replace `\u003cusername\u003e` and `\u003cpassword\u003e` in the connection string with the MongoDB user credentials you created.\r\n      - Go to the \"Connect\" section, select \"Connect your application,\" and copy the connection string.\r\n\r\n   5. **Add the Connection String to Your Environment Variables**\r\n\r\n      - In your `.env` file, add the connection string as follows:\r\n\r\n      ```plaintext\r\n      MONGO_URL=\"mongodb+srv://yourusername:yourpassword@yourcluster.mongodb.net/logs?retryWrites=true\u0026w=majority\"\r\n      ```\r\n\r\n   6. **Verify the Connection (Optional)**\r\n      - Run a quick connection test in your application to ensure MongoDB is correctly set up and accessible.\r\n\r\n8. Redis Setup(Optional, required for email services)\r\n\r\n   To enable Redis functionality in the `mlogs` application, you need to configure Redis. You can set up Redis either locally or by using a cloud-based service.\r\n\r\n   Redis Cloud (Cloud-based)\r\n\r\n   1. **Choose a Redis Cloud Provider**\r\n\r\n      - Pick a Redis cloud provider from the following options:\r\n      - [Redis Labs](https://redislabs.com/)\r\n      - [Upstash](https://upstash.com/)\r\n      - [Aiven](https://aiven.io/redis)\r\n\r\n   2. **Create an Account and Provision a Redis Instance**\r\n\r\n      - Sign up for an account with your chosen provider.\r\n      - Create a new Redis instance through their dashboard.\r\n      - After the instance is created, you will be provided with connection details, including:\r\n        - **Host** (Redis endpoint)\r\n        - **Port** (usually `6379` or a custom port)\r\n        - **Password** (if authentication is enabled)\r\n\r\n   3. **Get the Redis Connection Details**\r\n\r\n      - You will need the following information from your Redis provider:\r\n        - **Host**: Your Redis instance hostname (e.g., `your-redis-hostname`).\r\n        - **Port**: Typically `6379`.\r\n        - **Password**: The password (if set) for connecting to the Redis instance.\r\n\r\n   4. **Add Redis Connection Details to Your `.env` File**\r\n\r\n      - In your `.env` file, configure the Redis connection as follows:\r\n\r\n        ```plaintext\r\n        REDIS_HOST=your-redis-hostname\r\n        REDIS_PORT=6379\r\n        REDIS_PASSWORD=your-redis-password (if applicable)\r\n        ```\r\n\r\n9. Running the application\r\n\r\n   Once you've completed the setup, you can start the backend server by running(make sure you have nodemon installed):\r\n\r\n   ```bash\r\n   npm run dev\r\n   ```\r\n\r\n### Setup using Docker\r\n\r\n1. Run PostgresDB Container\r\n   Start a postgres container in Docker using the following command:\r\n\r\n   ```bash\r\n   docker run -d --name postgres_container -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 postgres\r\n   ```\r\n\r\n   Enter the connection url of the database in the .env file\r\n\r\n   ```plaintext\r\n   postgresql://postgres:mysecretpassword@localhost:5432/postgres\r\n   ```\r\n\r\n2. Run MONGODB Container (Optional)\r\n\r\n   Start a MONGODB container using docker, require for logging:\r\n\r\n   ```bash\r\n   docker run -d --name mlogs -p 27017:27017 mongo\r\n   ```\r\n\r\n   Update the .env file with the connection string:\r\n\r\n   ```plaintext\r\n   MONGO_URL=\"mongodb://localhost:27017\"\r\n   ```\r\n\r\n3. Run Redis container (Optional, for email service)\r\n\r\n   Use the following docker command to run a docker container:\r\n\r\n   ```sh\r\n   docker run -d --name mlogs_redis -p 6379:6379 redis redis-server --requirepass mysecretpassword\r\n   ```\r\n\r\n   Update the .env file with the connection details:\r\n\r\n   ```plaintext\r\n   REDIS_HOST=localhost\r\n   REDIS_PORT=6379\r\n   REDIS_PASSWORD=mysecretpassword\r\n   ```\r\n\r\n4. Build the image\r\n\r\n   In the root directory run the following command to build the image:\r\n\r\n   ```bash\r\n       docker build -t mlogs-backend .\r\n   ```\r\n\r\n5. Start the container:\r\n\r\n   Run the image by running the following command and passing the env file:\r\n\r\n   ```bash\r\n       docker run -d --name mlogs_backend_container --env-file .env -p 3000:3000 mlogs-backend\r\n   ```\r\n\r\n\u003c!-- CONTRIBUTING --\u003e\r\n\r\n## Contributing\r\n\r\nPlease see our [contributing guide](/CONTRIBUTING.md).\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-mayanktiwari%2Fmlogs-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-mayanktiwari%2Fmlogs-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-mayanktiwari%2Fmlogs-backend/lists"}