Skip to content

sandipto729/SRSNBackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

SRSN Backend

This repository contains the backend code for the Sri Ramkrishna Siksha Niketan project, handling user data, authentication, and various administrative functionalities to support the school's web portal.

Features

  • User Authentication: Secure login and password management using bcrypt.
  • Data Management:
    • CRUD operations for student records, including student information, results, and class changes.
    • Event management with toggles for event status controlled by admin permissions.
  • Event Tracking: A separate table records event status changes, with a popup for detailed change history.
  • Profile Picture Uploads: Integrated with Cloudinary to handle image uploads and URL generation.
  • Real-Time Chat:Implemented socket-based functionality for real-time communication, with separate chat rooms for classes, events, or admin discussions, including typing indicators and message delivery status.
  • Redis Integration: Used for ATP (Automatic Token Processing) verification to enhance security and efficiency, and leveraged as an in-memory storage system for faster operations like session management, caching, and real-time data synchronization.

Tech Stack

  • Node.js and Express: Backend framework for API endpoints.
  • MongoDB: Database for storing user data and event details.
  • Nodemailer: For sending notification emails (e.g., password recovery).
  • bcrypt: For password hashing.
  • Cloudinary: For image upload and storage.
  • Redis: For ATP verification, in-memory storage, and faster operations like caching and session management.
  • Socket.io: For implementing real-time communication through sockets.
  • Docker: For containerizing the application and ensuring consistency across development and production environments.

Project Structure

The project structure follows a standard Node.js MVC architecture:

SRSNBackend/
├── backend/
│   ├── socket/              # Handles real-time socket connections and events
│   ├── config/              # Configuration files (e.g., MongoDB connection)
│   ├── controller/          # Handles business logic for various routes
│   ├── helper/              # Helper functions (e.g., password hashing, utility functions)
│   ├── middleware/          # Middleware, including authentication checks
│   ├── model/               # Mongoose schemas for MongoDB collections
│   ├── public/              # Static files (e.g., images, stylesheets, JavaScript)
│   └── routes/              # Defines API routes

Run Locally

Process 1

Clone the project

  git clone https://github.com/sandipto729/ SRSNBackend.git

Go to the project directory

  cd SRSNBackend

Install dependencies

  npm install

Add Environment Variables

    MONGO_URL=Your_Mongodb_connection_string
    FRONTEND_URL=Your_frontend_url
    TOKEN_SECRET_KEY=Your_Token_key
    PASSKEY=Your_Gmail_Password

Start the server

  node index.js

Process 2

Running the Repository Using Docker

To run this repository with Docker, follow these steps:

  • Ensure Prerequisites Are Installed

Make sure you have Docker installed on your system. You can download Docker from Docker's official website.

  • Set Up Required Environment Variables

The following environment variables are needed to run the container successfully:

  • MONGO_URL: The connection string for your MongoDB database.

  • TOKEN_SECRET_KEY: A secret key used for token-based authentication.

  • PassKey: The passkey for your Gmail account, used for email functionality.

  • REDIS_PASSWORD: The password for your Redis instance.

  • REDIS_HOST: The hostname or IP address of your Redis instance.

  • REDIS_PORT: The port on which your Redis instance is running.

  • Run the Docker Command

Execute the following command in your terminal to start the Docker container:

docker run -it \
  -e MONGO_URL="Your_mongo_database" \
  -e TOKEN_SECRET_KEY="Your_token_secret_key" \
  -e PassKey="Your_gmail_passkey" \
  -e REDIS_PASSWORD="Your_redis_password" \
  -e REDIS_HOST="Your_redis_host" \
  -e REDIS_PORT="Your_redis_port" \
  -p 8000:8000 sandipto729/srsnbackend

Replace the placeholder values (Your_mongo_database, Your_token_secret_key, etc.) with your actual environment-specific configurations.

  • Access the Application Once the container is running, the application will be accessible on http://localhost:8000.

  • Stopping the Container To stop the running container, press Ctrl+C in the terminal or use the docker stop command followed by the container ID.

Authors

Contributing

Contributions are welcome! Please fork this repository, create a new branch, and submit a pull request with a description of your changes.

License

MIT

Used By

This project is used by the following companies:

  • Student and Teachers of Sri Ramkrishna Siksha Niketan School (Primary and High Section)

Feedback

We value your feedback! If you have any comments, suggestions, or questions about our project, please feel free to reach out to us.

You can contact us at: sandipto729@gmail.com

Thank you for your support, and happy coding!

Releases

No releases published

Packages

No packages published