How kentchiu/stock works
Main Components
• Backend API – All code is located within the “api” folder. This includes:
• Configuration and database connectivity (api/stock/config/database.py)
• Data models and schemas (api/stock/models, api/stock/schemas)
• Repositories for data access (api/stock/repositories)
• Routers for API endpoints (api/stock/routers) built using FastAPI
• Business logic services (api/stock/services)
• Utility functions and exception handling (api/stock/utils)
• Tests under “api/tests” ensuring quality and reliability.
• Frontend Web Application – Present in the “web” directory:
• Built with ReactJS and TypeScript. Notice components, hooks, pages, and Recoil state management for UI and user interactions.
• Visual assets and configuration files (e.g., TailwindCSS configuration, nginx-proxy in web/nginx-proxy.conf) for deployment.
• Database – The application uses SQLite, with the database file managed in “api/data”. The README even includes commands to dump the DB contents.
• Infrastructure/Deployment – Docker Compose files and Dockerfiles in both “api” and “web” directories outline containerization for both frontend and backend.
• Documentation – The doc directory and images in the README offer insights into application features and are useful for illustrating the user interface as part of the overall architecture.
Relationships & Interactions
• The Frontend (ReactJS) communicates with the Backend API via HTTP endpoints exposed by FastAPI routers.
• The Backend serves client requests by invoking service layers that rely on repository logic to communicate with the SQLite database.
• Docker and Docker Compose orchestrate the deployment of the entire stack, ensuring backend and frontend containers work together seamlessly.
• Testing modules (unit & integration tests) interact with both backend repositories and endpoints to guarantee correct behavior.
Architectural Patterns & Technologies
• MVC/Microservice-like layer separation in the backend – models, routers (controllers), services (business logic), and repositories (data access).
• State management using RecoilJS on the frontend.
• API design leveraging RESTful principles with FastAPI.
• Containerization practices via Docker Compose.
• Emphasis on separation of concerns where the frontend, backend, and database are clearly delineated.