Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
kasinadhsarma authored Aug 9, 2024
1 parent 8c3a2fd commit a4a5ef2
Show file tree
Hide file tree
Showing 53 changed files with 3,375 additions and 8 deletions.
45 changes: 45 additions & 0 deletions backend/blockchain/contracts/JobCity.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract JobCity {
string public platformName;
address public owner;
uint256 public totalCertificates;

struct Certificate {
uint256 id;
string courseName;
address recipient;
uint256 issueDate;
}

mapping(uint256 => Certificate) public certificates;

event CertificateIssued(uint256 indexed id, string courseName, address recipient);

constructor(string memory _name) {
platformName = _name;
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can call this function");
_;
}

function issueCertificate(string memory _courseName, address _recipient) public onlyOwner {
totalCertificates++;
certificates[totalCertificates] = Certificate(
totalCertificates,
_courseName,
_recipient,
block.timestamp
);
emit CertificateIssued(totalCertificates, _courseName, _recipient);
}

function getCertificate(uint256 _id) public view returns (Certificate memory) {
require(_id > 0 && _id <= totalCertificates, "Invalid certificate ID");
return certificates[_id];
}
}
25 changes: 25 additions & 0 deletions backend/blockchain/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)

@app.get("/")
async def root():
return {"message": "Welcome to the Job-City Blockchain API"}

@app.get("/health")
async def health_check():
return {"status": "healthy"}

if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
21 changes: 21 additions & 0 deletions backend/blockchain/scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const hre = require("hardhat");

async function main() {
const [deployer] = await hre.ethers.getSigners();

console.log("Deploying contracts with the account:", deployer.address);

const JobCity = await hre.ethers.getContractFactory("JobCity");
const jobCity = await JobCity.deploy("Job-City Platform");

await jobCity.waitForDeployment();

console.log("JobCity contract deployed to:", await jobCity.getAddress());
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
18 changes: 18 additions & 0 deletions models/Task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require('mongoose');

const taskSchema = new mongoose.Schema({
title: {
type: String,
required: true
},
difficulty: {
type: String,
required: true
},
description: {
type: String,
required: true
}
});

module.exports = mongoose.model('Task', taskSchema);
20 changes: 20 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true
},
password: {
type: String,
required: true
},
email: {
type: String,
required: true,
unique: true
}
});

