This is a decentralized social media application that leverages blockchain technology to provide a secure and transparent social media platform for users. The application consists of several components: client, blockchain, API, server, and wallet.
- Project Structure
- Requirements
- Setup and Installation
- Environment Configuration
- Running the Application
- Contributing
- client: Contains the frontend code for the social media app.
- blockchain: Includes smart contracts and configuration files.
- api: Node.js APIs used by the application.
- server: Python code for plagiarism checking and detection.
- wallet: Flutter application code for the wallet functionality.
- Node.js: Ensure you have Node.js installed for the API.
- Git: Version Control
- Python: Required for the server-side plagiarism detection.
- Flutter: Needed for the wallet application.
- Hardhat: Required for managing smart contracts.
- Android Phone: Required for installing the mobile wallet app
- Clone the repository to your local machine using Git. Open your terminal and run the following command:
git clone https://github.com/shrawank22/social_media_dapp.git
- Navigate to the project directory:
cd social_media_dapp
For each component (client, api, blockchain, server, and wallet), open a new terminal and follow the corresponding instructions below:
- Navigate to the
client
directory:cd client
- Install dependencies:
npm install
- Navigate to the
api
directory:cd api
- Install dependencies:
npm install
- Navigate to the
blockchain
directory:cd blockchain
- Install dependencies and set up the blockchain environment:
npm install
- Compile smart contracts:
npx hardhat compile
- Deploy smart contracts:
npx hardhat run scripts/deploy.js --network polygon
- Navigate to the
server
directory:cd server
- Install Python dependencies:
pip3 install -r requirements.txt
- After installing nltk, download the stopwords and punkt tokenizer models by opening a Python shell:
import nltk nltk.download('punkt') nltk.download('stopwords')
- Navigate to the
wallet
directory:cd wallet
- Ensure Flutter is installed and set up.
- Get Flutter packages:
flutter pub get
- Generate freezed files:
flutter pub run build_runner build
You need to create .env files in the client, api, and blockchain directories to store environment-specific variables. Here are the instructions for each:
- Create a .env file in the client directory:
touch .env
- Add the necessary environment variables (replace placeholders with actual values):
VITE_PINATA_KEY= VITE_PINATA_SECRET_KEY= VITE_CONTRACT_ADDRESS= VITE_REACT_APP_VERIFICATION_SERVER_PUBLIC_URL=https://27c5-202-3-77-209.ngrok-free.app # Update HOSTED_SERVER_URL with the ngrok url returned when you run `ngrok http ${SERVER_PORT}` VITE_REACT_APP_VERIFICATION_SERVER_LOCAL_HOST_URL=http://localhost:8080 VITE_PUBLIC_PROJECT_ID= VITE_PUBLIC_RELAY_URL=wss://relay.walletconnect.com VITE_RPC_URL=
- Create a .env file in the api directory:
touch .env
- Add the necessary environment variables:
HOSTED_SERVER_URL=https://27c5-202-3-77-209.ngrok-free.app # Update HOSTED_SERVER_URL with the ngrok url returned when you run `ngrok http ${SERVER_PORT}` RPC_URL_AMOY= VERIFIER_DID= ISSUER_DID= AMOY_CONTRACT_ADDRESS= BASIC_AUTH= FRONTEND_URL=http://localhost:5173 HOSTED_ISSUER_URL= HOSTED_RESOLVER_URL= MONGODB_URI= SECRET=fdhvewuifhjweuhrfwe&&Q&WE007**%%%52dgyfh@^ghqdbhfewnjweuhqwegyqwevqhw CONTRACT_ADDRESS= API_KEY=
- Create a .env file in the blockchain directory:
touch .env
- Add the necessary environment variables:
PRIVATE_KEY= # metamask account private key API_KEY= # Alchemy/Infura API_Key
Make sure to replace the placeholder values with your actual configuration details.
Ngrok is required to expose your local server to the internet. Follow these steps:
- Install Ngrok from official website https://ngrok.com/
- Start Ngrok and point it to your server port:
ngrok http 8080
- Copy the ngrok URL displayed in the terminal and update the client and api .env files.
In each terminal, navigate to the corresponding directory and run the appropriate command:
- Start the frontend application:
npm run dev
- Start the Node.js API server:
npm start
- Start the Python server:
python3 app.py
- Run the Flutter application:
flutter run --dart-define=PROJECT_ID=xxx
Contributions are welcome! Please follow the standard GitHub flow and ensure code is well-documented.