How eriksonssilva/gemini-web-wrapper works
Project type and main objectives
• This is essentially a full-stack API tool acting as a middleware service. It exposes a /v1/chat/completions endpoint that accepts client requests (such as from Roo Code) and internally calls gemini-webapi to interact with Google Gemini Web.
• It focuses on a single, global chat instance per server run; hence state is maintained; and all incoming requests share the same conversation context.
File structure
• README.md – Provides the overall project description, usage notes, configuration, authentication details, and known limitations.
• gemini_api.py – Core entry point for the application. This file likely sets up the FastAPI server, initializes the global chat instance, and defines the REST endpoint (/v1/chat/completions).
• models/models.py – Contains the model definitions or helper functions that abstract parts of the chat or possibly request/response schemas.
• requirements.txt – Lists all dependencies, like FastAPI, gemini-webapi, browser-cookie3, etc.
Main components
a. API Layer (FastAPI):
• Represented by the gemini_api.py file. This is the entry point for incoming client HTTP requests.
• Exposed endpoint: /v1/chat/completions.
b. Global Chat Instance:
• A single, shared chat session used for handling conversation history. Emphasize that every incoming request touches this central state.
c. Gemini-WebAPI Integration:
• This component shows the connection between your API layer and the gemini-webapi library.
• It interacts with Google Gemini Web through browser cookies for authentication and session management.
d. Models and Data Processing:
e. External Components & Dependencies:
• External Service: Google Gemini Web. Illustrate how the gemini-webapi library connects to it.
• Authentication Mechanism: Browser cookies, which the gemini-webapi library uses to authenticate with Google Gemini.
• Clients: Tools like Roo Code that send requests to this API.
Architectural patterns and design principles
• Separation of concerns: the API layer (handling HTTP requests) is separate from the business logic (managed by gemini-webapi and the Global Chat Instance).
• Common design principles like modularity (via splitting out models and API endpoints), stateless HTTP endpoints (with a caveat that the single global chat has shared state), and dependency injection if used in FastAPI.