module.exports = mongoose.model('User', userSchema);
212 changes: 204 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,222 @@
{
"name": "jobcity",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"@monaco-editor/react": "^4.6.0",
"accepts": "^1.3.8",
"aes-js": "^4.0.0-beta.5",
"ansi-regex": "^6.0.1",
"ansi-styles": "^6.2.1",
"any-promise": "^1.3.0",
"anymatch": "^3.1.3",
"arg": "^5.0.2",
"array-flatten": "^1.1.1",
"autoprefixer": "^10.4.20",
"balanced-match": "^1.0.2",
"bcryptjs": "^2.4.3",
"binary-extensions": "^2.3.0",
"body-parser": "^1.20.2",
"brace-expansion": "^2.0.1",
"braces": "^3.0.3",
"browserslist": "^4.23.3",
"bson": "^6.8.0",
"buffer-equal-constant-time": "^1.0.1",
"busboy": "^1.6.0",
"bytes": "^3.1.2",
"call-bind": "^1.0.7",
"camelcase-css": "^2.0.1",
"caniuse-lite": "^1.0.30001651",
"chokidar": "^3.6.0",
"client-only": "^0.0.1",
"color-convert": "^2.0.1",
"color-name": "^1.1.4",
"commander": "^4.1.1",
"content-disposition": "^0.5.4",
"content-type": "^1.0.5",
"cookie": "^0.6.0",
"cookie-signature": "^1.0.6",
"cross-spawn": "^7.0.3",
"cssesc": "^3.0.0",
"debug": "^2.6.9",
"define-data-property": "^1.1.4",
"depd": "^2.0.0",
"destroy": "^1.2.0",
"didyoumean": "^1.2.2",
"dlv": "^1.1.3",
"eastasianwidth": "^0.2.0",
"ecdsa-sig-formatter": "^1.0.11",
"ee-first": "^1.1.1",
"electron-to-chromium": "^1.5.5",
"emoji-regex": "^9.2.2",
"encodeurl": "^1.0.2",
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0",
"escalade": "^3.1.2",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"ethers": "^6.13.2",
"express": "^4.19.2",
"fast-glob": "^3.3.2",
"fastq": "^1.17.1",
"fill-range": "^7.1.1",
"finalhandler": "^1.2.0",
"foreground-child": "^3.3.0",
"forwarded": "^0.2.0",
"fraction.js": "^4.3.7",
"framer-motion": "^11.3.24",
"fresh": "^0.5.2",
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.4",
"glob": "^10.4.5",
"glob-parent": "^6.0.2",
"gopd": "^1.0.1",
"graceful-fs": "^4.2.11",
"has-property-descriptors": "^1.0.2",
"has-proto": "^1.0.3",
"has-symbols": "^1.0.3",
"hasown": "^2.0.2",
"http-errors": "^2.0.0",
"iconv-lite": "^0.4.24",
"inherits": "^2.0.4",
"ipaddr.js": "^1.9.1",
"is-binary-path": "^2.1.0",
"is-core-module": "^2.15.0",
"is-extglob": "^2.1.1",
"is-fullwidth-code-point": "^3.0.0",
"is-glob": "^4.0.3",
"is-number": "^7.0.0",
"isexe": "^2.0.0",
"jackspeak": "^3.4.3",
"jiti": "^1.21.6",
"js-tokens": "^4.0.0",
"jsonwebtoken": "^9.0.2",
"jwa": "^1.4.1",
"jws": "^3.2.2",
"kareem": "^2.6.3",
"lilconfig": "^2.1.0",
"lines-and-columns": "^1.2.4",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.1.1",
"loose-envify": "^1.4.0",
"lru-cache": "^10.4.3",
"media-typer": "^0.3.0",
"memory-pager": "^1.5.0",
"merge-descriptors": "^1.0.1",
"merge2": "^1.4.1",
"methods": "^1.1.2",
"micromatch": "^4.0.7",
"mime": "^1.6.0",
"mime-db": "^1.52.0",
"mime-types": "^2.1.35",
"minimatch": "^9.0.5",
"minipass": "^7.1.2",
"monaco-editor": "^0.50.0",
"mongodb": "^6.7.0",
"mongodb-connection-string-url": "^3.0.1",
"mongoose": "^8.5.2",
"mpath": "^0.9.0",
"mquery": "^5.0.0",
"ms": "^2.0.0",
"mz": "^2.7.0",
"nanoid": "^3.3.7",
"negotiator": "^0.6.3",
"next": "^14.2.5",
"node-releases": "^2.0.18",
"normalize-path": "^3.0.0",
"normalize-range": "^0.1.2",
"object-assign": "^4.1.1",
"object-hash": "^3.0.0",
"object-inspect": "^1.13.2",
"on-finished": "^2.4.1",
"package-json-from-dist": "^1.0.0",
"parseurl": "^1.3.3",
"path-key": "^3.1.1",
"path-parse": "^1.0.7",
"path-scurry": "^1.11.1",
"path-to-regexp": "^0.1.7",
"picocolors": "^1.0.1",
"picomatch": "^2.3.1",
"pify": "^2.3.0",
"pirates": "^4.0.6",
"postcss": "^8.4.41",
"postcss-import": "^15.1.0",
"postcss-js": "^4.0.1",
"postcss-load-config": "^4.0.2",
"postcss-nested": "^6.2.0",
"postcss-selector-parser": "^6.1.1",
"postcss-value-parser": "^4.2.0",
"proxy-addr": "^2.0.7",
"punycode": "^2.3.1",
"qs": "^6.11.0",
"queue-microtask": "^1.2.3",
"range-parser": "^1.2.1",
"raw-body": "^2.5.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"read-cache": "^1.0.0",
"readdirp": "^3.6.0",
"resolve": "^1.22.8",
"reusify": "^1.0.4",
"run-parallel": "^1.2.0",
"safe-buffer": "^5.2.1",
"safer-buffer": "^2.1.2",
"scheduler": "^0.23.2",
"semver": "^7.6.3",
"send": "^0.18.0",
"serve-static": "^1.15.0",
"set-function-length": "^1.2.2",
"setprototypeof": "^1.2.0",
"shebang-command": "^2.0.0",
"shebang-regex": "^3.0.0",
"side-channel": "^1.0.6",
"sift": "^17.1.3",
"signal-exit": "^4.1.0",
"source-map-js": "^1.2.0",
"sparse-bitfield": "^3.0.3",
"state-local": "^1.0.7",
"statuses": "^2.0.1",
"streamsearch": "^1.1.0",
"string-width": "^5.1.2",
"string-width-cjs": "^4.2.3",
"strip-ansi": "^7.1.0",
"strip-ansi-cjs": "^6.0.1",
"styled-jsx": "^5.1.1",
"sucrase": "^3.35.0",
"supports-preserve-symlinks-flag": "^1.0.0",
"tailwindcss": "^3.4.9",
"ws": "^8.18.0"
"thenify": "^3.3.1",
"thenify-all": "^1.6.0",
"to-regex-range": "^5.0.1",
"toidentifier": "^1.0.1",
"tr46": "^4.1.1",
"ts-interface-checker": "^0.1.13",
"tslib": "^2.4.0",
"type-is": "^1.6.18",
"unpipe": "^1.0.0",
"update-browserslist-db": "^1.1.0",
"util-deprecate": "^1.0.2",
"utils-merge": "^1.0.1",
"vary": "^1.1.2",
"webidl-conversions": "^7.0.0",
"whatwg-url": "^13.0.0",
"which": "^2.0.2",
"wrap-ansi": "^8.1.0",
"wrap-ansi-cjs": "^7.0.0",
"ws": "^8.18.0",
"yaml": "^2.5.0"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"export": "next build && next export",
"test": "echo \"No tests specified\" && exit 0"
}
"test": "echo \"Error: no test specified\" && exit 1",
"build": "next build"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Loading

0 comments on commit a4a5ef2

Please sign in to comment.