Skip to content

Repository files navigation

CryVi SmartWeb3

Welcome to CryVi SmartWeb3! This project helps you build and interact with Web3 applications. It includes a full-stack web application with a user-friendly interface (frontend) and a powerful server-side component (backend).

What's Inside?

This project is like a big toolbox for Web3 developers. Here's a peek at what it offers:

  • Frontend: A modern website built with React, TypeScript, and Vite for a fast and smooth user experience. Styled with Tailwind CSS and Daisy UI.
  • Backend: A robust server built with Node.js, Express, and TypeScript. It handles data, business logic, and communication with the blockchain.
  • Database: Uses PostgreSQL, a reliable open-source database, to store application data.
  • Blockchain Tools: Integrates with services like Alchemy (for talking to the Ethereum blockchain) and Zerion (for tracking DeFi portfolios).
  • Monorepo Power: Uses Turborepo to manage the frontend and backend code together efficiently.
  • Containerization: Includes Docker support, making it easy to set up and run the project consistently anywhere.

πŸš€ Making It Real: From Demo to DApp

This application shows off many cool features you'd find in a modern crypto or blockchain app (often called a "Web3 DApp"). Right now, many parts use "mock data" (which is like sample or pretend information) or "placeholder functions" (meaning they simulate an action but don't do it for real yet). To make this app fully live and working, these parts would need to be connected to:

  • A backend server (the app's main brain and memory, running on the internet).
  • Live blockchain networks (like Ethereum or Polygon).
  • Specialized third-party services (other companies that provide useful tools, like for buying crypto or tracking portfolios).

Here’s a simple guide to what's a demo and what it would need to become real:

1. Your Projects and Files:

  • What you see: You can create projects, add folders, and make files (like smart contracts).
  • Currently: This is like a personal notepad in your browser. Your projects and files are stored temporarily in your browser's memory.
  • To make it real: This would need a backend server with a database. Think of it like cloud storage (e.g., Google Drive or Dropbox) but for your DApp projects, so you can access them anytime, anywhere, and they are saved securely.

2. Smart Contract Magic:

  • Creating Token Contracts: You can choose options (like name, symbol for a new crypto token) and the app generates Solidity (smart contract language) code for you.
    • Currently: The code generated is based on good, industry-recognized templates, but it's a standard starting point.
    • To make it real: For very unique or complex tokens, a developer might review and customize this code. The generation logic itself could be expanded on a server for more advanced template options.
  • Testing Contracts: There's a "Testing" tab where you can (pretend to) run tests on your contracts.
    • Currently: This simulates a test run and shows sample pass/fail messages.
    • To make it real: This needs to connect to a special testing service on a server. This service would take your contract code, prepare it (like compiling a computer program), and run automated checks to make sure it works correctly.

3. Deploying Your Smart Contracts (Putting them on the Blockchain):

  • What you see: You can select a blockchain network (like Ethereum or Polygon testnets) and click "Deploy."
  • Currently: This is a simulation. It shows you what the process looks like (estimating gas, sending the transaction, waiting for confirmation) but doesn't actually put anything on a live blockchain.
  • To make it real:
    • Gas Estimation: The app needs to ask the live blockchain network how much "gas" (transaction fee) is needed.
    • Deployment Transaction: Your actual connected crypto wallet (like MetaMask) would be used to send the deployment transaction to the chosen network and pay the real gas fees. The application would then watch the blockchain for confirmation.

4. The Template Marketplace:

  • What you see: A list of pre-built smart contract templates (like for an NFT or a DAO) that you can browse and "use."
  • Currently: This is a sample list of templates stored in the app's code.
  • To make it real: These templates would come from a backend database. If you wanted a "community marketplace" where others can share templates, that would also need a backend system for submission and management.
  • "Using" a Template: When you "use" a template, it correctly copies the code into your projects. However, deploying that template still follows the simulated deployment mentioned above.

5. Your Crypto Wallet and Balances:

  • What you see: You can connect your crypto wallet (like MetaMask). Sometimes, you might see token balances (e.g., in the Swap or Staking sections).
  • Currently: While your wallet connection is real, most token balances displayed are samples.
  • To make it real: The application would need to use your connected wallet's connection to the blockchain to ask for your current balance of each specific token, in real-time.

6. DeFi Features (Buying, Swapping, Staking Crypto):

  • Purchasing Crypto (/defi/purchase):
    • What you see: A page explaining you can buy crypto with a card.
    • Currently: This is a placeholder. It shows where a service like MoonPay or Transak would appear.
    • To make it real: You'd need to sign up with one of these specialized services for buying crypto (they are like a secure checkout for crypto). They give you a special code (an "API key") and a ready-made tool (a "widget" or mini-app) that you can add to this page to handle the actual buying process securely.
  • Swapping Tokens (/defi/swap):
    • What you see: An interface to swap one crypto token for another (e.g., ETH for USDC).
    • Currently: The list of tokens and the exchange rates/quotes are samples. The swap itself is simulated.
    • To make it real: This needs to connect to a specialized service that finds the best crypto swap rates (called a "DEX Aggregator"). This service provides live prices. Then, the app would use your wallet to: 1. Give permission for the service to use the tokens you want to swap. 2. Confirm the actual swap, which your wallet sends to the blockchain.
  • Staking Tokens (/defi/staking):
    • What you see: Options to "stake" your crypto (lock it up to earn rewards) in different "pools."
    • Currently: The pools, your staked amounts, and the rewards you earn are all simulated.
    • To make it real: This feature needs to connect to real "staking" smart contracts that are already live on the blockchain. (Smart contracts are programs that run on the blockchain). The app would use your wallet to send your tokens to these contracts to stake them and to claim any real rewards you've earned. Information about the staking opportunities (like interest rates, called APR, or how much is already staked, called TVL) would also come from these smart contracts or a supporting backend system.

7. Crypto Portfolio Tracking (/portfolio):

  • What you see: A page showing the value of your crypto assets. You can add multiple wallet addresses to track.
  • Currently: The displayed assets, their quantities, and values are samples.
  • To make it real: This needs to connect to a specialized portfolio tracking service (like Zerion, Zapper, or Covalent). You give these services your public wallet addresses, and they automatically gather and show you all your crypto assets from many different blockchains in one place.

8. Tax Calculator (/tax-calculator):

  • What you see: A page explaining what a tax calculator is for.
  • Currently: This is just an informational placeholder. Crypto taxes are very complex!
  • To make it real: This would require a highly specialized system, often a dedicated third-party service or very complex custom software, to import all your transaction history and apply relevant tax rules. The app currently advises seeking professional help or dedicated tax software.

9. Activity Feed & Analytics (/analytics):

  • What you see: A log of your recent actions within the app and some basic stats.
  • Currently: This activity log is stored only in your browser and is just for your current session. The stats are very simple (e.g., number of projects you've created in the current session).
  • To make it real: For a persistent activity log (that you can see across sessions or that an admin could view) and for more detailed app usage analytics, this would need to send data to a backend server and analytics database.

This section aims to make it clear that while the app showcases a lot of functionality, the "engine" for many features (the backend, blockchain connections, third-party services) needs to be fully connected to move from this demonstration to a live, production-ready DApp.

Project Structure

The project is organized to keep things tidy. The main parts are within the web-app/ folder:

cryvisw3dapp/
β”œβ”€β”€ README.md           # You are here! This guide explains the project.
└── web-app/            # Contains the full-stack web application
    β”œβ”€β”€ apps/           # Houses the frontend and backend applications
    β”‚   β”œβ”€β”€ frontend/   # Code for the website you see and interact with
    β”‚   └── backend/    # Code for the server that works behind the scenes
    β”‚       β”œβ”€β”€ src/      # Main source code for the backend
    β”‚       β”‚   β”œβ”€β”€ db/
    β”‚       β”‚   β”‚   └── schema.ts # Describes the structure of the backend's database
    β”‚       β”‚   └── ... (other backend files)
    β”‚       └── package.json # Lists dependencies for the backend
    β”œβ”€β”€ packages/       # Shared code or configurations for the web-app
    β”œβ”€β”€ docker-compose.yml # Instructions for Docker to run the app
    β”œβ”€β”€ package.json    # Manages the web-app parts and shared scripts
    └── turbo.json      # Configuration for Turborepo

The backend (web-app/apps/backend/) is where any database interactions are primarily managed.

Technologies We Use

  • Turborepo: Helps manage the frontend and backend code efficiently.
  • React & Vite: For building a fast and modern frontend.
  • TypeScript: Adds an extra layer of reliability to JavaScript code.
  • Tailwind CSS & Daisy UI: For styling the website beautifully.
  • Node.js & Express.js: For building a strong backend server.
  • PostgreSQL: A popular and robust database for storing information.
  • Alchemy SDK & Zerion API: Tools for connecting to the blockchain world.
  • Docker: A tool to package the application so it runs the same way everywhere.

Development Tools

This project leverages several tools to facilitate smart contract and decentralized application (dApp) development:

  • Remix IDE: An open-source web and desktop application for Solidity smart contract development. It's useful for quickly writing, deploying, and debugging smart contracts.
  • Etherscan: A block explorer and analytics platform for Ethereum. It allows you to view transactions, smart contract code, and network statistics. It's invaluable for debugging and verifying interactions on the blockchain.
  • Hardhat: A development environment for Ethereum software. It helps manage and automate the recurring tasks inherent in building smart contracts and dApps, like compiling code, running tests, and deploying to various networks.
  • ethers.js: A compact and complete JavaScript library for interacting with the Ethereum Blockchain and its ecosystem. It's used in the frontend and backend to connect to wallets, query blockchain data, and send transactions.

Before You Start (Prerequisites)

Make sure you have these tools installed on your computer:

  • Node.js: (Version 18 or newer is recommended) - This lets you run JavaScript code.
  • npm: (Usually comes with Node.js) - This helps you install project dependencies.
  • Docker: (Optional, but recommended for easier setup) - This helps run the application in a consistent environment.
  • Git: For downloading (cloning) the project code.

Getting Started: Your First Steps

Let's get the project up and running on your computer!

1. Download the Code

First, you need to get a copy of the project. Open your terminal (command prompt) and run:

git clone <your-repository-url>
cd cryvisw3dapp
# Replace <your-repository-url> with the actual link to the project.
# cd cryvisw3dapp navigates you into the project's main folder.

2. Install Project Dependencies

The project has several parts (frontend, backend) that need their own tools. We use Turborepo to manage this. Navigate to the web-app folder and install everything:

cd web-app
npm install
# This command looks at package.json files and downloads all necessary libraries.

3. Set Up Environment Variables (Important Secrets!)

The backend needs some secret keys and settings to work, like API keys for Alchemy and Zerion, and database connection details.

  • Go to the web-app/apps/backend/ folder.
  • Create a new file named .env.
  • Copy the content from the example below into your new .env file.

Example for web-app/apps/backend/.env:

# Server Configuration
PORT=3001 # Port for the backend server.

# --- Database Connection ---
# For running the backend directly on your computer (Option B in Database Setup)
DATABASE_URL="postgresql://myuser:mypassword@localhost:5432/myappdb"

# For running the backend inside Docker (Option A in Database Setup)
DATABASE_URL_DOCKER="postgresql://myuser:mypassword@db:5432/myappdb"

# --- API Keys (Get these from the services themselves) ---
ALCHEMY_API_KEY="YOUR_ALCHEMY_API_KEY"
ZERION_API_KEY="YOUR_ZERION_API_KEY" # Check Zerion's docs for how to format this.

# --- Docker Compose Database Settings ---
# These are used by web-app/docker-compose.yml if not set elsewhere.
POSTGRES_USER="myuser"
POSTGRES_PASSWORD="mypassword"
POSTGRES_DB="myappdb"

Important:

  • Replace "YOUR_ALCHEMY_API_KEY" and "YOUR_ZERION_API_KEY" with your actual keys.
  • For DATABASE_URL, myuser, mypassword, and myappdb are examples. You might need to change these based on your PostgreSQL setup.
  • The .env file is ignored by Git, so your secrets stay safe on your computer.

4. Set Up the Database (PostgreSQL)

The backend needs a PostgreSQL database to store information.

Option A: Using Docker (Recommended for Beginners)

This is the easiest way to get PostgreSQL running without installing it directly on your computer. Make sure Docker is running.

  1. Start the PostgreSQL Database with Docker Compose: Open your terminal in the cryvisw3dapp/web-app/ directory (where the docker-compose.yml file is).

    docker-compose up -d db
    • docker-compose up: Starts services defined in docker-compose.yml.
    • -d: Runs the database in the background (detached mode).
    • db: Tells Docker Compose to only start the service named 'db' (our PostgreSQL database).

    Your database is now running in Docker! The backend, when also run in Docker, will connect to it using DATABASE_URL_DOCKER from your .env file.

Option B: Local PostgreSQL Instance

If you prefer, you can install PostgreSQL directly on your computer.

  1. Install and Run PostgreSQL: Download and install PostgreSQL. Make sure the service is running.
  2. Create a Database: Create a new database (e.g., myappdb) and a user (e.g., myuser) with a password (e.g., mypassword).
  3. Configure DATABASE_URL: In your web-app/apps/backend/.env file, make sure the DATABASE_URL variable correctly points to your local PostgreSQL instance (e.g., postgresql://myuser:mypassword@localhost:5432/myappdb).

Database Structure (Schema): The structure of the database tables is defined in web-app/apps/backend/src/db/schema.ts. If you are using an ORM or migration tool with your PostgreSQL setup (other than Drizzle, which has been removed), you would manage database changes (migrations) according to that tool's instructions. This README now provides general guidance for PostgreSQL setup.

How to Run the Application

You can run the frontend and backend separately for development or run everything together using Docker.

All commands below should be run from the cryvisw3dapp/web-app/ directory.

Running in Development Mode (Without Docker)

This is useful for actively developing and seeing changes quickly.

  • Start the Backend Server:

    npm run dev --workspace=@web-app/backend

    This usually starts the backend on http://localhost:3001. It will watch for file changes and restart automatically.

  • Start the Frontend Development Server: In a new terminal window (also in the cryvisw3dapp/web-app/ directory):

    npm run dev --workspace=@web-app/frontend

    This usually starts the frontend on http://localhost:5173 (Vite's default) or similar. Your browser might open automatically.

Running with Docker (Recommended for a Complete Setup)

Docker makes it easy to run the entire application (frontend, backend, and database) together.

  1. Ensure Prerequisites:

    • Docker is installed and running.
    • Your web-app/apps/backend/.env file is correctly configured, especially DATABASE_URL_DOCKER and your API keys.
  2. Build and Start All Services: In your terminal, from the cryvisw3dapp/web-app/ directory:

    docker-compose up --build
    • --build: Tells Docker to build the images for the frontend and backend before starting. You only need to do this the first time or if you change their Dockerfiles.
    • This command will show logs from all services in your terminal.

    To run in the background (detached mode):

    docker-compose up -d --build
  3. Accessing the Application: Once Docker is finished:

    • Frontend (Website): Open your browser to http://localhost:8080
    • Backend API: Is available at http://localhost:3001 (the frontend uses this internally).
  4. Viewing Logs (if running in background):

    docker-compose logs -f # Shows logs from all services
    docker-compose logs -f backend # Shows logs only for the backend
  5. Stopping the Application:

    • If running in the foreground (logs visible), press Ctrl + C in the terminal.
    • If running in the background (detached mode):
      docker-compose down
    • To stop and remove data volumes (like database data, use with caution!):
      docker-compose down -v

Available Scripts

Here are some useful commands you can run from the cryvisw3dapp/web-app/ directory using npm run <script_name>. Use the --workspace flag to target a specific app (frontend or backend).

General (run from web-app/):

  • npm run dev: Tries to start both frontend and backend in development mode.
  • npm run build: Creates production-ready versions of both frontend and backend.

Backend (--workspace=@web-app/backend):

  • npm run dev --workspace=@web-app/backend: Starts backend in development mode (watches files).
  • npm run build --workspace=@web-app/backend: Compiles backend code for production.
  • npm run start --workspace=@web-app/backend: Runs the compiled backend (for production).

Frontend (--workspace=@web-app/frontend):

  • npm run dev --workspace=@web-app/frontend: Starts frontend in development mode (fast updates).
  • npm run build --workspace=@web-app/frontend: Builds frontend for production.
  • npm run preview --workspace=@web-app/frontend: Lets you view the production build locally.

Contributing

We'd love your help to make this project better! (A CONTRIBUTING.md file with more details will be added later).

License

[Specify the license for your project, e.g., MIT License]


Remember to replace placeholders like <your-repository-url> and update the license information.

About

CryVi SmartWeb3 - This project will include a dapp with a suite of tools to facilitate development and interaction with decentralized applications.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages