GithubHelp home page GithubHelp logo

woaitsaryan / attack-capital-task Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 710 KB

Home Page: https://attack-capital.aryanbharti.com/

TypeScript 94.23% CSS 1.32% JavaScript 0.54% Dockerfile 3.90%

attack-capital-task's Introduction

Attack Capital Fullstack Internship Task

Hosted at attack-capital.aryanbharti.com

Overview

Welcome to Attack Capital's Fullstack Internship Task! This repository contains the codebase for the personal blog platform developed as part of the task. The platform allows users to sign up, log in, and post blog posts. Users can view all posts and filter them by author. The backend is built using Node.js and Express, while the frontend uses Next.js 14 with TypeScript.

Task Description

Develop a personal blog platform where users can sign up, log in, and post articles. The platform should allow users to view all posts and filter them by author. The backend should be built using Node.js and Express, and the frontend should use Next.js 14 with TypeScript.

Technologies Used

Frontend

  • Language: TypeScript
  • Framework: Next.js
  • CSS Framework: Tailwind CSS

Backend

  • Language: Typescript
  • Web Framework: Express
  • ORM: Mongoose and IORedis
  • Databases: MongoDB (main database), Redis (caching)

Getting Started with Roles

  1. After running both Docker containers, you need to sign in.

Usage

To utilize the Attack Capital personal blog website, follow these steps:

- Clone the Repository

git clone https://github.com/woaitsAryan/attack-capital-task
cd attack-capital-task

- Run the docker commands in both the folders

Navigate to the respective directories and execute the following Docker commands:

sudo docker compose build
sudo docker compose up -d

( refer the respective running frontend and backend sections )

Web Interface (Frontend)

Environment Variables

Copy the env.sample file to .env and customize it according to your needs. This file contains environment variables used by the frontend.

Running the Frontend

To run the Attack Capital frontend, follow these steps:

  1. Ensure you have Docker installed on your system.

  2. Open a terminal and navigate to the root directory of the frontend.

  3. Copy env from env.sample and make changes only if necessary.

    sudo nano .env
  4. Run the following commands:

    sudo docker compose build
    sudo docker compose up

    or

    npm i -g pnpm
    pnpm install
    pnpm run build
    pnpm run start
  5. The application will be accessible at http://localhost:3000 by default.

Screenshots

Sign Up

Sign up

Login

Login

Home page view

Home page

Dashboard view

Dashboard page

Create Post view

Create post

API (Backend)

Run In Postman

Endpoints

1. Get All Blog posts

  • Endpoint: GET /posts
  • Description: Retrieve all posts
  • Query Parameters:
    • page: Page number for paginated queries (default: 1).
    • limit: Number of posts per page in paginated queries (default: 10).
    • author: Fetch posts of a specific author
  • Sample Request /?page=1&limit=10 - Multiple queries are supported
  • Response Format:
      {
        "posts": [
          {
              "_id": "664620a7e934454efc292810",
              "title": "Tutamen.",
              "content": "Terga thymbra defetiscor.",
              "authorId": {
                  "_id": "664620a7e934454efc2927fb",
                  "email": "[email protected]",
                  "name": "Margarita Adams"
              },
              "createdAt": "2024-05-16T15:05:11.771Z",
          },
          // Additional posts
        ]
    }

2. Create a post

  • Endpoint: POST /posts

  • Description: Add a new post to the database.

  • Request Format:

    {
      "title":"Sample title",
      "content": "some content lorem ipsum yes"
    }
    
  • Response Format: The response from the POST / endpoint is in JSON format and follows the structure below:

    {
    "message": "Post created",
    "post": {
        "_id": "664738b116ed8cfbef8e2740",
        "title": "Sample title",
        "content": "some content lorem ipsum yes",
        "authorId": "6645ec717c00ecf279d8a7c9",
        "createdAt": "2024-05-17T11:00:01.326Z",
        "__v": 0
    }
    }
    

3. Sign Up

  • Endpoint: POST /auth/signup

  • Description: Create a new user.

  • Request Format:

    {
      "email":"[email protected]",
      "password": "password12345",
      "name":"Aryan Bharti"
    }
    
  • Response Format: The response from the POST /auth/signup endpoint is in JSON format and follows the structure below:

    {
      "token": "jwt_token",
      "message": "Account successfully registered!",
      "name": "Aryan Bharti",
    }

6. Login

  • Endpoint: POST /auth/login

  • Description: Login route.

  • Request Format:

    {
      "email":"[email protected]",
      "password": "password12345"
    }
    
  • Response Format: The response from the POST /auth/login endpoint is in JSON format and follows the structure below:

    {
     "token": "jwt_token",
    "message": "Successfully logged in!",
    "name": "Aryan Bharti"
    } 
    

Caching

Redis is utilized for caching in this system. The filters used in queries are used as the key for the Redis storage. This approach ensures that redundant queries for the same filter do not incur additional processing time. The Redis storage also considers pagination, using the default limit of 10.

Environment Variables

A sample of the environment file is provided in the root directory of the backend, named .env.sample.

Running the Backend

To run the Attack Capital Backend, follow these steps:

  1. Ensure you have Docker installed on your system.

  2. Open a terminal and navigate to the root directory of the backend.

  3. Copy env from env.sample and make changes only if necessary.

    sudo nano .env
  4. Run the following commands:

    sudo docker compose build
    sudo docker compose up

    or

    pnpm install
    pnpm run build
    pnpm run start
  5. The application will be accessible at http://localhost:3000 by default.

  6. You can seed the database with dummy blog posts using pnpm run seed or node scripts/seed.js if built

Best Regards, Aryan Bharti

attack-capital-task's People

Contributors

woaitsaryan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.