-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from EchoSkorJjj/frontend-design
Frontend design, user storage service, and notes service merge to main
- Loading branch information
Showing
98 changed files
with
4,971 additions
and
651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
**/*_password.txt | ||
.DS_Store | ||
node_modules | ||
.env | ||
.env | ||
**/log.txt | ||
**/user-storage.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.vscode | ||
.DS_Store | ||
|
||
.env | ||
.env.local | ||
.env.development.local | ||
|
||
venv | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.9-slim | ||
ENV PYTHONUNBUFFERED=1 | ||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Install any needed packages specified in requirements.txt | ||
# Copy only the requirements.txt first to leverage Docker cache | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the rest of the application | ||
COPY . . | ||
|
||
# It's a good practice to expose the port your app runs on. | ||
# This does not actually publish the port but serves as documentation. | ||
EXPOSE 50052 | ||
|
||
# Run note_upload_service.py when the container launches | ||
CMD ["python3", "note_upload_service.py"] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
1. Build Image | ||
docker build -t notes-service . | ||
|
||
2. Run container | ||
docker run -p 50051:50051 \ | ||
-e AWS_ACCESS_KEY_ID=your_access_key_id \ | ||
-e AWS_SECRET_ACCESS_KEY=your_secret_access_key \ | ||
notes-service | ||
|
||
- | ||
Build instructions from Neil Sharma: | ||
1. 2x GRPC server (to talk to upload notes, to talk to retrieve notes) | ||
(Server is just responding to requests) | ||
2. We can choose between Unitary or bidirectional streaming | ||
3. For client we should create simple client to upload notes | ||
4. DB/Schema is up to us to create | ||
5. Implement good logging, as a .log file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import grpc | ||
import notes_pb2 | ||
import notes_pb2_grpc | ||
|
||
def upload_note(stub, user_id, filename, file_content): | ||
# Create a request message | ||
request = notes_pb2.UploadNoteRequest(userId=user_id, filename=filename, fileContent=file_content) | ||
# Make the call to the server | ||
response = stub.UploadNote(request) | ||
return response | ||
|
||
def retrieve_note(stub, note_id): | ||
# Create a request message | ||
request = notes_pb2.RetrieveNoteRequest(noteId=note_id) | ||
# Make the call to the server | ||
response = stub.RetrieveNote(request) | ||
return response | ||
|
||
def run(): | ||
with grpc.insecure_channel('localhost:50052') as channel: | ||
stub = notes_pb2_grpc.NoteServiceStub(channel) | ||
|
||
# Example usage: upload a PDF note | ||
user_id = '123' | ||
filename = 'example_note.pdf' # Change to your PDF file name | ||
with open(filename, 'rb') as pdf_file: # Open the PDF file in binary mode | ||
file_content = pdf_file.read() # Read the entire PDF file content | ||
upload_response = upload_note(stub, user_id, filename, file_content) | ||
print(f"Uploaded Note ID: {upload_response.noteId}") | ||
|
||
# Example usage: retrieve a note | ||
# Note: You need to implement this part on the server side for it to work | ||
note_id = upload_response.noteId | ||
retrieve_response = retrieve_note(stub, note_id) | ||
# print(f"Retrieved Note Content: {retrieve_response.fileContent}") | ||
|
||
if __name__ == '__main__': | ||
run() |
Oops, something went wrong.