How coordipai/web-server works
Project type and purpose
• From the file tree and common conventions (routers, services, repositories, schemas, a Dockerfile, pyproject.toml) this is a backend-only REST API service written in Python (likely using FastAPI or a similar framework).
• It provides user authentication (JWT, GitHub OAuth, Redis), issue tracking and rescheduling, project and user management, an AI “agent” module (chain, prompts, tool), plus response handling, logging, tracing, and CI/CD.
File structure
• Top‐level:
• src/main.py – application entrypoint (mounts routers, middleware, config).
• src/config – database, logger, middleware, tracing, volume (storage) setup.
• src/auth – authentication layer: GitHub OAuth, JWT generation, Redis session caching.
• src/agent – AI agent orchestration: prompt management, chain of tools, router.
• src/issue & src/issue_rescheduling – issue management and automated rescheduling submodule.
• src/project, src/project_user – project entities and assignments.
• src/user & src/user_repository – user profiles versus external user datastore.
• src/response – unified response schemas, error/success definitions.
• src/stat – statistics aggregation.
• Each feature submodule follows the Router → Service → Repository → (Model/Schema) pattern.
• Infrastructure/configuration via Dockerfile, pre-commit, GitHub Actions (deploy.yml, restart.yml).
Key architectural patterns
• Layered architecture:
• HTTP layer (FastAPI routers)
• Application/service layer (business logic)
• Data access layer (repositories)
• Configuration & cross-cutting concerns in config (logging, tracing, middleware).
• External integrations: GitHub OAuth, Redis for session store, relational database.
• CI/CD pipelines as part of the overall system delivery.
Components and interactions
a. Main Components:
1. Clients (Web or API consumers)
2. API Gateway / FastAPI application
• Routers (auth, agent, issue, issue_rescheduling, project, project_user, user, user_repository, stat)
• Middleware (CORS, authentication, logging, tracing)
3. Service Layer (domain logic for each feature)
4. Repository Layer (ORM or DB connectors)
5. Persistence: Relational Database (PostgreSQL/MySQL)
6. Cache/Session Store: Redis
7. External Service: GitHub OAuth API
8. CI/CD (GitHub Actions) and Docker host for deployment
9. Logging & Tracing Backend
b. Relationships & Data Flows:
• Client → HTTP → FastAPI Router (e.g., /auth, /issue)
• Router → calls Service → calls Repository → Database
• Auth Router → calls GitHub OAuth API & Redis for session/token storage
• Agent Router → calls AI Chain & Tools internally (no external X)
• All requests pass through middleware (logging, tracing) → traces → tracing backend
• Docker build pushes container → deploy pipeline → hosts service
c. Architectural patterns / principles:
• Separation of concerns (layers, modules)
• Dependency inversion (routers depend on abstract services, services on abstract repositories)
• Single responsibility per module (each folder encapsulates one domain concept)
d. Key technologies:
• FastAPI (or similar) for HTTP
• Pydantic for schemas
• SQLAlchemy or another ORM in repo layer
• Redis (session cache)
• GitHub OAuth
• Docker + GitHub Actions
Detailed capturing of essential elements
• Middleware and config modules as cross-cutting or a shared library.
• Agent module separately to show its custom chain/prompt/tool flow if needed.