How chillin-s-playground/eggchatter-web-app-be works
Project type and purpose
• This is a backend‐only RESTful API service called “EggChatter Backend,” built with FastAPI.
• Purpose: provide user authentication (JWT), chat messaging, and “easter egg” GIF features, persisting data in MongoDB.
File structure
• Top level:
• app/main.py – entry point (FastAPI app)
• app/core – configuration, DB connection, security, shared exceptions
• app/routers – HTTP endpoints grouped by domain (auth, users, easter_egg, chats)
• app/services – business logic layer (auth, users, easter_egg, chats)
• app/models – ORM/data models for MongoDB collections
• app/schemas – Pydantic request/response schemas
• tests – unit tests
• Config files: pyproject.toml (Poetry), .env for runtime variables, pytest.ini for testing
README insights
• Tech stack: FastAPI, MongoDB, Pydantic, JWT (HS256), Poetry
• Features: authentication, real‐time chat (via REST/WebSockets?), easter‐eggs API
• Runtime: uvicorn on port 8080
Main components
a. External Clients (Web/Mobile)
b. API Gateway / FastAPI App
• Entry point (app/main.py)
• Routers (auth, users, chats, easter_egg)
c. Core Layer
• Config (env variables)
• Security (JWT encoding/verification)
• Database connector (MongoDB client)
d. Service Layer
• AuthService, UserService, ChatService, EasterEggService
• Implements business logic, calls models & core utilities
e. Data Layer
• MongoDB collections via Models (User, Chat, Friend, EasterEgg)
f. External Dependencies
• MongoDB instance
• Possibly third‐party GIF API or CDN for easter eggs
Relationships and data flow
• Client → HTTP Request → FastAPI (main)
• FastAPI Router → corresponding Service
• Service → Core Database module → MongoDB
• Service → Core Security module → sign/verify JWT
• Service → external GIF API (for easter eggs)
• Response back through Router → Client
Architectural patterns & principles
• Layered architecture:
1. Presentation/API layer (routers)
2. Business logic layer (services)
3. Data access layer (models + core database)
• Separation of concerns: config/security isolated in core
• Use of Pydantic schemas to enforce data contracts
• Dependency injection (FastAPI’s Depends) to wire config, DB, and services
Elements
• API entrypoint (app/main.py)
• Router modules grouped by domain
• Service modules
• Core modules (config, database, security)
• MongoDB instance
• External GIF/Media service