API server for ChemCloud Web Service
450

Chemical inventory management system with real-time stock tracking, user authentication, and comprehensive reporting.
ChemCloud is a full-stack chemical inventory management system designed for educational institutions and laboratories. It provides secure authentication, stock movement tracking, year-based reporting, real-time updates, and exportable reports, all optimized for performance and scalability.
| Feature | Description |
|---|---|
| Faculty Authentication | Secure login/signup using JWT + HttpOnly cookies |
| Chemical Master DB | Add/update chemicals with measuring units & pack sizes |
| Stock Tracking | Log purchases & usage with auto-year handling |
| Real-time Search | Instant chemical search powered by Socket.IO |
| Reports | Year-wise reports, balance sheets, usage logs |
| Exports | Download PDF / XLSX reports |
| Responsive UI | Fully responsive React/Tailwind interface |
| Capability | Description |
|---|---|
| Multi-instance scaling | Redis-powered communication + rate limiting |
| Distributed Rate Limiting | Protects API using Redis tokens |
| Monitoring | Health endpoints + structured logs |
| Dockerized Infrastructure | Full Docker + Compose support |
| Graceful Shutdown | Safe cleanup and connection closure |
| Logging | Winston-based structured logs |
flowchart LR
A[React Frontend] -- Axios/Socket.IO --> B[Express API]
B -- Mongo Queries --> C[(MongoDB)]
B -- Cache/Rate Limit --> D[(Redis)]
A -- Static Assets --> E[Nginx]
subgraph Container Stack
B
E
end
sequenceDiagram
participant F as Faculty (User)
participant FE as Frontend
participant API as Express API
participant DB as MongoDB
participant R as Redis
F->>FE: Login request
FE->>API: POST /login
API->>DB: Verify credentials
API->>FE: JWT Cookie (HttpOnly)
F->>FE: Search Chemical
FE->>API: GET /chemical?q=...
API->>R: Cache/Ratelimit
API->>DB: Fetch Chemicals
API->>FE: Results
API->>FE: Socket.IO update events
| Tech | Purpose |
|---|---|
| Node.js 20 | Runtime |
| Express.js 5 | API framework |
| MongoDB 7 | Primary database |
| Redis 7 | Cache + rate limiting |
| JWT + Bcrypt | Authentication & hashing |
| Helmet | Security headers |
| Winston | Logging |
| Socket.IO | Real-time updates |
| Tech | Purpose |
|---|---|
| React 18 | UI framework |
| Vite | Bundler |
| TailwindCSS | Styling |
| Shadcn/UI | Components |
| Axios | API requests |
| Socket.IO Client | Real-time |
| jsPDF / XLSX | Document exports |
| Tool | Use |
|---|---|
| Docker | Containerization |
| Docker Compose | Multi-container orchestration |
| Nginx | Production frontend hosting |
| GitHub Actions | CI/CD |
git clone https://github.com/Atharvkote/ChemCloud.git
cd ChemCloud
cp .env.example .env
docker-compose up -d
Access:(Local)
View logs:
docker-compose logs -f
cd server
npm install
npm run dev
cd client
npm install
npm run dev
server/
├── configs/
├── controllers/
├── models/
├── routes/
├── middlewares/
├── socket-handlers/
├── utils/
├── Dockerfile
└── server.js
client/
├── src/
│ ├── components/
│ ├── pages/
│ ├── contexts/
│ ├── hooks/
│ ├── services/
│ └── App.jsx
├── Dockerfile
├── nginx.conf
└── vite.config.js
| Method | Endpoint | Description |
|---|---|---|
| POST | /signup | Create account |
| POST | /login | Login |
| POST | /logout | Logout |
| GET | /check-auth | Validate token |
| Method | Endpoint |
|---|---|
| GET | /chemical |
| GET | /chemical/:id |
| POST | /chemical |
| PUT | /chemical/:id |
| DELETE | /chemical/:id |
| Method | Endpoint |
|---|---|
| GET | /chemical-report |
| GET | /chemical-report/balance/:id |
| POST | /chemical-report |
| DELETE | /chemical-report/:id |
| Key | Description |
|---|---|
| MONGODB_URI | Mongo connection |
| REDIS_URL | Redis instance |
| JWT_SECRET | Token signing secret |
| SERVER_PORT | API port |
| CORS_ORIGIN | Allowed origins |
Refer: .env.example
| Security Layer | Details |
|---|---|
| HttpOnly JWT | Protects against XSS |
| Bcrypt Hashing | Secure passwords |
| Helmet Headers | Industry-standard headers |
| Rate Limiting | 100 req / 30 seconds |
| Sanitization | Input cleaning |
| Docker Non-root User | Enhanced safety |
erDiagram
FACULTY ||--o{ CHEMICAL : created_by
FACULTY ||--o{ CHEMICAL_RECORD : updated_by
CHEMICAL ||--o{ CHEMICAL_RECORD : has
FACULTY {
string name
string email
string mobile
}
CHEMICAL {
string name
string baseUnit
number primaryPackSize
}
CHEMICAL_RECORD {
int year
string entryType
number usedQty
number openingQty
number closingQty
}
docker build -t chemcloud-api ./server
docker build -t chemcloud-frontend ./client
docker-compose up -d
| Tool | Usage |
|---|---|
| /health | Check API status |
| Docker Logs | docker-compose logs -f |
| Browser DevTools | UI/Socket debugging |
| Winston Logs | Server runtime logs |
| Issue | Fix |
|---|---|
| MongoDB connection error | Check URI / Mongo running |
| Redis not connecting | Disable Redis for local mode |
| CORS error | Add correct domain to CORS_ORIGIN |
| Socket.IO fail | Check network & server console |
| JWT invalid | Logout → Login again |
| Version | Planned Features |
|---|---|
| v1.1 | Unit tests, categories, rich reporting |
| v1.2 | Mobile app, equipment tracking |
| v2.0 | Multi-institution, analytics dashboard, ML predictions |
Atharv Kote – Full Stack Developer
Content type
Image
Digest
sha256:4e57c06ae…
Size
53.4 MB
Last updated
4 months ago
docker pull atharvakote/chemcloud-backend