π A self-contained document scanning and matching system with a built-in credit system. Users can upload documents, scan them for matches, and manage their credits, while admin can view analytics and approve credit requests.
docscanner.mp4
β
User registration & login
β
User roles: Regular Users & Admin
β
Profile section with credits, past scans, and credit requests
ποΈ Users get 20 free scans per day (auto-reset at midnight π)
β Users can request additional credits, which admins can approve/deny
π Each document scan deducts 1 credit
π Upload plain text, PDF, or Word documents
π§ Scanning methods:
- Basic Text Matching (Levenshtein distance)
- AI-powered Matching (spaCy for semantic similarity)
π Displays matching documents with percentage similarity
π Track number of scans per user
π Identify most common scanned document topics
π View top users by scans & credit usage
π Generate credit usage statistics
π Secure user authentication with hashed passwords
π« Admin-only access to sensitive features (e.g., analytics, credit approval)
- π Frontend: HTML, CSS, JavaScript
- π₯οΈ Backend: Django (Python)
- π¦ Database: SQLite (for development)
- π File Storage: Local storage for uploaded documents
- π§ AI Matching: spaCy for semantic similarity
1οΈβ£ Python 3.8+ installed on your system
2οΈβ£ pip (Python package manager)
π₯ Clone the Repository
git clone https://github.com/skp3214/document-scanning-and-matching-system.git
cd document-scanning-and-matching-systemπ οΈ Create a Virtual Environment
python -m venv venv
venv\Scripts\activateπ₯ Move to Project Directory
cd Doc_Scanner_Matcherπ¦ Install Dependencies
pip install -r requirements.txtποΈ Set Up the Database
python manage.py migrateπ Create an Admin User
python manage.py createsuperuserπ Follow the prompts to set a username, email, and password for the admin user.
python manage.py runserverπ Access the App: Open http://127.0.0.1:8000/ in your browser
π Important Note:
- To allow the admin user to approve/deny credit requests, follow these steps:
- Log in to the Django admin panel at
http://127.0.0.1:8000/admin/using the superuser credentials. - Navigate to the UserProfiles table.
- Add the admin user to this table to grant them the required privileges.
- Log in to the Django admin panel at
Now, the admin user can approve/deny credit requests as shown in the video. π
1οΈβ£ Register & Log In π
2οΈβ£ Upload & Scan Documents π
3οΈβ£ Check Profile (Credits, Past Scans, Requests) π€
4οΈβ£ Request More Credits β
1οΈβ£ Approve/Deny Credit Requests βοΈβ
2οΈβ£ View Analytics Dashboard π
For questions or feedback, reach out:
π§ Email: spsm1818@gmail.com
π GitHub: skp3214
| Endpoint | URL Path | View Function | Description |
|---|---|---|---|
| User Registration | auth/register/ |
register |
Registers a new user. |
| User Login | auth/login/ |
user_login |
Logs in a user. |
| Home Page | / |
home |
Displays the homepage. |
| User Profile | user/profile/ |
profile |
Shows user profile. |
| Request Credits | credits/request/ |
request_credits |
Allows users to request additional credits. |
| Admin Credit Management | credits/admins/ |
admin_credits |
Admins manage credit requests. |
| Scan Document | scan/ |
scan_document |
Upload and scan a document for matches. |
| View Matches | matches/<int:doc_id>/ |
matches |
Displays matching documents. |
| Document Details | document/<int:doc_id>/ |
document_detail |
Shows details of a scanned document. |
| Download Scan History | download-scan-history/ |
download_scan_history |
Downloads user's scan history. |
| Admin Analytics | admins/analytics/ |
analytics |
Admin dashboard with scan and credit statistics. |
| User Logout | logout/ |
user_logout |
Logs out the user. |
This documentation provides an overview of the Django views used in the Document Scanning and Matching System. The views handle user authentication, document scanning, credit management, and analytics.
- Purpose: Handles user registration.
- Methods:
- GET: Displays the registration form.
- POST: Processes the form data, creates a new user, and logs them in.
- Redirects: To the
homepage after successful registration. - Template:
register.html
- Purpose: Handles user login.
- Methods:
- GET: Displays the login form.
- POST: Authenticates the user and logs them in.
- Redirects: To the
homepage (or thenextURL if provided) after successful login. - Template:
login.html
- Purpose: Handles user logout.
- Methods:
- GET: Logs out the user.
- Redirects: To the
homepage after logout.
- Purpose: Displays the home page.
- Methods:
- GET: Renders the home page with the logged-in user's username.
- Template:
home.html
- Purpose: Displays the user's profile, including their credits, past scans, and credit requests.
- Methods:
- GET: Renders the profile page with the user's data.
- Template:
profile.html
- Purpose: Handles credit requests from users.
- Methods:
- GET: Displays the credit request form.
- POST: Processes the form data and creates a new
CreditRequest.
- Redirects: To the
profilepage after submitting the request. - Template:
creditsrequest.html
- Purpose: Allows admins to approve or deny credit requests.
- Methods:
- GET: Displays a list of pending credit requests.
- POST: Processes the admin's action (approve/deny) and updates the request status.
- Redirects: To the
profilepage if the user is not an admin. - Template:
admincredits.html
- Purpose: Handles document uploads and scans.
- Methods:
- GET: Displays the document upload form.
- POST: Processes the uploaded file, extracts its content, and creates a new
Document.
- Redirects: To the
matchespage after successful upload. - Template:
scan.html
- Purpose: Displays documents similar to the uploaded document.
- Methods:
- GET: Renders the matches page with the uploaded document and its matches.
- Template:
matches.html
- Purpose: Displays the content of a specific document.
- Methods:
- GET: Renders the document detail page.
- Template:
document_detail.html
- Purpose: Allows users to download their scan history as a text file.
- Methods:
- GET: Generates and serves a text file with the user's scan history.
- Response: A plain text file with the scan history.
- Purpose: Displays analytics for admins, including scans per user, credit usage, and common topics.
- Methods:
- GET: Renders the analytics dashboard.
- Redirects: To the
profilepage if the user is not an admin. - Template:
analytics.html
- Purpose: Resets the user's credits at midnight.
- Usage: Called in the
profileview to ensure credits are reset daily.
- Purpose: Finds documents similar to the uploaded document using basic text matching (e.g., Levenshtein distance).
- Usage: Called in the
matchesview.
- Purpose: Finds documents similar to the uploaded document using AI-powered matching (spaCy).
- Usage: Called in the
matchesview.
-
User Registration:
- A new user registers using the
registerview. - They are redirected to the
homepage after registration.
- A new user registers using the
-
User Login:
- The user logs in using the
user_loginview. - They are redirected to the
homepage (or thenextURL) after login.
- The user logs in using the
-
Document Upload:
- The user uploads a document using the
scan_documentview. - They are redirected to the
matchespage to view similar documents.
- The user uploads a document using the
-
Credit Request:
- The user requests additional credits using the
request_creditsview. - An admin approves or denies the request using the
admin_creditsview.
- The user requests additional credits using the
-
Analytics:
- An admin views analytics using the
analyticsview.
- An admin views analytics using the
register.html: Registration form.login.html: Login form.home.html: Home page.profile.html: User profile page.creditsrequest.html: Credit request form.admincredits.html: Admin credit approval page.scan.html: Document upload form.matches.html: Matches page.document_detail.html: Document detail page.analytics.html: Analytics dashboard.
- spaCy: Used for AI-powered document matching.
- Install with:
pip install spacy - Download the English model:
python -m spacy download en_core_web_sm
- Install with:
Stores additional user-related data, such as credits and the last reset time.
user: One-to-One relationship with Django's built-inUsermodel.credits: Integer field to track the user's available credits (default: 20).last_reset: DateTime field to store the last time credits were reset (auto-generated on creation).
Stores user-uploaded documents and their processed data.
user: ForeignKey relationship with theUsermodel (one user can have multiple documents).file: FileField to store the uploaded document in thedocuments/directory.uploaded_at: DateTime field to record when the document was uploaded (auto-generated).content: TextField to store extracted text content from the document.vector: BinaryField to store the documentβs processed vector representation (nullable and optional).
save(self, *args, **kwargs): Overrides the default save method to:- Process document content using SpaCy (
en_core_web_sm). - Convert the processed content into a vector and store it as a binary field.
- Call the parent class's
save()method to persist data.
- Process document content using SpaCy (
Handles credit requests from users.
user: ForeignKey relationship with theUsermodel (one user can make multiple credit requests).requested_credits: Integer field to store the number of credits requested.status: CharField to store the request status (pendingby default, can be updated later).requested_at: DateTime field to record when the request was made (auto-generated).
spacyis used for natural language processing, extracting vectors from document content.- Binary vectors are stored in the
vectorfield for future similarity searches. - Credits help manage document processing, ensuring fair usage.