The backend of Decision Compass is engineered in Indore to provide a robust and secure foundation for complex decision-making. It primarily handles secure user authentication, ensuring that all decision data remains private and accessible only to authorized users.
- Secure user authentication
- Robust backend for decision-making workflows
- Privacy-focused: Only authorized access to decision data
- 100% JavaScript
- Node.js (version X.X.X or higher)
- npm (Node package manager)
-
Clone the repository:
git clone https://github.com/hyper-27/dc-backend.git cd dc-backend
-
Install dependencies:
npm install
-
Configure environment variables:
- Create a
.env
file in the root directory. - Add necessary configuration values as shown below.
- Create a
-
Start the server:
npm start
Create a .env
file in your project root with values like:
PORT=3000
MONGO_URI=mongodb://localhost:27017/dc-backend
JWT_SECRET=your_jwt_secret
Register
POST /api/auth/register
{
"username": "john_doe",
"email": "john@example.com",
"password": "yourpassword"
}
Response:
{
"message": "User registered successfully",
"userId": "abc123"
}
Login
POST /api/auth/login
{
"email": "john@example.com",
"password": "yourpassword"
}
Response:
{
"token": "jwt_token_here",
"user": {
"id": "abc123",
"username": "john_doe"
}
}
Get All Decisions (Authenticated)
GET /api/decisions
Headers:
Authorization: Bearer <jwt_token>
Response:
[
{
"id": "decision1",
"title": "Choose tech stack",
"options": ["Node.js", "Python", "Go"],
"createdBy": "abc123"
}
]
Create a New Decision
POST /api/decisions
Headers:
Authorization: Bearer <jwt_token>
{
"title": "Choose cloud provider",
"options": ["AWS", "Azure", "GCP"]
}
Response:
{
"message": "Decision created",
"decisionId": "decision2"
}
dc-backend/
├── controllers/
│ ├── authController.js
│ └── decisionController.js
├── models/
│ ├── userModel.js
│ └── decisionModel.js
├── routes/
│ ├── authRoutes.js
│ └── decisionRoutes.js
├── middleware/
│ └── authMiddleware.js
├── app.js
├── server.js
├── .env.example
└── README.md
Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes.
---