Skip to content

Webziro/Fom-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

307 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Finfom API

Overview

Finfom is a robust document management and secure sharing platform built using Node.js, Express, and TypeScript. It leverages a modern microservice-ready architecture to handle file versioning, granular access control, and real-time analytics for digital assets.

Tools

  • Node.js & TypeScript: High-performance server-side logic with static typing for maintainability.
  • MongoDB & Mongoose: Flexible NoSQL data modeling for documents, and folders
  • Redis: In-memory data store used for API response caching to optimize public resource access.
  • Cloudinary: Integrated cloud storage for secure asset hosting and optimized file delivery.
  • Multer: Efficient handling of multipart/form-data for seamless document uploads.
  • JWT: Stateless authentication mechanism using JSON Web Tokens for secure session management.
  • Winston & Morgan: Comprehensive logging suite for auditing HTTP traffic and system events.

Getting Started

Installation

  1. Clone the repository:
git clone https://github.com/Webziro/Fom-app.git
  1. Navigate to the backend directory:
cd finfom-backend
  1. Install production and development dependencies:
npm install
  1. Seed the system groups (Technology, Business, etc.):
npm run seed
  1. Launch the development server:
npm run dev

Environment Variables

Create a .env file in the backend root and configure the following:

PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/finfom
REDIS_HOST=localhost
REDIS_PORT=6379
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRE=7d
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
CLIENT_URL=http://localhost:5173
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_EMAIL=your_email@gmail.com
SMTP_PASSWORD=your_app_password
FROM_NAME=Finfom
FROM_EMAIL=no-reply@finfom.com

API Documentation

Base URL

http://localhost:5000

Endpoints

POST /api/auth/register

Request:

{
  "username": "johndoe",
  "email": "john.doe@example.com",
  "password": "StrongPassword123!"
}

Response:

{
  "success": true,
  "data": {
    "id": "64f8a7b2c9d4e5f6a7b8c9d0",
    "username": "johndoe",
    "email": "john.doe@example.com",
    "role": "user",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Errors:

  • 400: User already exists or validation failed (password too weak, invalid email).

POST /api/auth/login

Request:

{
  "email": "john.doe@example.com",
  "password": "StrongPassword123!"
}

Response:

{
  "success": true,
  "data": {
    "id": "64f8a7b2c9d4e5f6a7b8c9d0",
    "token": "eyJhbGciOiJIUzI1Ni..."
  }
}

Errors:

  • 401: Invalid credentials.

POST /api/files/upload

Request: Multipart Form Data

  • file: binary data (PDF, JPG, PNG, DOCX)
  • title: "Quarterly Report"
  • description: "Final version for Q3"
  • visibility: "private" | "public" | "password"
  • password: "secret123" (if visibility is password)

Response:

{
  "success": true,
  "data": {
    "id": "64f8a7b2c9d4e5f6a7b8c9d1",
    "title": "Quarterly Report",
    "url": "https://res.cloudinary.com/...",
    "currentVersion": 1
  }
}

Errors:

  • 400: Missing required fields or invalid file type.

GET /api/files

Request: GET /api/files?page=1&limit=10&search=report&folderId=64f... Header: Authorization: Bearer

Response:

{
  "success": true,
  "data": [...],
  "pagination": {
    "total": 25,
    "pages": 3
  }
}

POST /api/files/:id/download

Request:

{
  "password": "secret123"
}

Response: Binary stream with Content-Disposition header

Errors:

  • 403: Access denied (private file or incorrect password).

GET /api/files/analytics

Request: Header: Authorization: Bearer

Response:

{
  "success": true,
  "data": {
    "totalDownloads": 150,
    "storageUsed": 10485760,
    "topFiles": [...],
    "fileTypes": [{"_id": "application/pdf", "count": 10}]
  }
}

POST /api/files/folders

Request:

{
  "title": "Tax Returns 2024",
  "description": "Financial folders"
}

Response:

{
  "success": true,
  "data": {
    "id": "64f8a7...",
    "title": "Tax Returns 2024"
  }
}

Technologies Used

Technology Description Link
Node.js JavaScript Runtime Link
TypeScript Typed JavaScript Link
Express Web Framework Link
MongoDB NoSQL Database Link
Redis Caching Engine Link
Cloudinary Cloud Storage Link
Vite Frontend Tooling Link
Tailwind CSS Utility-first CSS Link

Contributing

  • Fork the repository.
  • Create a new feature branch (git checkout -b feature/NewFeature).
  • Commit your changes with descriptive messages.
  • Push to the branch (git push origin feature/NewFeature).
  • Open a Pull Request for review.

Author Info

Project Lead

  • GitHub: Webziro
  • Twitter: [Placeholder]
  • LinkedIn: [Placeholder]

Node.js TypeScript Express MongoDB

Readme was generated by Dokugen

About

A document storage and sharing app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors