Hosted at attack-capital.aryanbharti.com
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.
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.
- Language: TypeScript
- Framework: Next.js
- CSS Framework: Tailwind CSS
- Language: Typescript
- Web Framework: Express
- ORM: Mongoose and IORedis
- Databases: MongoDB (main database), Redis (caching)
- After running both Docker containers, you need to sign in.
To utilize the Attack Capital personal blog website, follow these steps:
git clone https://github.com/woaitsAryan/attack-capital-task
cd attack-capital-task
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 )
Copy the env.sample
file to .env
and customize it according to your needs. This file contains environment variables used by the frontend.
To run the Attack Capital frontend, follow these steps:
-
Ensure you have Docker installed on your system.
-
Open a terminal and navigate to the root directory of the frontend.
-
Copy env from env.sample and make changes only if necessary.
sudo nano .env
-
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
-
The application will be accessible at
http://localhost:3000
by default.
Sign Up
Login
Home page view
Dashboard view
Create Post view
- 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 ] }
-
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 } }
-
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", }
-
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" }
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.
A sample of the environment file is provided in the root directory of the backend, named .env.sample
.
To run the Attack Capital Backend, follow these steps:
-
Ensure you have Docker installed on your system.
-
Open a terminal and navigate to the root directory of the backend.
-
Copy env from env.sample and make changes only if necessary.
sudo nano .env
-
Run the following commands:
sudo docker compose build sudo docker compose up
or
pnpm install pnpm run build pnpm run start
-
The application will be accessible at
http://localhost:3000
by default. -
You can seed the database with dummy blog posts using
pnpm run seed
or node scripts/seed.js if built
Best Regards, Aryan Bharti